diff --git a/dgraph/cmd/counter/increment_test.go b/dgraph/cmd/counter/increment_test.go index 8099d1e0cb0..bf3c95c13b1 100644 --- a/dgraph/cmd/counter/increment_test.go +++ b/dgraph/cmd/counter/increment_test.go @@ -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) +} diff --git a/edgraph/server.go b/edgraph/server.go index 134c2ad1d89..67cd741c705 100644 --- a/edgraph/server.go +++ b/edgraph/server.go @@ -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 {