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

perf(txn): de-duplicate the context keys and predicates #7478

Merged
merged 4 commits into from
Mar 4, 2021
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
7 changes: 1 addition & 6 deletions dgraph/cmd/zero/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,12 +367,7 @@ func (s *Server) commit(ctx context.Context, src *api.TxnContext) error {

checkPreds := func() error {
// Check if any of these tablets is being moved. If so, abort the transaction.
preds := make(map[string]struct{})

for _, k := range src.Preds {
preds[k] = struct{}{}
}
for pkey := range preds {
for _, pkey := range src.Preds {
splits := strings.Split(pkey, "-")
if len(splits) < 2 {
return errors.Errorf("Unable to find group id in %s", pkey)
Expand Down
5 changes: 5 additions & 0 deletions worker/mutation.go
Original file line number Diff line number Diff line change
Expand Up @@ -800,6 +800,11 @@ func CommitOverNetwork(ctx context.Context, tc *api.TxnContext) (uint64, error)
if pl == nil {
return 0, conn.ErrNoConnection
}

// Do de-duplication before sending the request to zero.
tc.Keys = x.Unique(tc.Keys)
tc.Preds = x.Unique(tc.Preds)

zc := pb.NewZeroClient(pl.Get())
tctx, err := zc.CommitOrAbort(ctx, tc)

Expand Down