Commit 69c808c
committed
s3: split bucket delete into two-phase dispatch (Codex P1 #695)
Codex P1 on PR #695 caught that the original single-OperationGroup
shape would be rejected by the production coordinator on every
bucket delete. The fix lands here together with a test-coordinator
tightening that catches this class of bug in unit tests.
Background:
kv/sharded_coordinator.go:dispatchDelPrefixBroadcast rejects any
OperationGroup that mixes DEL_PREFIX with other ops AND any
OperationGroup that uses DEL_PREFIX inside a transaction. The
earlier shape ([Del BucketMetaKey, DelPrefix×6] with IsTxn=true)
hit both rejection rules, so production would have failed every
bucket delete with ErrInvalidRequest. The local test coordinator
bypassed those checks, so the regression test passed despite
the production-breaking shape.
Fix is two-part:
1. **Split AdminDeleteBucket and s3.go:deleteBucket into two
Dispatch calls**:
Phase 1 — `Del BucketMetaKey` in a txn (OCC-protected against
a concurrent AdminCreateBucket racing the delete).
Lives inside retryS3Mutation so an OCC conflict
retries the whole closure.
Phase 2 — DEL_PREFIX broadcast over every per-bucket key
family in a non-txn OperationGroup. Lives outside
retryS3Mutation because Phase 1 is the point of no
return: a Phase-2 retry would 404 at loadBucketMetaAt.
Phase-2 failure is logged via slog.WarnContext and not
propagated. The bucket meta is already gone from the operator's
POV; orphan keys (if any) are no worse than the pre-fix state
on main and can be recovered by a future sweep tool. Surfacing
a 500 to the operator after a successful delete would be a
worse UX.
Phase-1-first ordering is deliberate: a Phase-2-first ordering
could leave the bucket meta extant while per-bucket data was
wiped if Phase 1 then failed (concurrent recreate). Phase-1-
first localises any partial failure to "bucket gone, orphan
data may persist", which has a clean audit trail.
2. **Tighten localAdapterCoordinator validation** to mirror the
production coordinator's dispatch-time rejection rules:
reject IsTxn=true with any DelPrefix, reject mixed
Del+DelPrefix groups. Without this, a future regression that
ships the rejected shape would silently pass tests while
breaking production. The existing
TestS3Server_AdminDeleteBucket_SweepsOrphansAcrossAllPerBucketPrefixes
test now exercises the production-realistic dispatch path and
would have caught Codex P1 directly.
Refactor: split the single `bucketDeleteOperationGroupElems`
helper into `bucketDeleteSafetyNetElems` (DEL_PREFIX-only, used
by Phase 2) and a new `runBucketDeleteSafetyNet` method that
shares the dispatch-and-log logic between Admin and SigV4
paths. The Phase-1 Del op shape is small enough to inline at
each call site.
Design doc §6.2 rewritten with the two-phase rationale, the
Codex P1 finding, the Phase-2 failure semantics, and why Phase-1-
first ordering is correct.
Tests:
go test -count=1 -run TestS3Server_AdminDeleteBucket ./adapter/ — passes
go test -race -count=1 -run TestS3 ./adapter/ — passes (1.455s)
golangci-lint run ./adapter/... — 0 issues1 parent 5f48cd7 commit 69c808c
4 files changed
Lines changed: 206 additions & 58 deletions
File tree
- adapter
- docs/design
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| 11 | + | |
11 | 12 | | |
12 | 13 | | |
13 | 14 | | |
| |||
27 | 28 | | |
28 | 29 | | |
29 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
30 | 34 | | |
31 | 35 | | |
32 | 36 | | |
| |||
37 | 41 | | |
38 | 42 | | |
39 | 43 | | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
40 | 83 | | |
41 | 84 | | |
42 | 85 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
636 | 636 | | |
637 | 637 | | |
638 | 638 | | |
| 639 | + | |
639 | 640 | | |
640 | 641 | | |
641 | 642 | | |
| |||
669 | 670 | | |
670 | 671 | | |
671 | 672 | | |
672 | | - | |
673 | | - | |
674 | | - | |
675 | | - | |
676 | | - | |
677 | | - | |
678 | | - | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
679 | 681 | | |
680 | 682 | | |
681 | 683 | | |
682 | | - | |
| 684 | + | |
683 | 685 | | |
684 | | - | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
685 | 691 | | |
686 | 692 | | |
687 | 693 | | |
688 | 694 | | |
689 | 695 | | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
690 | 699 | | |
691 | 700 | | |
692 | 701 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
359 | 360 | | |
360 | 361 | | |
361 | 362 | | |
362 | | - | |
363 | | - | |
364 | | - | |
365 | | - | |
366 | | - | |
367 | | - | |
368 | | - | |
369 | | - | |
370 | | - | |
371 | | - | |
372 | | - | |
373 | | - | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
374 | 389 | | |
375 | 390 | | |
376 | | - | |
377 | | - | |
378 | | - | |
379 | | - | |
380 | | - | |
381 | | - | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
382 | 395 | | |
383 | | - | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
388 | 401 | | |
389 | | - | |
| 402 | + | |
390 | 403 | | |
391 | 404 | | |
392 | 405 | | |
| |||
397 | 410 | | |
398 | 411 | | |
399 | 412 | | |
| 413 | + | |
400 | 414 | | |
401 | 415 | | |
402 | 416 | | |
| |||
418 | 432 | | |
419 | 433 | | |
420 | 434 | | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
421 | 439 | | |
422 | 440 | | |
423 | 441 | | |
424 | | - | |
| 442 | + | |
425 | 443 | | |
426 | | - | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
| 447 | + | |
| 448 | + | |
427 | 449 | | |
428 | 450 | | |
429 | 451 | | |
430 | 452 | | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
431 | 458 | | |
432 | 459 | | |
433 | 460 | | |
434 | | - | |
435 | | - | |
436 | | - | |
437 | | - | |
438 | | - | |
439 | | - | |
440 | | - | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
441 | 466 | | |
442 | 467 | | |
443 | 468 | | |
444 | 469 | | |
445 | 470 | | |
446 | 471 | | |
447 | | - | |
448 | | - | |
449 | | - | |
450 | | - | |
451 | | - | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
452 | 477 | | |
453 | | - | |
454 | 478 | | |
455 | 479 | | |
456 | 480 | | |
| |||
460 | 484 | | |
461 | 485 | | |
462 | 486 | | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
463 | 505 | | |
464 | 506 | | |
465 | 507 | | |
| |||
Lines changed: 64 additions & 10 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
170 | 170 | | |
171 | 171 | | |
172 | 172 | | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
173 | 189 | | |
174 | | - | |
175 | | - | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | | - | |
181 | | - | |
182 | | - | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
183 | 211 | | |
184 | 212 | | |
185 | 213 | | |
186 | 214 | | |
187 | | - | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
188 | 242 | | |
189 | 243 | | |
190 | 244 | | |
| |||
0 commit comments