forked frompostgres/postgres
- Notifications
You must be signed in to change notification settings - Fork6
Commitdc5f905
committed
Fix invalidation of local pgstats references for entry reinitialization
818119a has introduced the "generation" concept in pgstats entries,incremented a counter when a pgstats entry is reinitialized, but it didnot count on the fact that backends still holding local references tosuch entries need to be refreshed if the cache age is outdated. Theprevious logic only updated local references when an entry was dropped,but it needs also to consider entries that are reinitialized.This matters for replication slot stats (as well as custom pgstats kindsin 18~), where concurrent drops and creates of a slot could causeincorrect stats to be locally referenced. This would lead to anassertion failure at shutdown when writing out the stats file, as thebackend holding an outdated local reference would not be able to dropduring its shutdown sequence the stats entry that should be dropped, asthe last process holding a reference to the stats entry. Thecheckpointer was then complaining about such an entry late in theshutdown sequence, after the shutdown checkpoint is finished with thecontrol file updated, causing the stats file to not be generated. Innon-assert builds, the entry would just be skipped with the stats filewritten.Note that only logical replication slots use statistics.A test case based on TAP is added to test_decoding, where a persistentconnection peeking at a slot's data is kept with concurrent drops andcreates of the same slot. This is based on the isolation test case thatAnton has sent. As it requires a node shutdown with a check to makesure that the stats file is written with this specific sequence ofevents, TAP is used instead.Reported-by: Anton A. MelnikovReviewed-by: Bertrand DrouvotDiscussion:https://postgr.es/m/56bf8ff9-dd8c-47b2-872a-748ede82af99@postgrespro.ruBackpatch-through: 151 parent9d5ce4f commitdc5f905
File tree
2 files changed
+69
-2
lines changed- contrib/test_decoding/t
- src/backend/utils/activity
2 files changed
+69
-2
lines changedLines changed: 60 additions & 0 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
118 | 118 |
| |
119 | 119 |
| |
120 | 120 |
| |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
121 | 181 |
|
Lines changed: 9 additions & 2 deletions
Original file line number | Diff line number | Diff line change | |
---|---|---|---|
| |||
703 | 703 |
| |
704 | 704 |
| |
705 | 705 |
| |
706 |
| - | |
| 706 | + | |
| 707 | + | |
707 | 708 |
| |
708 | 709 |
| |
709 | 710 |
| |
| |||
713 | 714 |
| |
714 | 715 |
| |
715 | 716 |
| |
716 |
| - | |
| 717 | + | |
| 718 | + | |
| 719 | + | |
| 720 | + | |
| 721 | + | |
| 722 | + | |
| 723 | + | |
717 | 724 |
| |
718 | 725 |
| |
719 | 726 |
| |
|
0 commit comments
Comments
(0)