Repository navigation
Refuse a transaction left open across within() on PostgreSQL, add transaction() (0.3.0) - #10
Conversation
…nsaction() PostgreSQL has no non-transactional SET: a restore that ran inside a transaction the within() callback left open was undone by the caller's rollback, and the session kept the budget timeout. within() now throws LogicException in that case; transaction() owns the transaction and uses SET LOCAL, which ends with it on commit and rollback alike. Live tests pin the refusal, transaction() on all three servers, and that MySQL/MariaDB session variables survive a later rollback. Fixes #6
|
Sorry @rasuvaeff, you've used your own review budget of 250,000 diff characters for the last 7 days. You can request another review in 5 days and 15 hours by commenting |
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars.
|
Reviewer's GuideAPIDocument and expose the PostgreSQL
Add the public
ImplementationImplement PostgreSQL timeout scoping and reject callbacks that return with a transaction open when
DocumentationUpdate the project guidance, changelog, English and Russian READMEs, and skill documentation to explain the new API and transaction-safety rules.
TestsAdd unit and live-server coverage for refusing PostgreSQL callbacks that leave transactions open, transaction ownership and cleanup, and MySQL/MariaDB restoration behavior.
Extend the PDO test double to model transaction lifecycle operations and rollback failures.
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
Summary
PostgreSQL has no non-transactional
SET(SET,set_config(..., false)andRESETare all undone by a rollback of the transaction they ran in). Whenwithin()was entered outside a transaction and the callback left one open, the restore ran inside it and the caller's later rollback undid it: the session kept the budget timeout.StatementTimeout::transaction($context, $callback): opens a transaction through PDO, runs the callback under the budget, commits, or rolls back and rethrows. On PostgreSQL the limit isSET LOCAL, which ends with the transaction on commit and rollback alike (also after a timeout aborted it), so nothing can be left on the session. A transaction already open is refused withLogicException.within()/run()entered outside a transaction throwsLogicExceptionwhen the callback returns with a transaction open, instead of silently leaking. A callback that throws keeps its own error (documented: the restore may still be lost there).Tests
postgresqlRefusesATransactionLeftOpenAcrossWithinandtransactionLeavesNoLimitBehindwere red before the fix, green after;mysqlAndMariaDbKeepTheRestoreThroughALaterRollbackgreen on both.transaction()commit/rollback/terminated context/already-open.--with-uncovered,zend.assertions=-1): MSI 92.8% (minMsi 88).Docs: README.md + README.ru.md, llms.txt, agent skill, AGENTS.md, CHANGELOG
## 0.3.0 — 2026-11-21.Fixes #6
Summary by Sourcery
Add owned transaction execution and prevent PostgreSQL timeout settings from leaking when callbacks leave transactions open.
New Features:
StatementTimeout::transaction()to run budgeted callbacks in an owned transaction with automatic commit or rollback.Bug Fixes:
within()callbacks leave transactions open.Enhancements:
within()andrun()callbacks that return with a transaction opened outside the callback's scope.Documentation:
Tests: