Skip to content

workload/schemachange: handle aborted transactions #56120

@jayshrivastava

Description

@jayshrivastava

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-testingTesting tools and infrastructureC-enhancementSolution expected to add code/behavior + preserve backward-compat (pg compat issues are exception)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions