- Notifications
You must be signed in to change notification settings - Fork28
Commit8a90620
committed
Fix race condition during replication origin drop.
replorigin_drop() misunderstood the API for condition variables: ithad ConditionVariablePrepareToSleep and ConditionVariableCancelSleepinside its test-and-sleep loop, rather than outside the loop asintended. The net effect is a narrow race-condition window wherein,if the process using a replication slot releases it immediately afterreplorigin_drop() releases the ReplicationOriginLock, replorigin_drop()would get into the condition variable's wait list too late and thenwait indefinitely for a signal that won't come.Because there's a different CV for each replication slot, we can'tjust move the ConditionVariablePrepareToSleep call to above thetest-and-sleep loop. What we can do, in the wake of commit13db3b9,is drop the ConditionVariablePrepareToSleep call entirely. This fixdepends on that commit because (at least in principle) the slot matchingthe target replication origin might move around, so that once in a bluemoon successive loop iterations might involve different CVs. We can nowcope with such a scenario, at the cost of an extra trip through theretry loop.(There are ways we could fix this bug without depending on that commit,but they're all a lot more complicated than this way.)While at it, upgrade the rather skimpy comments in this function.Back-patch to v10 where this code came in.Discussion:https://postgr.es/m/19947.1515455433@sss.pgh.pa.us1 parent13db3b9 commit8a90620
1 file changed
+23
-6
lines changedLines changed: 23 additions & 6 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
339 | 339 |
| |
340 | 340 |
| |
341 | 341 |
| |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
342 | 346 |
| |
343 | 347 |
| |
| 348 | + | |
| 349 | + | |
| 350 | + | |
344 | 351 |
| |
345 | 352 |
| |
346 |
| - | |
347 | 353 |
| |
348 | 354 |
| |
349 | 355 |
| |
350 | 356 |
| |
351 | 357 |
| |
352 | 358 |
| |
353 |
| - | |
354 | 359 |
| |
355 | 360 |
| |
| 361 | + | |
356 | 362 |
| |
357 | 363 |
| |
358 | 364 |
| |
| |||
363 | 369 |
| |
364 | 370 |
| |
365 | 371 |
| |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
366 | 380 |
| |
367 | 381 |
| |
368 | 382 |
| |
369 |
| - | |
| 383 | + | |
370 | 384 |
| |
371 |
| - | |
372 | 385 |
| |
373 | 386 |
| |
374 | 387 |
| |
375 |
| - | |
| 388 | + | |
376 | 389 |
| |
377 | 390 |
| |
378 | 391 |
| |
| |||
382 | 395 |
| |
383 | 396 |
| |
384 | 397 |
| |
385 |
| - | |
| 398 | + | |
386 | 399 |
| |
387 | 400 |
| |
388 | 401 |
| |
389 | 402 |
| |
390 | 403 |
| |
391 | 404 |
| |
392 | 405 |
| |
| 406 | + | |
393 | 407 |
| |
| 408 | + | |
| 409 | + | |
| 410 | + | |
394 | 411 |
| |
395 | 412 |
| |
396 | 413 |
| |
|
0 commit comments
Comments
(0)