Fix parallel storage chunk upload state#12209
Conversation
Greptile SummaryThis PR introduces Redis-backed distributed locks to serialize chunk-upload state reads and finalizations across concurrent requests for storage files, function deployments, and site deployments. Chunk writes themselves remain outside the lock, preserving parallel throughput. End-to-end tests using Swoole coroutines verify the parallel-upload path and include retry logic for 429 responses. Confidence Score: 4/5Safe to merge with minor follow-up; the lock design is sound but the checkLock TTL configuration in Functions/Sites is slightly inconsistent. All findings are P2. The core double-finalization race is correctly prevented by the lock + in-lock DB re-read. LockContention now correctly returns 429. Previous P1 concerns from the thread appear addressed in the current code. The only new finding is that checkLock in Functions/Sites uses ttl:120 matching its timeout:120, which is an edge-case concern with no practical impact for a fast DB-read critical section. Functions/Http/Deployments/Create.php and Sites/Http/Deployments/Create.php — checkLock TTL configuration. Important Files Changed
Reviews (6): Last reviewed commit: "Fix deployment upload analyze warning" | Re-trigger Greptile |
✨ Benchmark resultsComparing 1.9.x (before) to fix/parallel-storage-chunk-upload (after). Before
After
Delta
Top API waits
|
🔄 PHP-Retry SummaryFlaky tests detected across commits: Commit
|
| Test | Retries | Total Time | Details |
|---|---|---|---|
UsageTest::testPrepareDatabaseStatsTablesAPI |
1 | 32.85s | Logs |
TablesDBTransactionsConsoleClientTest::testBulkCreate |
1 | 240.83s | Logs |
Commit d58929b - 28 flaky tests
| Test | Retries | Total Time | Details |
|---|---|---|---|
UsageTest::testFunctionsStats |
1 | 10.20s | Logs |
UsageTest::testPrepareSitesStats |
1 | 7ms | Logs |
UsageTest::testEmbeddingsTextUsageDoesNotBreakProjectUsage |
1 | 5ms | Logs |
WebhooksCustomServerTest::testDeleteDeployment |
1 | 15ms | Logs |
WebhooksCustomServerTest::testDeleteFunction |
1 | 10ms | Logs |
WebhooksCustomServerTest::testCreateCollection |
1 | 9ms | Logs |
WebhooksCustomServerTest::testCreateAttributes |
1 | 12ms | Logs |
WebhooksCustomServerTest::testCreateDocument |
1 | 17ms | Logs |
WebhooksCustomServerTest::testUpdateDocument |
1 | 80ms | Logs |
WebhooksCustomServerTest::testDeleteDocument |
1 | 13ms | Logs |
WebhooksCustomServerTest::testCreateTable |
1 | 14ms | Logs |
WebhooksCustomServerTest::testCreateColumns |
1 | 36ms | Logs |
WebhooksCustomServerTest::testCreateRow |
1 | 15ms | Logs |
WebhooksCustomServerTest::testUpdateRow |
1 | 10ms | Logs |
WebhooksCustomServerTest::testDeleteRow |
1 | 20ms | Logs |
WebhooksCustomServerTest::testCreateStorageBucket |
1 | 9ms | Logs |
WebhooksCustomServerTest::testUpdateStorageBucket |
1 | 11ms | Logs |
WebhooksCustomServerTest::testCreateBucketFile |
1 | 10ms | Logs |
WebhooksCustomServerTest::testUpdateBucketFile |
1 | 7ms | Logs |
WebhooksCustomServerTest::testDeleteBucketFile |
1 | 6ms | Logs |
WebhooksCustomServerTest::testDeleteStorageBucket |
1 | 17ms | Logs |
WebhooksCustomServerTest::testCreateTeam |
1 | 8ms | Logs |
WebhooksCustomServerTest::testUpdateTeam |
1 | 13ms | Logs |
WebhooksCustomServerTest::testUpdateTeamPrefs |
1 | 15ms | Logs |
WebhooksCustomServerTest::testDeleteTeam |
1 | 6ms | Logs |
WebhooksCustomServerTest::testCreateTeamMembership |
1 | 16ms | Logs |
WebhooksCustomServerTest::testDeleteTeamMembership |
1 | 10ms | Logs |
WebhooksCustomServerTest::testWebhookAutoDisable |
1 | 56ms | Logs |
Commit 6e19db1 - 28 flaky tests
| Test | Retries | Total Time | Details |
|---|---|---|---|
WebhooksCustomServerTest::testDeleteDeployment |
1 | 204ms | Logs |
WebhooksCustomServerTest::testDeleteFunction |
1 | 10ms | Logs |
WebhooksCustomServerTest::testCreateCollection |
1 | 8ms | Logs |
WebhooksCustomServerTest::testCreateAttributes |
1 | 8ms | Logs |
WebhooksCustomServerTest::testCreateDocument |
1 | 63ms | Logs |
WebhooksCustomServerTest::testUpdateDocument |
1 | 12ms | Logs |
WebhooksCustomServerTest::testDeleteDocument |
1 | 26ms | Logs |
WebhooksCustomServerTest::testCreateTable |
1 | 15ms | Logs |
WebhooksCustomServerTest::testCreateColumns |
1 | 17ms | Logs |
WebhooksCustomServerTest::testCreateRow |
1 | 18ms | Logs |
WebhooksCustomServerTest::testUpdateRow |
1 | 18ms | Logs |
WebhooksCustomServerTest::testDeleteRow |
1 | 12ms | Logs |
WebhooksCustomServerTest::testCreateStorageBucket |
1 | 7ms | Logs |
WebhooksCustomServerTest::testUpdateStorageBucket |
1 | 8ms | Logs |
WebhooksCustomServerTest::testCreateBucketFile |
1 | 9ms | Logs |
WebhooksCustomServerTest::testUpdateBucketFile |
1 | 5ms | Logs |
WebhooksCustomServerTest::testDeleteBucketFile |
1 | 5ms | Logs |
WebhooksCustomServerTest::testDeleteStorageBucket |
1 | 12ms | Logs |
WebhooksCustomServerTest::testCreateTeam |
1 | 6ms | Logs |
WebhooksCustomServerTest::testUpdateTeam |
1 | 8ms | Logs |
WebhooksCustomServerTest::testUpdateTeamPrefs |
1 | 10ms | Logs |
WebhooksCustomServerTest::testDeleteTeam |
1 | 5ms | Logs |
WebhooksCustomServerTest::testCreateTeamMembership |
1 | 11ms | Logs |
WebhooksCustomServerTest::testDeleteTeamMembership |
1 | 8ms | Logs |
WebhooksCustomServerTest::testWebhookAutoDisable |
1 | 21ms | Logs |
UsageTest::testFunctionsStats |
1 | 10.14s | Logs |
UsageTest::testPrepareSitesStats |
1 | 7ms | Logs |
UsageTest::testEmbeddingsTextUsageDoesNotBreakProjectUsage |
1 | 5ms | Logs |
Commit fd83090 - 4 flaky tests
| Test | Retries | Total Time | Details |
|---|---|---|---|
UsageTest::testFunctionsStats |
1 | 10.12s | Logs |
UsageTest::testPrepareSitesStats |
1 | 7ms | Logs |
UsageTest::testEmbeddingsTextUsageDoesNotBreakProjectUsage |
1 | 5ms | Logs |
FunctionsScheduleTest::testCreateScheduledAtExecution |
1 | 131.11s | Logs |
Commit 5c7e08f - 4 flaky tests
| Test | Retries | Total Time | Details |
|---|---|---|---|
FunctionsScheduleTest::testCreateScheduledAtExecution |
1 | 127.07s | Logs |
UsageTest::testFunctionsStats |
1 | 10.19s | Logs |
UsageTest::testPrepareSitesStats |
1 | 7ms | Logs |
UsageTest::testEmbeddingsTextUsageDoesNotBreakProjectUsage |
1 | 5ms | Logs |
Note: Flaky test results are tracked for the last 5 commits
|
Addressed the Greptile review feedback:
Verified with:
|
|
Addressed the latest Greptile TTL finding:
Verified with:
|
|
Addressed the latest Greptile review feedback:
Verified locally with:
|
Summary
Tests