- Notifications
You must be signed in to change notification settings - Fork28
Commitd4b667e
committed
Fix "invalid spinlock number: 0" error in pg_stat_wal_receiver.
Commit2c8dd05 added the atomic variable writtenUpto intowalreceiver's shared memory information. It's initialized onlywhen walreceiver started up but could be read via pg_stat_wal_receiverview anytime, i.e., even before it's initialized. In the server builtwith --disable-atomics and --disable-spinlocks, this uninitializedatomic variable read could cause "invalid spinlock number: 0" error.This commit changed writtenUpto so that it's initialized atthe postmaster startup, to avoid the uninitialized variable readvia pg_stat_wal_receiver and fix the error.Also this commit moved the read of writtenUpto after the releaseof spinlock protecting walreceiver's shared variables. This isnecessary to prevent new spinlock from being taken by atomicvariable read while holding another spinlock, and to shortenthe spinlock duration. This change leads writtenUpto not to beconsistent with the other walreceiver's shared variables protectedby a spinlock. But this is OK because writtenUpto should not beused for data integrity checks.Back-patch to v13 where commit2c8dd05 introduced the bug.Author: Fujii MasaoReviewed-by: Michael Paquier, Thomas Munro, Andres FreundDiscussion:https://postgr.es/m/7ef8708c-5b6b-edd3-2cf2-7783f1c7c175@oss.nttdata.com1 parentdaf2e70 commitd4b667e
File tree
4 files changed
+20
-2
lines changed- src
- backend/replication
- test/regress
- expected
- sql
4 files changed
+20
-2
lines changedLines changed: 9 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
261 | 261 |
| |
262 | 262 |
| |
263 | 263 |
| |
264 |
| - | |
| 264 | + | |
265 | 265 |
| |
266 | 266 |
| |
267 | 267 |
| |
| |||
1376 | 1376 |
| |
1377 | 1377 |
| |
1378 | 1378 |
| |
1379 |
| - | |
1380 | 1379 |
| |
1381 | 1380 |
| |
1382 | 1381 |
| |
| |||
1396 | 1395 |
| |
1397 | 1396 |
| |
1398 | 1397 |
| |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
1399 | 1406 |
| |
1400 | 1407 |
| |
1401 | 1408 |
| |
|
Lines changed: 1 addition & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
63 | 63 |
| |
64 | 64 |
| |
65 | 65 |
| |
| 66 | + | |
66 | 67 |
| |
67 | 68 |
| |
68 | 69 |
| |
|
Lines changed: 7 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
67 | 67 |
| |
68 | 68 |
| |
69 | 69 |
| |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
70 | 77 |
| |
71 | 78 |
| |
72 | 79 |
| |
|
Lines changed: 3 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
32 | 32 |
| |
33 | 33 |
| |
34 | 34 |
| |
| 35 | + | |
| 36 | + | |
| 37 | + | |
35 | 38 |
| |
36 | 39 |
| |
37 | 40 |
| |
|
0 commit comments
Comments
(0)