Skip to content

[Spark] Reject duplicate txn and domain metadata keys in AMT snapshot state - #8437

Merged
murali-db merged 1 commit into
delta-io:masterfrom
prakharjain09:amt-sidecar-non-content-metadata-task-14-dupcheck
Dec 5, 2026
Merged

murali-db merged 1 commit into
delta-io:masterfrom
prakharjain09:amt-sidecar-non-content-metadata-task-14-dupcheck

Conversation

@prakharjain09

Copy link
Copy Markdown
Collaborator

Which Delta project/connector is this regarding?

  • Spark
  • Standalone
  • Flink
  • Kernel
  • Other (fill in here)

Description

Snapshot reads of an AMT checkpoint with sidecars now fail with INTERNAL_ERROR when a txn appId or a domain is held more than once across inline entries and sidecars, since the winning entry would otherwise be arbitrary.

  • SnapshotState checks setTransactions and domainMetadata when they come from a reconstructed AMT checkpoint. Checksum answers are not checked, non-AMT tables and AMT checkpoints without sidecars are skipped, and each kind is checked at most once per snapshot.
  • The writer's duplicate key check moves unchanged to AMTNonContentSidecarReader.assertNoDuplicateKeys, plus a new assertNoDuplicateKeysInCheckpoint used by the snapshot.
  • checkpointSizeInBytes in the AMT write usage log now counts the non-content sidecars, and two fields are renamed: numInlineSystemDomainMetadata to numAlwaysInlineDomainMetadata and numDomainMetadataSidecarWithoutCountTag to numDomainMetadataSidecarsWithoutCountTag.

How was this patch tested?

New tests in AMTNonContentSidecarSuite on hand-built AMT checkpoints cover a key duplicated across inline entries and a sidecar, a key duplicated across two sidecars, checkpoints without sidecars and non-AMT tables (not checked), lookups answered by the checksum (not checked), and a state reconstructed by another accessor. The write metrics tests check the renamed fields and that the logged checkpointSizeInBytes includes the sidecars. The existing incremental writer duplicate key tests still pass on the shared helper.

Does this PR introduce any user-facing changes?

No

… state

Snapshot reads of an AMT checkpoint with sidecars now fail with INTERNAL_ERROR when a txn appId or a domain is held more than once across inline entries and sidecars, since the winning entry would otherwise be arbitrary.

- The writer's duplicate key check moves unchanged to AMTNonContentSidecarReader.assertNoDuplicateKeys, and a new assertNoDuplicateKeysInCheckpoint is used by the snapshot.
- Checksum answers are not checked, non-AMT tables and AMT checkpoints without sidecars are skipped, and each kind is checked at most once per snapshot.
- checkpointSizeInBytes in the AMT write usage log now counts the non-content sidecars, and two fields are renamed: numInlineSystemDomainMetadata to numAlwaysInlineDomainMetadata and numDomainMetadataSidecarWithoutCountTag to numDomainMetadataSidecarsWithoutCountTag.
@prakharjain09
prakharjain09 force-pushed the amt-sidecar-non-content-metadata-task-14-dupcheck branch from 93b6660 to 07b3112 Compare December 5, 2026 02:33
@murali-db
murali-db merged commit 1a02730 into delta-io:master Dec 5, 2026
36 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.

2 participants