Commit 98eb41d
authored
Fix race condition when deleting labels (#4944)
Concurrent requests updating the same resource's labels could fail with
Sequel::NoExistingObject when both try to delete the same label. This
occurred because find().destroy loads the model first, then deletes by
ID - if another request deletes it in between, the delete affects 0 rows
and Sequel raises an error.
Changed to use where().destroy which deletes directly via SQL without
loading the model, making it atomic and idempotent.
Also removed unnecessary .try(:destroy) from annotations_update since
where() always returns a dataset, never nil.
Observed error:
CF-NoExistingObject: Attempt to delete object did not result in a single
row modification (Rows Deleted: 0, SQL: DELETE FROM
"service_instance_labels" WHERE ("id" = ...))1 parent 63a5a5b commit 98eb41d
2 files changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | | - | |
| 13 | + | |
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
0 commit comments