Code hacks

Andrei Matei edited this page Apr 18, 2016 · 3 revisions

Inject a retryable error in an UPDATE statement on a marked row

Add the following snippet above https://github.com/cockroachdb/cockroach/blob/ef7138bc3fd7261ac40f84762c87f45846f41fe4/cli/start.go#L171

+       // !!!
+       restarted := false
+       cliContext.TestingKnobs.StoreTestingKnobs.TestingCommandFilter =
+               func(args storageutils.FilterArgs) *roachpb.Error {
+                       switch req := args.Req.(type) {
+                       case *roachpb.PutRequest:
+                               if bytes.Contains(req.Value.RawBytes, []byte("marker")) && !restarted {
+                                       log.Infof("!!! injecting retry error")
+                                       restarted = true
+                                       return roachpb.NewErrorWithTxn(
+                                               roachpb.NewTransactionRetryError(), args.Hdr.Txn)
+                               }
+                       }
+                       return nil
+               }
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.