-
Notifications
You must be signed in to change notification settings - Fork 4.1k
workload/schemachange: handle aborted transactions #56120
Description
The function OperationGenerator.randOp(tx *pgx.Tx) has a subtle problem when spurious errors occur. Consider the call stack here:
OperationGenerator.randOp(tx *pgx.Tx)createTable(tx)randTable(tx ...)tableExists(tx ...)
Say that tableExists(tx ...) produces an error which aborts transaction tx. randOp will see the error and try to call another operation, but every other op will fail because randOp will pass in a tx which is aborted. randOp will be stuck in a loop for a while until it randomly calls an operation does not use tx (ex. createSequence). Note, this will happen far less frequently after the competition of #56119
To fix this, it would be nice if all non-opType functions that receive a transaction as a parameter used nested transactions so that the original transaction does not get aborted. That way, when randOp sees an error and calls another op, the tx passed will be in its original state.