Skip to content
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

iterator: allow NextPrefix from exhausted position #3603

Closed

Conversation

RaduBerinde
Copy link
Member

We don't need to support NextPrefix from an exhausted position, but we
want to implement predictable semantics for the metamorphic tests.

The iterator could be exhausted in either direction; in both cases,
returning whatever Next returns is correct.

Fixes #3597

Also see #3593 (review)

We don't need to support NextPrefix from an exhausted position, but we
want to implement predictable semantics for the metamorphic tests.

The iterator could be exhausted in either direction; in both cases,
returning whatever `Next` returns is correct.

Fixes cockroachdb#3597
@RaduBerinde RaduBerinde requested a review from jbowens May 9, 2024 20:56
@RaduBerinde RaduBerinde requested a review from a team as a code owner May 9, 2024 20:56
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@RaduBerinde
Copy link
Member Author

Thinking about this some more - maybe the problem was that even with the previous code, most of the time NextPrefix returns a key, after a SeekLT returned nil. That would suggest that we don't (always) set the iterValidityState to IterExhausted when SeekGT returns nil, should we?

@RaduBerinde
Copy link
Member Author

This diff also seems to fix the failure:

--- a/iterator.go
+++ b/iterator.go
@@ -1589,8 +1589,8 @@ func (i *Iterator) SeekLTWithLimit(key []byte, limit []byte) IterValidityState {
        if seekInternalIter {
                i.iterKV = i.iter.SeekLT(key, base.SeekLTFlagsNone)
                i.stats.ReverseSeekCount[InternalIterCall]++
-               if err := i.iter.Error(); err != nil {
-                       i.err = err
+               if i.iterKV != nil {
+                       i.err = errors.CombineErrors(i.err, i.iter.Error())
                        i.iterValidityState = IterExhausted
                        return i.iterValidityState
                }

@RaduBerinde
Copy link
Member Author

Closing in favor of #3604 (we posted at the same time).

@RaduBerinde RaduBerinde closed this May 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

github.com/cockroachdb/pebble/internal/metamorphic: TestMetaTwoInstance failed
2 participants