Commit db3fe36
authored
perf(queue): claim the actuation lock before the refresh it exists to prevent (#10181)
The publish-and-maintain pass refreshed PR details and THEN asked "does another
pass already own this PR", so every contended pass did the work and threw it
away.
github_app.pr_public_surface_lock_contended is the single most frequent audit
event on the production Orb: 1,180 occurrences between 09:00 and 10:53 today,
roughly 10 per minute and about twice the next event. Each one is a discarded
pass.
The cost is real but worth stating precisely. refreshPullRequestDetails is
itself cached -- it consults the detail-sync state and reuses stored
pull_request_files rows when the last sync covered the current head SHA -- so a
contention does not always cost a GitHub call. It always costs the sync-state
reads, and on a cache miss it costs a token fetch plus the files/reviews fetch.
That miss is what a busy PR produces, and a busy PR is also what contends, so
the two peak together. This happened in the same window the installation
exhausted its REST quota and 66 queue jobs stalled behind deferred_by:
rate_limit.
Claiming first changes no semantics: the lock's stated purpose (#9013) is to
make "does another pass already own this PR" one question with one answer for
the whole publish-then-maintain unit, and asking it before the expensive part is
strictly better. Holding it across the refresh is already safe -- #9467 renews
the lock while work runs precisely because this unit can span an AI review far
longer than a refresh.
The second contention site is deliberately untouched: it does not refresh
beforehand, so it does not have this defect.
Guarded by a test asserting SOURCE ORDER, which is unusual and deliberate. Both
orderings behave identically on the happy path and differ only in what a LOSING
pass spends before it throws, so no behavioural test can distinguish them --
which is why this drifted unnoticed. The test anchors on the publish pass's own
contention audit event so an unrelated claim elsewhere in this 16k-line file
cannot satisfy it, and asserts both landmarks still exist so a rename cannot
make it pass vacuously.
Closes #101741 parent 515de46 commit db3fe36
2 files changed
Lines changed: 73 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4397 | 4397 | | |
4398 | 4398 | | |
4399 | 4399 | | |
4400 | | - | |
4401 | | - | |
4402 | | - | |
4403 | | - | |
4404 | | - | |
4405 | | - | |
4406 | | - | |
4407 | | - | |
4408 | | - | |
4409 | | - | |
4410 | | - | |
4411 | | - | |
4412 | | - | |
4413 | | - | |
4414 | | - | |
4415 | | - | |
4416 | | - | |
| 4400 | + | |
| 4401 | + | |
| 4402 | + | |
| 4403 | + | |
| 4404 | + | |
| 4405 | + | |
| 4406 | + | |
4417 | 4407 | | |
4418 | 4408 | | |
4419 | 4409 | | |
| |||
4438 | 4428 | | |
4439 | 4429 | | |
4440 | 4430 | | |
| 4431 | + | |
| 4432 | + | |
| 4433 | + | |
| 4434 | + | |
| 4435 | + | |
| 4436 | + | |
| 4437 | + | |
| 4438 | + | |
| 4439 | + | |
| 4440 | + | |
| 4441 | + | |
| 4442 | + | |
| 4443 | + | |
| 4444 | + | |
| 4445 | + | |
| 4446 | + | |
| 4447 | + | |
4441 | 4448 | | |
4442 | 4449 | | |
4443 | 4450 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
0 commit comments