From 80ba39b9dfbe46eae1782a0ec69797143b12022b Mon Sep 17 00:00:00 2001 From: jchappelow Date: Mon, 24 Feb 2025 16:16:26 -0600 Subject: [PATCH] [v0.9] remove orderSchemas, update postgres docker image (#1413) * update pg docker w/ more locks, 16.8 * engine/execution: remove orderSchemas The orderSchemas function is no longer relevant as it was with extensions prior. * version 0.9.4 --- build/package/docker/postgres.dockerfile | 4 +- internal/engine/execution/global.go | 53 +----------------------- internal/version/version.go | 2 +- 3 files changed, 5 insertions(+), 54 deletions(-) diff --git a/build/package/docker/postgres.dockerfile b/build/package/docker/postgres.dockerfile index f189c08cb..486d8a890 100644 --- a/build/package/docker/postgres.dockerfile +++ b/build/package/docker/postgres.dockerfile @@ -1,4 +1,4 @@ -FROM postgres:16.5 +FROM postgres:16.8 # Inject the init script that makes the kwild superuser and a kwild database # owned by that kwild user, as well as a kwil_test_db database for tests. @@ -15,4 +15,4 @@ COPY ./pginit.sql /docker-entrypoint-initdb.d/init.sql # Override the default entrypoint/command to include the additional configuration CMD ["postgres", "-c", "wal_level=logical", "-c", "max_wal_senders=10", "-c", "max_replication_slots=10", \ "-c", "track_commit_timestamp=true", "-c", "wal_sender_timeout=0", "-c", "max_prepared_transactions=2", \ - "-c", "max_locks_per_transaction=256", "-c", "max_connections=128"] + "-c", "max_locks_per_transaction=4096", "-c", "max_connections=128"] diff --git a/internal/engine/execution/global.go b/internal/engine/execution/global.go index 0065a8ea7..df77c4937 100644 --- a/internal/engine/execution/global.go +++ b/internal/engine/execution/global.go @@ -6,7 +6,6 @@ import ( "encoding/json" "errors" "fmt" - "sort" "sync" "github.com/kwilteam/kwil-db/common" @@ -154,7 +153,7 @@ func NewGlobalContext(ctx context.Context, db sql.Executor, extensionInitializer // we need to make sure schemas are ordered by their dependencies // if one schema is dependent on another, it must be loaded after the other // this is handled by the orderSchemas function - for _, schema := range orderSchemas(schemas) { + for _, schema := range schemas { err := g.loadDataset(ctx, schema) if err != nil { return nil, fmt.Errorf("%w: schema (%s / %s / %s)", err, schema.Name, schema.DBID(), schema.Owner) @@ -175,7 +174,7 @@ func (g *GlobalContext) Reload(ctx context.Context, db sql.Executor) error { return err } - for _, schema := range orderSchemas(schemas) { + for _, schema := range schemas { err := g.loadDataset(ctx, schema) if err != nil { return err @@ -455,51 +454,3 @@ func (g *GlobalContext) unloadDataset(dbid string) { delete(g.datasets, dbid) delete(g.initializers, dbid) } - -// orderSchemas orders schemas based on their dependencies to other schemas. -func orderSchemas(schemas []*types.Schema) []*types.Schema { - // Mapping from schema DBID to its extensions - schemaMap := make(map[string][]string) - for _, schema := range schemas { - var exts []string - for _, ext := range schema.Extensions { - exts = append(exts, ext.Name) - } - schemaMap[schema.DBID()] = exts - } - - // Topological sort - var result []string - visited := make(map[string]bool) - var visitAll func(items []string) - - visitAll = func(items []string) { - for _, item := range items { - if !visited[item] { - visited[item] = true - visitAll(schemaMap[item]) - result = append(result, item) - } - } - } - - keys := make([]string, 0, len(schemaMap)) - for key := range schemaMap { - keys = append(keys, key) - } - sort.Strings(keys) // sort the keys for deterministic output - visitAll(keys) - - // Reorder schemas based on result - var orderedSchemas []*types.Schema - for _, dbid := range result { - for _, schema := range schemas { - if schema.DBID() == dbid { - orderedSchemas = append(orderedSchemas, schema) - break - } - } - } - - return orderedSchemas -} diff --git a/internal/version/version.go b/internal/version/version.go index cf0244ace..0c37058de 100644 --- a/internal/version/version.go +++ b/internal/version/version.go @@ -15,7 +15,7 @@ import ( // - 0.6.0+release // - 0.6.1 // - 0.6.2-alpha0+go1.21.nocgo -const kwilVersion = "0.9.3" +const kwilVersion = "0.9.4" // KwildVersion may be set at compile time by: //