Skip to content

Add Transaction::getConflictingKeyRanges() helper for reportConflictingKeys #95

Description

@s2x

Description

TransactionOptions::setReportConflictingKeys() is implemented, but there is no way to actually read the reported keys other than knowing the special-key-space layout by hand. After a not_committed (1020) error, the conflicting ranges are published under:

\xff\xff/transaction/conflicting_keys/

where each key is <prefix><user key> and the value is 1 for the start of a conflicting range and 0 for its end. Java exposes this through Transaction.getRange(SpecialKeySpace...); Python and Go document the prefix.

What needs to be done

Add to Transaction.php:

/** @return list<array{begin: string, end: string}> */
public function getConflictingKeyRanges(): array
  • Requires setReportConflictingKeys() to have been set on the transaction, and must be called after the failing commit() and before reset()/onError().
  • Reads the special range, strips the prefix, and pairs 1/0 markers into begin/end ranges.
  • Throw a clear exception (not a raw range-read error) if the option was not enabled.

Consider also a lower-level getConflictingKeys(): array<KeyValue> returning the raw special-key rows.

Acceptance Criteria

  • getConflictingKeyRanges() returns the ranges that caused a 1020 conflict
  • Clear error when setReportConflictingKeys() was not enabled
  • Integration test that forces a write conflict between two transactions and asserts the reported range
  • docs/error-handling.md updated
  • composer lint and composer test clean

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions