badalprasadsingh commented on code in PR #1603:
URL: https://github.com/apache/iceberg-go/pull/1603#discussion_r3685763574
##########
table/commit_retry_test.go:
##########
@@ -944,3 +944,32 @@ func TestDoCommit_RetryProgressesFreshMeta(t *testing.T) {
require.NotContains(t, wfs.files, cat.observedManifestLists[1],
"attempt-1 rebuild manifest list must be cleaned as orphan
after success")
}
+
+func TestTransactionCommit_MarksCommittedOnlyOnSuccess(t *testing.T) {
+ // first CommitTable : fails (non-ErrCommitFailed, so doCommit returns
immediately), the second succeeds
+ cat := &sequentialCatalog{
+ errs: []error{errors.New("catalog unavailable")},
+ }
+ tbl := newRetryTestTable(t, cat, nil)
+ cat.metadata = tbl.Metadata()
+
+ tx := tbl.NewTransaction()
+ require.NoError(t, tx.SetProperties(map[string]string{"key": "value"}))
+
+ _, err := tx.Commit(t.Context())
+ require.Error(t, err, "first commit must surface the catalog failure")
+ assert.False(t, tx.committed, "failed commit must leave committed ==
false")
+
+ // transaction stays usable: further changes and a retry are both
allowed
+ require.NoError(t, tx.SetProperties(map[string]string{"key2":
"value2"}),
+ "apply must be allowed after a failed commit")
+
+ committed, err := tx.Commit(t.Context())
Review Comment:
Done.
1. `TestTransactionCommit_RetriableAfterCleanConflict` now asserts
`cat.attempts` goes `1->2`, proving the retry reaches the catalog.
2. Added `TestTransactionCommit_RetriableAfterExhaustedInternalRetries`
(numRetries=2, all _ErrCommitFailed_) which asserts 3 internal attempts and
`committed == false` afterward.
--
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]