Commit 467eac5
Address review: snapshot clientCtx and guard timeoutQuorumWait against recycle
Per @merlimat's review on #4760, the original null-check in maybeTimeout()
still races: clientCtx may be nulled between the guard and the subsequent
getConf() dereference. Volatile only addresses visibility, not atomicity
across two reads.
- Snapshot clientCtx into a local in maybeTimeout(); the local cannot be
mutated by another thread, so the dereference is race-free.
- Drop the volatile modifier on clientCtx (no longer load-bearing once the
read is done once into a local).
- Extend timeoutQuorumWait()'s early-return to also short-circuit when
lh / clientCtx are null. recyclePendAddOpObject() resets `completed` to
false, so the prior `if (completed)` guard does not cover the
already-recycled case; without this check timeoutQuorumWait() NPEs on
lh.getLedgerMetadata() (and worse, could invoke
handleUnrecoverableErrorDuringAdd on a stale handle).
- Add testTimeoutQuorumWaitIsNoOpWhenAlreadyRecycled covering the new guard.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent dbdf559 commit 467eac5
2 files changed
Lines changed: 46 additions & 7 deletions
File tree
- bookkeeper-server/src
- main/java/org/apache/bookkeeper/client
- test/java/org/apache/bookkeeper/client
Lines changed: 14 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
| 69 | + | |
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
| |||
154 | 154 | | |
155 | 155 | | |
156 | 156 | | |
157 | | - | |
158 | | - | |
159 | | - | |
160 | | - | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
161 | 164 | | |
162 | 165 | | |
163 | | - | |
| 166 | + | |
164 | 167 | | |
165 | 168 | | |
166 | 169 | | |
167 | 170 | | |
168 | 171 | | |
169 | 172 | | |
170 | 173 | | |
171 | | - | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
172 | 179 | | |
173 | 180 | | |
174 | 181 | | |
| |||
Lines changed: 32 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
| 27 | + | |
27 | 28 | | |
| 29 | + | |
| 30 | + | |
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
| |||
165 | 168 | | |
166 | 169 | | |
167 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
168 | 200 | | |
0 commit comments