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

Fixes for replicated query iterator #2214

Merged
merged 2 commits into from
Jan 29, 2025

Conversation

josephschorr
Copy link
Member

No description provided.

… on QueryRelationships and ReverseQueryRelationships iterators in the strict read mode proxy
@josephschorr josephschorr requested a review from a team as a code owner January 28, 2025 18:33
@github-actions github-actions bot added area/datastore Affects the storage system area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools) labels Jan 28, 2025
tstirrat15
tstirrat15 previously approved these changes Jan 28, 2025
Copy link
Contributor

@tstirrat15 tstirrat15 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, had question

Comment on lines +140 to +163
replicaLoop:
for result, err := range it {
if err != nil {
// If the RevisionUnavailableError is returned on the first result, we should fallback
// to the primary.
if errors.As(err, &common.RevisionUnavailableError{}) {
if !isFirstResult {
yield(tuple.Relationship{}, spiceerrors.MustBugf("RevisionUnavailableError should only be returned on the first result"))
return
}
requiresFallback = true
break replicaLoop
}

if !yield(tuple.Relationship{}, err) {
return
}
}

isFirstResult = false
if !yield(result, nil) {
return
}
}
Copy link
Contributor

@tstirrat15 tstirrat15 Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why was this additional layer necessary? Was this an observed failure mode?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes; we need to catch it here as well

Copy link
Contributor

@vroldanbet vroldanbet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, added some suggestions

Comment on lines +329 to +133
if errors.As(err, &common.RevisionUnavailableError{}) {
log.Trace().Str("revision", rr.rev.String()).Msg("replica does not contain the requested revision, using primary")
return handler(rr.primary.SnapshotReader(rr.rev))(ctx, filter, options...)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needed here, as this error won't be bubbled up at this point because the iterator hasn't been returned yet: all we've done is return an iterator function.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It could be if the underlying implementation changes; since that is not guaranteed, we still need to check for it here to future proof this

replicated, err := NewStrictReplicatedDatastore(primary, replica)
require.NoError(t, err)

reader := replicated.SnapshotReader(revisionparsing.MustParseRevisionForTest("3"))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also test that a snapshot reader of ONLY the replica does return the error. Otherwise, this test could be silently failing (it does not - I traced it).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I validated this test before I fixed the problem

internal/datastore/proxy/strictreplicated.go Show resolved Hide resolved
vroldanbet
vroldanbet previously approved these changes Jan 29, 2025
Copy link
Contributor

@vroldanbet vroldanbet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for addressing the feedback, LGTM

@josephschorr josephschorr added this pull request to the merge queue Jan 29, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jan 29, 2025
@vroldanbet vroldanbet added this pull request to the merge queue Jan 29, 2025
Merged via the queue into authzed:main with commit 7466dea Jan 29, 2025
39 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Jan 29, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area/datastore Affects the storage system area/tooling Affects the dev or user toolchain (e.g. tests, ci, build tools)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants