Repository navigation
fix(deletes): batch expired transaction log cleanup - #13563
Merged
Merged
Conversation
Contributor
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
…tive limit array_chunk() throws a ValueError when the length is below 1, so a database configured with a non-positive maxQueryValues would take the cleanup worker down instead of batching. utopia-php/database wraps every one of its own array_chunk() calls on that value in max(1, ...); match it here. Not reachable today - Factory::configureOptions only applies the setter when the value is above zero, and the library default is 5000 - so this is a guard against future configuration rather than a fix for a live failure.
The test fails in CI. It was the only failure in Tests / E2E / General on
run 35599864714:
1) Tests\E2E\General\DeletesTest::testDeleteExpiredTransactions
tests/e2e/General/DeletesTest.php:134
Tests: 32, Assertions: 182, Failures: 1, Skipped: 10
Line 134 is the catch-all fail(), so the coroutine threw inside the CI
container rather than tripping an assertion about batching. The test passed
locally only, against a hand-built worktree runner.
It was also the only test in the suite to fork an OS process: proc_open of
app/worker.php under setsid, terminated by process-group SIGKILL, seeding
about 10,000 documents to clear the 5,000 query-value limit. Nothing else in
tests/e2e does that, and the cost is not worth carrying for a one-line chunk.
Removed rather than repaired so the fix is not blocked on it. Coverage should
come back as a worker e2e that drives the queue in-process, the way
tests/e2e/General/WorkerConcurrencyTest.php already does.
loks0n
approved these changes
Sep 21, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Maintenance deletes expired transactions and then removes their logs by transaction sequence. With more than 5,000 expired transactions, the single log-deletion query exceeds the database's value limit and fails after the transactions have been deleted.
Split the collected sequences into batches sized by the database's configured maximum query values, so every deleted transaction's logs can be cleaned up.
Test Plan
app/worker.php deletesprocess. No worker or database stubs.transactionInternalIdquery-value-limit exception and retained logs. With batching restored, the real PostgreSQL integration passes.docker exec appwrite-transactions-test /usr/local/bin/test tests/e2e/General/DeletesTest.php— 1 test passed using an isolated worktree runner against local services.git diff --checkpassed.This prevents new over-limit failures. Logs orphaned by earlier failed runs require separate cleanup because their transaction documents have already been deleted.
Related PRs and Issues
Checklist