Open MMeent opened 1 month ago
We were informed that parallel workers are shutdown after every query. Is that then not the case?
This can be solved by passing a GucStringAssignHook to DefineCustomStringVariable (or its pgrx equivalent).
Looks like there is no pgrx equivalent at present. For now I will add a manual slower check for if the GUC has changed.
We were informed that parallel workers are shutdown after every query. Is that then not the case?
no, that is correct. But data produced in a parallel worker may be different if their local state is constructed differently from others; e.g. pg_backend_pid() would output differently across backends, and is thus marked parallel restricted
- the query may be parallel, but the function can only be executed in the primary process, never in a parallel portion of the plan.
@MMeent can we close this now?
Steps to reproduce
Check the generated SQL, code, and migrations
Expected result
PARALLEL SAFE
Actual result
Functions that depend on non-GUC backend-local state are marked as
PARALLEL SAFE
:session()
accessesJWT
, a thread-local variable that is initialized ~once based off of GUCs, but updated withset_jwt_cache
, which is called fromsession()
when JWT has not been initialized yet. So, the following command sequence invalidates thePARALLEL SAFE
part (example query):user_id()
uses the output ofsession()
, and thus has the same issues.This can be solved by passing a GucStringAssignHook to DefineCustomStringVariable (or its pgrx equivalent).