-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Better Tombstone handling in Iter #21
Conversation
Adds an option for iterating with tombstones but by default the Iter function skips tombstones to match the Get functionality. Also fixes the colons in namespace issue by removing the namespace prefix rather than splitting on the separator. Increases tests to ensure that Iter covers undead objects. Note, this will require a change to Trtl replication, it must use the WithTombstone option when it is iterating in initiator phase 1 and remote phase 2; otherwise deletes will not be replicated.
Codecov Report
@@ Coverage Diff @@
## main #21 +/- ##
==========================================
+ Coverage 55.77% 56.41% +0.63%
==========================================
Files 10 10
Lines 554 569 +15
==========================================
+ Hits 309 321 +12
- Misses 200 203 +3
Partials 45 45
Continue to review full report at Codecov.
|
} | ||
} | ||
|
||
func TestTombstonesMultipleNamespaces(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing the problem and adding the test cases, I have a lot more confidence that we are handling the tombstones correctly. I just had a few questions/comments below.
// Teardown after finishing the test | ||
defer os.RemoveAll(ldbPath) | ||
defer ldbEngine.Close() | ||
ldbEngine, _ := setupLevelDBEngine(t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for adding the cleanup func, it makes the teardown code a lot neater.
iter.Release() | ||
|
||
require.Equal(t, expected, actual, "database key count does not match") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea to add these utilities.
func TestTombstonesMultipleNamespaces(t *testing.T) { | ||
// Create a test database | ||
db, _ := setupHonuDB(t) | ||
namespaces := []string{"graveyard", "cemetery", "catacombs"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1 for the theming
// If we aren't including Tombstones, we need to check if the next version is a | ||
// tombstone before we know if we have a next value or not. | ||
if !i.options.Tombstones { | ||
if obj, err := i.Object(); err != nil || obj.Tombstone() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we ignoring the error here or does it get captured somewhere else?
Adds an option for iterating with tombstones but by default the
Iter
function skips tombstones to match theGet
functionality. Also fixes the colons in namespace issue by removing the namespace prefix rather than splitting on the separator. Increases tests to ensure thatIter
covers undead objects.Note, this will require a change to Trtl replication, it must use the
WithTombstone
option when it is iterating in initiator phase 1 and remote phase 2; otherwise deletes will not be replicated.