Skip to content

Scope availability posting to the node revision it was built for#2362

Merged
shangyian merged 1 commit into
DataJunction:mainfrom
shangyian:fix-stale-availability-version-guard
Jul 24, 2026
Merged

Scope availability posting to the node revision it was built for#2362
shangyian merged 1 commit into
DataJunction:mainfrom
shangyian:fix-stale-availability-version-guard

Conversation

@shangyian

@shangyian shangyian commented Jul 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

Calling POST /data/{node}/availability always attaches the reported availability to the node's current revision. When a node is redefined in a non-trivial way (e.g. a cube whose dimensions or metrics change), a materialization workflow that was running against the previous revision keeps posting availability and that post lands on the new current revision, which is wrong. The reported table was built from the old definition, so its physical columns don't match what the new revision generates, and queries against the current revision resolve to a stale, schema-mismatched table and fail at execution.

Availability is already revision-scoped in the db schema (nodeavailabilitystate.node_id to noderevision.id), so the bug is that the write path ignores which revision produced the data.

The fix is to attach availability to the revision it was actually produced for. The target version is resolved in order:

  1. an explicit node_version on the request, if the producer sends one
  2. otherwise derived from the materialized table name, which already encodes <node>_<version>_<hash> (e.g. dj__foo_bar_v1_0_ab12…)
  3. otherwise the current revision (unchanged prior behavior)

The availability then attaches to that revision. An older revision keeps its own availability (still valid for version-pinned queries) while the current revision is left untouched, so its queries fall back correctly instead of hitting a mismatched table.

Because the version is derived from the table name producers already send, this fixes the case for existing materialization workflows with no client-side change. node_version is an optional, forward-looking override.

Test Plan

  • PR has an associated issue: #
  • make check passes
  • make test shows 100% unit test coverage

Deployment Plan

@netlify

netlify Bot commented Jul 24, 2026

Copy link
Copy Markdown

Deploy Preview for thriving-cassata-78ae72 canceled.

Name Link
🔨 Latest commit 09fd41a
🔍 Latest deploy log https://app.netlify.com/projects/thriving-cassata-78ae72/deploys/6a63296662396b00088974d8

@shangyian shangyian changed the title Fix stale availability version guard Scope availability posting to the node revision it was built for Jul 24, 2026
@shangyian
shangyian force-pushed the fix-stale-availability-version-guard branch from 006c2cb to 81e06d5 Compare July 24, 2026 00:24
…lt for

POST /data/{node}/availability binds availability to node.current
unconditionally. A materialization workflow left running after a non-trivial
redefinition (e.g. a cube whose dimensions/metrics changed) keeps posting for a
superseded revision, stamping a stale, schema-mismatched table onto the new
revision so queries resolve to the wrong table.

Scope the availability to the revision it was produced for. The target version
is an explicit node_version if a producer sends one, else it is derived from the
materialized table name, which already encodes <node>_<version>_<hash> (factored
into a shared materialized_table_name / version_from_materialized_table pair so
build and parse can't drift). The availability attaches to that revision — an
older revision keeps its own availability (valid for pinned queries) while the
current revision is left untouched. An explicit unknown version is rejected; a
derived version matching no revision falls back to the current revision.

Because the version is derived from the table name producers already send, this
works with existing materialization workflows without a client change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@shangyian
shangyian force-pushed the fix-stale-availability-version-guard branch from 81e06d5 to 09fd41a Compare July 24, 2026 08:59
@shangyian
shangyian marked this pull request as ready for review July 24, 2026 09:32
@shangyian
shangyian merged commit 63838f3 into DataJunction:main Jul 24, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant