Hi hackers, (CC: Sawada-san and Alexander, who attended in the original thread)
This is a fork thread from [1]. I found a race condition between the exiting backend and another one, while using the injection points. Found issue ========== Injection points attached after injection_points_set_local() are removed via before_shmem_exit callback. This cleanup identifies an injection point only by name. If another backend detached the point and attached a new callback with the same name before the original backend exited, the cleanup could detach the new callback instead. 0001 reproduces the same issue. Proposed fix ========== The fix idea is to remember the indicator of attached injection points by the backend. When the backend is in the local injection point mode and points, the slot id and its generation are stored in the local list. At the cleanup phase, the backend iterates all listed injection points and removes it if the generation is the same. See 0002. Alternative fix =========== So far, a regression test 010_index_concurrently_upsert can fail by this issue [2]. If we only focus on fixing this test, there is another approach to wait till cleanups are done. The patch with the prefix "nocfbot" implements the same. How do you feel? Feedbacks are very welcome. [1]: postgresql.org/message-id/flat/OS7PR01MB183172A425382C8A781DB153FF56D2%40OS7PR01MB18317.jpnprd01.prod.outlook.com [2]: https://www.postgresql.org/message-id/8ccd0497-c914-47e2-804d-299b678863bf%40gmail.com Best regards, Hayato Kuroda FUJITSU LIMITED
nocfbot-0001-Stabilize-010_index_concurrently_upsert.patch
Description: nocfbot-0001-Stabilize-010_index_concurrently_upsert.patch
0001-injection-points-reproducer-for-the-race-condition-b.patch
Description: 0001-injection-points-reproducer-for-the-race-condition-b.patch
0002-injection-points-Add-handles-for-detaching-callbacks.patch
Description: 0002-injection-points-Add-handles-for-detaching-callbacks.patch
