badalprasadsingh commented on code in PR #1637:
URL: https://github.com/apache/iceberg-go/pull/1637#discussion_r3756781170
##########
table/metadata.go:
##########
@@ -390,6 +390,45 @@ func (b *MetadataBuilder) currentSnapshot() *Snapshot {
return s
}
+// currentSnapshotForRef resolves the parent for createSnapshotProducer and
mergeOverwrite.
+// An unknown branch falls back to currentSnapshot() so a new
+// branch forks from main — the opposite of currentSnapshotIDForRef,
+// which must return nil there so AssertRefSnapshotID can prove the branch is
absent;
+// never derive one from the other. A present-but-dangling ref also yields nil.
+func (b *MetadataBuilder) currentSnapshotForRef(ref string) *Snapshot {
+ if ref == "" || ref == MainBranch {
+ return b.currentSnapshot()
+ }
+
+ r, ok := b.refs[ref]
Review Comment:
Fixed at construction itself in `NewTransactionOnBranchWithError` and
defended again after every refresh, and defended again after every refresh: the
commit requirement is `assertBranchRefSnapshotID` `(requireBranch)`,
re-validated on retry via `validateBranchRequirement` before the second
`CommitTable`.
Covers both the existing-tag and the absent-name→tag race. Tests:
`TestNewTransactionOnBranchRejectsTags`,
`TestTransactionCommitRejectsSameIDTagRace`,
`TestBranchCommitRejectsNameThatBecomesATagOnRetry`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]