-
Notifications
You must be signed in to change notification settings - Fork 4.1k
initializing client.Batch outside of txn retryable is dangerous #3067
Copy link
Copy link
Closed
Labels
E-easyEasy issue to tackle, requires little or no CockroachDB experienceEasy issue to tackle, requires little or no CockroachDB experiencehelp wantedHelp is requested / needed by the one who filed the issue to fix it.Help is requested / needed by the one who filed the issue to fix it.
Description
This here will go horribly wrong (endless retry loop) unless the retryable succeeds on its first attempt.
b := &client.Batch{}
b.Put(key, "test")
s.db.Txn(func(txn *client.Txn) error {
return txn.CommitInBatch(b)
})Instead, the batch needs to be initialized inside of the retryable (or the error stored within it cleared manually). I ran into this in WIP and took me a bit to track it down. We should reset errors in an appropriate location so that the above isn't a death trap.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
E-easyEasy issue to tackle, requires little or no CockroachDB experienceEasy issue to tackle, requires little or no CockroachDB experiencehelp wantedHelp is requested / needed by the one who filed the issue to fix it.Help is requested / needed by the one who filed the issue to fix it.