Commit f439ffd
committed
Fix race condition in concurrent artifact additions
This fixes a race condition where concurrent 'podman artifact add'
commands for different artifacts would result in only one artifact
being created, without any error messages.
The root cause was in the artifact store's Add() method. When the lock
was released during blob copying (for performance), concurrent additions
could overwrite each other's index entries:
- Process A: Lock → Read index → Unlock → Copy blobs → Lock → Commit
- Process B: Lock → Read index (missing A) → Unlock → Copy blobs → Lock → Commit
- Result: Process B's commit overwrites Process A's entry
The fix adds conflict detection after reacquiring the lock. Before
committing, we reload the artifact index and verify the artifact name
hasn't been added by another process. If a conflict is detected, we
return an error rather than silently overwriting the concurrent change.
This preserves the performance benefits of concurrent blob copying
while preventing the race condition that caused artifacts to be lost.
Fixes: containers/podman#27569
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>1 parent 63be353 commit f439ffd
1 file changed
+19
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
218 | 218 | | |
219 | 219 | | |
220 | 220 | | |
221 | | - | |
222 | 221 | | |
223 | | - | |
224 | | - | |
225 | | - | |
226 | | - | |
227 | | - | |
| 222 | + | |
228 | 223 | | |
229 | 224 | | |
230 | 225 | | |
| |||
297 | 292 | | |
298 | 293 | | |
299 | 294 | | |
300 | | - | |
301 | | - | |
302 | | - | |
| 295 | + | |
| 296 | + | |
303 | 297 | | |
304 | 298 | | |
305 | 299 | | |
| |||
356 | 350 | | |
357 | 351 | | |
358 | 352 | | |
| 353 | + | |
359 | 354 | | |
360 | | - | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
361 | 370 | | |
362 | 371 | | |
363 | 372 | | |
| |||
0 commit comments