Re: BUG #18314: PARALLEL UNSAFE function does not prevent parallel index build
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Michael Paquier <michael@paquier.xyz>
Cc: Tender Wang <tndrwang@gmail.com>, pgsql-bugs@lists.postgresql.org,
Alexander Lakhin <exclusion@gmail.com>,
jian he <jian.universality@gmail.com>
Date: 2024-03-06T23:01:50Z
Lists: pgsql-bugs
Michael Paquier <michael@paquier.xyz> writes: > Still the issue fixed here and the issue of the other thread are > different? Relying on the relcache tricks the planner to spawn > workers for nothing because they would just fail if the internals of > the function are unsafe to run in the workers, and the function is > marked as such. Sure, but the current patch just trades one set of errors for others. As I said, if we care about this problem then the right fix will involve serializing/deserializing already-const-folded expression trees instead of expecting that the workers can regenerate those. I don't personally think it's worth the trouble, especially not if we can get rid of the need for exception-using functions to be marked parallel unsafe. > In some cases users like to use properties as hints > to give to the planner about what to use or not. I'd like to believe > (and perhaps that's a cute thought) that functions are marked as > parallel-unsafe for a purpose, which is that they cannot run in > workers as they rely on a shared state. Whether the internals of the > functions are implemented correctly is up to the user. I mean, it's > perfectly possible to mark a function as immutable while its internals > are volatile, and I've seen people rely on that to push down clauses. It's the other direction that I'm concerned about: if we inline a SQL function and find that its innards are less volatile than the original marking, we are free to exploit that, and people will complain if we don't. Similarly, if the innards are more parallel safe than the original marking, we should be able to exploit that. regards, tom lane
Commits
-
Revert "Fix parallel-safety check of expressions and predicate for index builds"
- 69e8f9dadb01 12.19 landed
- 70a31629aede 13.15 landed
- 49b971298a9b 14.12 landed
- e82b64a92cf5 15.7 landed
- c46817ee512a 16.3 landed
- 099ca50bd41c 17.0 landed
-
Fix parallel-safety check of expressions and predicate for index builds
- c0e0174c216b 12.19 landed
- b60d71c202cd 13.15 landed
- 56a8ab2fc6f7 14.12 landed
- 50b5913a87c9 15.7 landed
- 4ec8f7708b6b 16.3 landed
- eae7be600be7 17.0 landed
-
Ensure we preprocess expressions before checking their volatility.
- 743ddafc7124 17.0 cited