You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Deadlock can occur in a batch when executing synchronously, with very specific statements #3846
When executing a batched command synchronously, we currently switch to asynchronous writing. This is to prevent a deadlock with PG, where we're stuck writing a big 2nd statement but PG is stuck writing back the results of the 1st statement.
However, we switch to async only once a flush has occurred - this is incorrect. A small 1st statement which produces a lot of results, followed by a huge 2nd statement (big parameter) would cause a deadlock, as the 2nd statement is still written synchronously (since no flush occurred).
We must switch to async writing starting with the 2nd statement, regardless of whether a flush has occurred or not. We may as well write the entire batch asynchronously, but as @vonzshik pointed out, writing the 1st statement synchronously is useful to improve the chances we get errors out.
Activity
Always write non-first batched statements asynchronously
Always write non-first batched statements asynchronously (#3847)
Always write non-first batched statements asynchronously (#3847)
Always write non-first batched statements asynchronously (#3847)
Always write non-first batched statements asynchronously (#3847)