Skip to content

fix(dataset): include tombstone xact_ids in Dataset.version() via audit_log BTQL query - #2508

Open
Mohd Quamar Tyagi (Tyagiquamar) wants to merge 1 commit into
braintrustdata:mainfrom
Tyagiquamar:fix/snapshot-tombstone-version
Open

Mohd Quamar Tyagi (Tyagiquamar) wants to merge 1 commit into
braintrustdata:mainfrom
Tyagiquamar:fix/snapshot-tombstone-version

Conversation

@Tyagiquamar

Copy link
Copy Markdown
Contributor

Problem\n\nDataset.version() previously delegated to super.version() (ObjectFetcher), which issued BTQL without audit_log: true. Deleted records were invisible to the version query.\n\nCalling dataset.createSnapshot() after deletions used a stale version predating those deletions.\n\n## Fix\n\nOverride Dataset.version() to issue its own BTQL query with audit_log: true, scanning tombstones too. Iterates cursor pages up to MAX_BTQL_ITERATIONS and returns the highest _xact_id seen.\n\nPinned-version fast path preserved: explicit version at initDataset time returns immediately without network calls.\n\n## Changes\n\n- js/src/logger.ts: Override Dataset.version() with paginated BTQL audit-log query\n- js/src/logger.test.ts: 2 new unit tests covering audit-log query structure and createSnapshot() post-deletion version\n\n## Testing\n\nvitest run src/logger.test.ts: Tests 128 passed (128)

…it_log BTQL query

Previously, Dataset.version() delegated to super.version() (ObjectFetcher),
which queried BTQL without audit_log: true. This meant deleted records'
transaction IDs were invisible to the version query, so calling
dataset.createSnapshot() after deletions would use a stale version that
predated those deletions.

Override Dataset.version() to issue its own BTQL query with audit_log: true,
scanning all rows including tombstones, and returning the highest _xact_id
seen. Add tests covering:
- the audit-log BTQL query structure and max-version extraction
- createSnapshot() picking up the correct post-deletion version

This branch has not been deployed

No deployments
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