badalprasadsingh commented on code in PR #2601:
URL: https://github.com/apache/iceberg-go/pull/2601#discussion_r4596384928
##########
table/expire_replay_test.go:
##########
@@ -167,6 +201,65 @@ func TestExpireReplayPlansWhereExpiryWasStaged(t
*testing.T) {
})
}
+func TestExpireReplayRejectsRefsOnlyHistoryAfterRetry(t *testing.T) {
+ synctest.Test(t, func(t *testing.T) {
+ fs, inner, tbl := newExpireReplayTable(t, nil)
+ var ids [4]int64
+ for i, name := range []string{"s1", "s2", "s3", "s4"} {
+ tbl, ids[i] = appendOnBranch(t, tbl, MainBranch, name)
+ }
+ peerUpdate(t, inner, NewSetSnapshotRefUpdate("expired-tag",
ids[0], TagRef, time.Hour.Milliseconds(), 0, 0))
+ time.Sleep(2 * time.Hour)
+
+ cat := &refsOnlyReloadCatalog{reqValidatingCatalog: inner}
+ tx := newOCCTable(t, inner.metadata, fs, cat).NewTransaction()
+ require.NoError(t, tx.ExpireSnapshots(
+ WithOlderThan(0), WithRetainLast(5),
WithPostCommit(false),
+ ))
+ staged, err := tx.StagedTable()
+ require.NoError(t, err)
+ assert.Nil(t, staged.Metadata().SnapshotByName("expired-tag"))
+ assert.Equal(t, sortedIDs(ids[:]...),
survivors(staged.Metadata()))
+
+ peer := peerAppend(t, fs, inner, MainBranch, "s5")
+ partial := refsOnlySnapshotMetadata(t, inner.metadata, ids[0],
peer)
+ assert.Equal(t, sortedIDs(ids[0], peer), survivors(partial))
+ cat.partial = partial
+ attemptsBefore := inner.attempts.Load()
+
+ _, err = tx.Commit(t.Context())
+ require.ErrorIs(t, err, ErrTransactionUnusable)
+ require.ErrorIs(t, err,
errSnapshotHistoryIncompleteForExpiration)
+ assert.Equal(t, 1, cat.loads)
+ assert.Equal(t, attemptsBefore+1, inner.attempts.Load(), "retry
must stop before resubmitting expiration")
+ assert.Equal(t, sortedIDs(ids[0], ids[1], ids[2], ids[3],
peer), survivors(inner.metadata))
+ assert.NotNil(t, inner.metadata.SnapshotByID(ids[0]), "retained
history must remain in catalog metadata")
+ assert.NotNil(t, inner.metadata.SnapshotByName("expired-tag"),
"failed expiry must not remove the tag")
+ assert.Equal(t, peer, refHead(t, inner.metadata, MainBranch))
+ })
+}
+
+func TestRefsOnlyReloadDoesNotBlockAppendReplay(t *testing.T) {
+ synctest.Test(t, func(t *testing.T) {
+ fs, inner, tbl := newExpireReplayTable(t, nil)
+ tbl, first := appendOnBranch(t, tbl, MainBranch, "first")
+ tbl, _ = appendOnBranch(t, tbl, MainBranch, "head")
Review Comment:
drop the assignment: this is where the lint is failing as tbl is never read
after this line
--
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]