Don't be so trusting that shm_toc_lookup() will always succeed.
Tom Lane <tgl@sss.pgh.pa.us>
Don't be so trusting that shm_toc_lookup() will always succeed. Given the possibility of race conditions and so on, it seems entirely unsafe to just assume that shm_toc_lookup() always finds the key it's looking for --- but that was exactly what all but one call site were doing. To fix, add a "bool noError" argument, similarly to what we have in many other functions, and throw an error on an unexpected lookup failure. Remove now-redundant Asserts that a rather random subset of call sites had. I doubt this will throw any light on buildfarm member lorikeet's recent failures, because if an unnoticed lookup failure were involved, you'd kind of expect a null-pointer-dereference crash rather than the observed symptom. But you never know ... and this is better coding practice even if it never catches anything. Discussion: https://postgr.es/m/9697.1496675981@sss.pgh.pa.us
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/access/transam/parallel.c | modified | +12 −19 |
| src/backend/executor/execParallel.c | modified | +8 −8 |
| src/backend/executor/nodeBitmapHeapscan.c | modified | +1 −1 |
| src/backend/executor/nodeCustom.c | modified | +1 −1 |
| src/backend/executor/nodeForeignscan.c | modified | +1 −1 |
| src/backend/executor/nodeIndexonlyscan.c | modified | +1 −1 |
| src/backend/executor/nodeIndexscan.c | modified | +1 −1 |
| src/backend/executor/nodeSeqscan.c | modified | +1 −1 |
| src/backend/storage/ipc/shm_toc.c | modified | +9 −1 |
| src/include/storage/shm_toc.h | modified | +1 −1 |
| src/test/modules/test_shm_mq/worker.c | modified | +3 −3 |
Discussion
- shm_toc_lookup API 8 messages · 2017-06-05