Skip to content

lake_init reports success but its catalog records no relations #778

Closed

Description

@athvin

lake_init reports success but its catalog records no relations.

What was observed

Driving a real provision job through the executor (FakePodApi, the real
exec-task binary, a local-mode lake) settles succeeded with every task
row succeeded:

create_catalog succeeded {"doc":{"tenant":"acme"},"plan":"catalog_created"}
lake_init      succeeded {"doc":{"catalog_hash":"c7a7d3f8…"},"plan":"lake_initialized"}
activate       succeeded {"doc":{"activated":true},"plan":"org_activated"}

…and the lake it built has no tables:

exists raw_records       = Ok(false)
exists schema_migrations = Ok(false)
exists entities          = Ok(false)
exists golden_records    = Ok(false)

The directory holds a 1.8MB catalog.ducklake and 22 orphan parquet files,
all of them under data/main/schema_migrations/ — the ledger's own data, with
no live table recording it. No other .ducklake file exists anywhere under the
tenant root, so this is not a second catalog.

Not a stale attach. A freshly spawned process opening the same catalog and
data path sees exactly the same false for every relation, so it is not the
test process holding an old view.

Why the job still succeeds

lake_init's output carries catalog_hash, which is computed from the
COMPILED catalog rather than read back from the lake. So the task has no way to
notice that what it wrote did not land, and reports the hash it intended.

The mechanism, as far as it was traced

exec-task ends at main.rs:

let code = er_server::exec_task::run(&args[2..]);
…
std::process::exit(code);

process::exit runs no destructors — the file's own comment says so about the
telemetry flush ("The flush cannot be left to Drop"). So the pod's DuckDB
session is never dropped, and for a task whose entire work is DDL against a
freshly created catalog there is nothing else to force the commit. Parquet data
files are written before the catalog metadata is committed, which is exactly
the shape of what is left behind.

That mechanism is consistent with the evidence but was not confirmed by
instrumenting the commit path, so treat it as the leading hypothesis rather
than a diagnosis.

Why other pod tasks are unaffected

They are not doing the first DDL. pg_apply_corrections_dag.rs and
pg_run_all_pipeline.rs both run pods that write to a lake the TEST already
created and populated in-process, and their results are read back
successfully. pg_run_all_dag.rs's reconcile_schema finds everything present
and applies nothing. The untested path is precisely a pod performing the
initial schema creation — which is what provisioning does.

Impact, if the hypothesis holds

provision and dataset_provision are both in deploy.yml's DAG_KINDS, so
a tenant provisioned in dev or production gets an org marked active, a
dataset marked active, a tenant_schema_states row, and a lake with no
relations — then fails at the first stage of its first real run, for a reason
that points at the run rather than at provisioning.

Worth checking against a real cluster before assuming: this was observed with
FakePodApi and a local-mode lake, and a real pod's lifecycle and a Postgres
metadata catalog may differ.

Blocks

pg_provision.rs's port to the executor path, which is the last of #645's
eight test ports. The port otherwise works: the job settles succeeded and
both the org and the default dataset reach active (the dataset promotion was
itself missing and is fixed on that branch).

Acceptance

pg_provision.rs driven through the executor, asserting what it already
asserts against the legacy arm: raw_records and schema_migrations exist,
the ledger's catalog_hash matches lake_catalog_hash(), and the
tenant_schema_state row says migrated.

Activity

  1. added
    mvp
    on Nov 7, 2026
  2. athvin commented on Nov 7, 2026

    @athvin
    OwnerAuthor

    Better diagnosis — the process::exit hypothesis in the description is wrong. Correcting it rather than leaving it to mislead.

    reconcile_lake_env opens its own session and that session is dropped when the function returns, well before process::exit. So destructors are not the issue.

    What actually happens is two concurrent sessions on one catalog file, inside one process:

    • exec_task::run_inner opens a session for EVERY task — let session = open_order_session(&order)? (exec_task.rs:372) — which attaches the tenant's DuckLake.
    • LakeInit then opens a SECOND one: crate::schema::reconcile_lake_env(&ctx.order.lake_env) → open_lake_env → another attach of the same catalog. Its own comment says why it does this: "the lake this task initialises may not have existed when the pod's ctx session was opened, so the probe handle is not the one to use."

    The reconciler's session commits its DDL and is dropped. The pod's ctx session is still alive — it lives to the end of run_inner — holding the view it attached before the reconcile, and it is dropped last. That is consistent with every piece of the evidence: the reconciler's parquet data files survive, and the catalog metadata is the earlier, empty view that the longer-lived handle flushed over the top.

    It also explains why no other pod task shows this. They write to a lake whose tables already exist, so their ctx session's view and the committed state agree. lake_init is the only task that re-creates the catalog's contents underneath a handle that is already attached to it.

    Worth noting the framework already names this class: AssemblyError::UnorderedLakeWriters { a, b } — "two concurrent writers of one tenant lake" — but it guards BETWEEN tasks in a DAG, so it cannot see two writers inside one task.

    Fix direction, then, is to stop lake_init holding two handles: either it reuses the ctx session (and exec_task arranges for that session to attach a lake that may not exist yet), or the ctx session is not opened for this task at all. Both are design calls rather than one-liners, which is why this is not folded into #645.

  3. added 4 commits that reference this issue on Nov 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    mvp

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions