badalprasadsingh commented on code in PR #1603:
URL: https://github.com/apache/iceberg-go/pull/1603#discussion_r3685765518
##########
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())
+ require.NoError(t, err, "commit retry must be allowed after a transient
failure")
+ require.NotNil(t, committed)
+ assert.True(t, tx.committed, "committed must be set only after a
successful commit")
+
+ _, err = tx.Commit(t.Context())
+ require.Error(t, err)
+ assert.Contains(t, err.Error(), "already been committed")
Review Comment:
Done.
--
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]