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

Fix a StartTs Mismatch bug which happens when running multiple best e… #3246

Merged
merged 1 commit into from
Apr 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions dgraph/cmd/counter/increment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,17 @@ func TestBestEffortOnly(t *testing.T) {
}
t.Logf("Best-Effort only reads with multiple preds OK.")
}

func TestBestEffortTs(t *testing.T) {
dg := setup(t)
pred := "counter.val"
incrementInLoop(t, dg, 1)
readBestEffort(t, dg, pred, 1)
txn := dg.NewReadOnlyTxn().BestEffort()
_, err := queryCounter(txn, pred)
require.NoError(t, err)

incrementInLoop(t, dg, 1) // Increment the MaxAssigned ts at Alpha.
_, err = queryCounter(txn, pred) // The timestamp here shouldn't change.
require.NoError(t, err)
}
4 changes: 3 additions & 1 deletion edgraph/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,9 @@ func (s *Server) Query(ctx context.Context, req *api.Request) (resp *api.Respons
if !req.ReadOnly {
return resp, x.Errorf("A best effort query must be read-only.")
}
req.StartTs = posting.Oracle().MaxAssigned()
if req.StartTs == 0 {
req.StartTs = posting.Oracle().MaxAssigned()
}
queryRequest.Cache = worker.NoTxnCache
}
if req.StartTs == 0 {
Expand Down