Implementing Transactions in kv Benchmark: Concurrency Issues


I am attempting to modify cockroach’s kv benchmark so that instead of executing simple reads and upserts, I execute ten reads or upserts within a single transaction. These are read-only and write-only transactions. When the workload 1) runs sequentially (–concurrency=1), or 2) contains exclusively read-only OR write-only transactions but not both, everything runs smoothly. However, when I 1) issue a mix of read-only and write-only transactions, and 2) run this mixed workload with --concurrency > 1, some read-only txn inevitably gives me an error:

  • “ERROR: current transaction is aborted, commands ignored until end of transaction block (SQLSTATE 25P02),” or
  • “Error: ERROR: Expected “ROLLBACK TO SAVEPOINT COCKROACH_RESTART”: current transaction is aborted, commands ignored until end of transaction block (SQLSTATE 25P02).”

I have attempted to use StmtHandle.QueryTx / StmtHandle.ExecTx and Tx.QueryEx / Tx.ExecEx within a transaction: mcp.Get().BeginEx(…), but I have not been successful. What’s wrong with my transactions?

I would greatly appreciate any thoughts on the matter.

Edit: To simplify my workload and reduce the number of possible causes, I replaced all generated keys with the value 1. The same behavior holds.

Here is when the workload runs successfully:

  1. –concurrency is low (less than 3), no matter what the mix of read-only/write-only txns
  2. The entire workload consists of read-only txns, regardless of concurrency
  3. The entire workload consists of write-only txns, regardless of concurrency
  4. Every txn consists of only 1 statement (instead of my default 10), regardless of the read/write percentages or the concurrency.
1 Like

The error you reported suggests that your benchmark code does not implement client-directed transaction retries properly. The problem is in the code, not your idea.

It would help if you could be more specific as to what specific code you’re using.