Repository navigation
fix: fail migrations whose source or destination stops answering - #14330
Conversation
The migration worker's HTTP calls had no timeouts. A source or destination that accepted the connection and never replied held the worker in curl_exec forever, so the migration stayed processing with nothing logged and the next jobs went to other workers. utopia-php/migration now times out stalled requests, so report and transfer calls throw and the worker records the migration as failed with the error. The worker's own scope probe client gets the same limits.
|
Review complete. 🟡 2 medium 💬 Inline comments (1)
📍 Findings outside the diff (1) — 🟡 1 medium — defects on lines GitHub can't attach comments to🟡 Medium — Probe timeouts misreported as source unauthorized · Migrations.php:362–364 · // src/Appwrite/Platform/Workers/Migrations.php
362 } catch (AppwriteException $error) {
363 throw new Exception(Exception::MIGRATION_SOURCE_UNAUTHORIZED, previous: $error);
364 }
🧹 Nitpicks (1) — 🟢 1 low
The change adds timeout configuration (
Reviewed commit: d7164f0 |
🟢 Tier S · Ready to mergeThe PR bounds migration HTTP connection and response waits, updates the migration dependency to the release that provides request timeouts, and adds an E2E test for a source that accepts a connection but never responds. It also applies the same timeout limits to the worker's scope probe and logs chained exception causes when a migration fails. Latest changes: The newest commit logs each previous exception's message, location, and trace when a migration fails.
📂 Walkthrough · 4
🔇 Filtered out · 1Findings Hansi considered but did not post.
Reviewed the commits since |
There was a problem hiding this comment.
This PR wires connect and total request timeouts into the Appwrite migration source probe client and adds an E2E test with an unresponsive TCP listener, plus a dev-branch pin for utopia-php/migration.
Key findings
- 🟡 Probe timeouts misreported as source unauthorized — Migrations.php:362
- 🟡 E2E test never exercises the probe timeout client — MigrationsBase.php:350
Security rulesNo new WARNING or ERROR findings from security rules. 32 existing findings tracked in
|
✨ Benchmark resultsComparing
Per-scenario breakdown & investigation detailsMetrics below reflect the current branch (after). Δ P95 compares against the base.
Top API waits (after)
|
With timeouts on the scope probe, a request that never gets a response surfaces as an AppwriteException with status 0, and authenticateSource reported it as an unauthorized key. That sends the user to check their key instead of reachability. Only a response status says anything about the key.
|
@greptileai review |
Workers are covered by E2E, not unit tests. The probe always calls the local API, so its no-answer path cannot be staged from E2E; the timeouts it relies on are covered in utopia-php/migration.
Sources wrap the error that stopped a migration, so the worker logged only the wrapper and its trace ended at report(). Logging each previous exception shows the request that actually failed, such as the SDK call that timed out.
Migration E2E tests intermittently time out in CI with the migration stuck in
processing. The worker picks the job up and setsprocessing, then logs nothing (no error, no completion), while later migrations finish on other workers.Cause
None of the migration worker's HTTP calls had a timeout. When a source or destination accepts the connection and never answers, the worker coroutine blocks in
curl_execforever. Thecatch/finallythat marks the migrationfailednever runs.Captured by dumping the stuck handler's stack while the regression test below runs without the fix:
Fix
Target::callabandons a response that sends no bytes for 30s, and the Appwrite SDK clients cap each request at 30s. A stall now throws, and the worker recordsfailedwith the error (Operation timed out after 30000 milliseconds with 0 bytes received).ClientinauthenticateSource()gets the same limits.Requires utopia-php/migration
^2.0.9, the release with the change from utopia-php/migration#232.Tests
testAppwriteMigrationFailsWhenSourceNeverAnswersopens a listening socket in the test process that never accepts. Connections complete from the backlog and nothing ever replies. It then runs an Appwrite migration against it and expectsfailedwith errors.Failed asserting ... 'finished'/+'processing'after 64s; worker blocked incurl_execfailed,stage: finished, error recordedThe Migrations suite was also run repeatedly the way CI runs it (
paratest --processes 1 --functional), plus 6-process concurrent runs. The results are in the comment below.Closes #14331