Skip to content

ci(e2e): surface native worker crashes and isolate migration test cleanup - #14120

Merged
abnegate merged 9 commits into
mainfrom
qlt-fix/migrations-crash-guard
Oct 6, 2026
Merged

abnegate merged 9 commits into
mainfrom
qlt-fix/migrations-crash-guard

Conversation

@abnegate

@abnegate abnegate commented Oct 5, 2026

Copy link
Copy Markdown
Member

Why

A native crash in a long-running appwrite process (for example zend_mm_heap corrupted in the combined worker) never failed a CI job by itself. Swoole respawns the child, so the only symptom is a test timing out on a migration left in processing, and the cause sits in container logs that are only dumped on failure.

On top of that, the overwrite/skip migration tests deleted their databases and reset the shared table cache only as their last statements. One stuck migration therefore left a database behind that the following tests reused, turning one failure into nine.

What

  • CI: every E2E job (General, per-service, grouped) gets a Check for native crashes step after the tests. It greps the logs of the services built from the appwrite image for zend_mm_heap, Segmentation fault, core dumped, signal 6/7/11 and exit code 139, prints only the matching lines and fails the job. Third-party containers (executor, browser, assistant, databases) are not scanned.
  • Migrations e2e: the 13 overwrite/skip tests register the database they create. A tearDown deletes it from the source and destination projects (204 or 404) and resets the shared database/table caches. Tests that register nothing keep sharing the cache as before.

Test plan

  • CI green; the new step passes on every E2E job (no crash lines on main).

🤖 Generated with Claude Code

abnegate and others added 2 commits October 5, 2026 21:29
A native crash in a long-running appwrite process (heap corruption or a
segfault in the combined worker) never failed a job by itself. Swoole
respawned the child and the only symptom was a test timing out on a
migration stuck in processing, with the cause buried in a container log
that is only dumped on failure (inv-mig-1). Grep the logs of the services
built from the appwrite image after every E2E run and fail with the
matching lines, so these crashes surface even when the tests happen to
pass. Third-party images (executor, browser, assistant, databases) are
left out so their logs cannot fail the job.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The overwrite and skip migration tests deleted their source and
destination databases and reset the shared table cache only as their
last statements. When one failed (a migration left in processing by a
crashed worker), the next tests reused the cached database and table and
failed on leftovers, turning one failure into nine. Each test now
registers its database and tearDown deletes it from both projects and
resets the shared caches, whether the test passed or not. Tests that do
not register a database keep sharing the cache as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@ghost

ghost commented Oct 5, 2026 •

Copy link
Copy Markdown

🟢 Tier S · Ready to merge

The latest changes address both open findings, and no new defects were found in the incremental changes.

Adds native-crash scanning after all E2E job types, restricted to services using the Appwrite image, and logs abnormal Swoole worker exits. Migration fixtures now use fresh databases registered during setup and cleaned up from both projects in teardown. Restart tests verify abnormal-exit diagnostics and that clean retirement and shutdown stay quiet.

Latest changes: The latest commits explicitly report log-retrieval failures, add worker diagnostic assertions, and remove migration fixture caches while moving cleanup registration into database setup.

Verdict New comments Fixed Still open
✅ Approved 0 2 0
📂 Walkthrough · 6
File Change
.github/scripts/check-native-crashes.sh Scan Appwrite service logs for native crashes and fail explicitly on retrieval or scanning errors.
.github/workflows/ci.yml Run the shared crash scanner after each E2E job's tests.
packages/queue/src/Adapter/Swoole.php Validate reaped worker status and log abnormal exits outside shutdown.
packages/queue/phpstan-baseline.neon Remove offset-access suppressions superseded by process-status validation.
packages/queue/tests/E2E/SwooleRestartTest.php Assert diagnostic logging for killed and fatal workers and silence for retirement and shutdown.
tests/e2e/Services/Migrations/MigrationsBase.php Create fresh migration fixtures, register databases during setup, and collect teardown deletion failures across both projects.
✅ Fixed since the last review · 2
  • Register the database before table setup can fail · tests/e2e/Services/Migrations/MigrationsBase.php:999
  • Cover abnormal-exit diagnostics in the existing restart tests · packages/queue/src/Adapter/Swoole.php:423

Reviewed the commits since 1c9efbe · Details · Comment @hansi-codes review to re-run, or mention @hansi-codes with a question.

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Tier A · Looks good to merge. Summary

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

✨ Benchmark results

Comparing main (before) → qlt-fix/migrations-crash-guard (after).

Metric Before After Change
🚀 Requests/sec 191.75 162.97 🔴 -15%
⏱️ Latency P50 89.38 ms 106.65 ms 🔴 +19.3%
⏱️ Latency P95 211.67 ms 249.87 ms 🔴 +18%
Per-scenario breakdown & investigation details

Metrics below reflect the current branch (after). Δ P95 compares against the base.

Scenario P50 (ms) P95 (ms) Requests RPS Δ P95 (ms)
API total 106.65 249.87 10,260 162.97 +38.2
Account 194.73 393.61 540 9.13 +58.67
TablesDB 102.81 196.32 5,580 90.44 +26.63
Storage 98.23 214.06 2,700 45.42 +30.4
Functions 151.48 305.93 1,440 24.73 +45.21

Top API waits (after)

API request Max wait (ms)
account.name.update 582.58
functions.variables.create 569.24
functions.variables.update 495.03
tablesdb.rows.increment 440.51
tablesdb.rows.update 428.32

abnegate and others added 4 commits October 5, 2026 22:57
The supervisor reaped a dead worker and respawned it without a word, so
a worker killed by a signal or exiting non-zero left no trace in the
container log. One of the three native crashes of the combined appwrite
worker on #11649 printed nothing at all, and the only symptom was a
migration stuck in processing. Log the worker id, signal and exit code
when a worker dies while the supervisor is not stopping, so the CI crash
scan and operators can see it. Exits during shutdown, including the
SIGKILL after the drain deadline, stay quiet because they are expected.

The wait result is narrowed before use since the package's Swoole stubs
leave it untyped, which also retires two baseline entries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The crash scan exited 0 when no service matched the appwrite image, and
masked failures of docker compose config and logs, so a renamed image or
a broken compose call would silently disable it. Move the step into one
script shared by the three E2E jobs that runs under errexit and
pipefail, prints the services it scans, errors when none match, and
treats a grep failure as an error rather than a clean result. The
pattern gains word boundaries so signal=110 or exit code 1390 cannot
match, and it now matches the supervisor's abnormal worker exit line so
crashes that print nothing else are caught.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
tearDown asserted on each delete as it went, so the first unexpected
status aborted the loop before the tracked ids and the shared database
and table caches were reset, and the next test reused a poisoned cache.
It now snapshots and clears that state first, deletes in both projects
collecting every failure, asserts once at the end, and always hands
over to the parent tearDown so the client is released.

The database, table and row migration tests still deleted their
databases as their last statements and so leaked them, and the cache
entries pointing at them, whenever an earlier assertion failed. They
and the two source key tests now register their databases with
trackDatabase and leave the cleanup to tearDown, which reuses the
existing per-database delete helper.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The abnormal worker exit line is also logged for a worker that exits
with a non-zero code and no signal, such as a PHP fatal error (code
255). Those are not native crashes, and matching them would fail E2E
on main for ordinary worker errors. Match the line only when a signal
killed the worker; the log line itself still records both cases for
diagnosis.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Tier A · Looks good to merge. Summary

Comment thread packages/queue/src/Adapter/Swoole.php Resolved
abnegate and others added 3 commits October 5, 2026 23:06
The supervisor now logs a worker that dies outside shutdown, which is
what lets the E2E crash scan see a native crash that prints nothing
else. Pin that in the restart harness, which already captures the
supervisor's stderr: a SIGKILLed worker and a worker killed by a fatal
error must each add exactly one line with the worker id, signal and
exit code, a worker that retires cleanly must add none, and a drain on
SIGTERM or SIGINT must log no abnormal exit at all. The kill case fails
against the supervisor before the logging change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Tests registered the database from setupMigrationTable only after it
returned, so when table setup failed, for example on the column wait
while the databases worker was down, the database it had just created
and cached was never deleted and later unscoped migrations picked it
up. setupMigrationDatabase now registers the database the moment it
exists, and the per-test registrations it makes redundant are gone.

With every database these helpers create deleted in tearDown, the
static database and table caches could never outlive a test, so they
are removed along with their resets: each call now creates fresh
fixtures, and no test can see a database left by an earlier one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
When docker compose logs failed, errexit ended the step with only a
bare exit status, and the reason was lost in the captured output. Print
what docker returned and an error annotation, so a failed scan says why
it failed instead of looking like an unexplained step failure.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

@ghost ghost left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@abnegate
abnegate merged commit b396717 into main Oct 6, 2026
95 checks passed
abnegate added a commit that referenced this pull request Oct 6, 2026
Brings in #14130 (route physical collection reads, schema checks, cache
purges and transaction commits through the databases handle), #14120's
merge commit, #14137 (VCS tag globs) and #14139 (project SMTP failures
finish the mail job).

Conflicts were resolved by keeping the database 8.0 forms the train
already uses (ColumnType cases, Capability checks via supports(),
Attribute::fromArray for checkAttribute, supportsSpatial/
supportsRelationships helpers) while taking main's databases-handle
routing, so dedicated databases get their own adapter's capabilities
and schema. The spatial capability check moves after the database
lookup because it now needs that database's adapter.

Documents Create/Update keep the train's RelationshipValues, which
already reads stored related documents through the databases handle;
main's inline permission walk is superseded by it.

Transactions increment/decrement now build their Counter from the
databases handle, since main renamed the handler parameter and the
counted collection's schema lives on that handle.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant