2018-06-02
2018-06-02 11:17:34 by Stephen R. van den Berg <srb@cuci.nl>
-
a0a76c1a83445cf76fa29a1be1381bb861feb219
(15 lines)
(+10/-5)
[
Show
| Annotate
]
Branch: 8.0
pgsql: Release lock on collision with another thread on the same portal.
468: Inside #if defined(PG_DEBUGRACE)
PD("Nostash locked by %s\n",
describe_backtrace(nostash->current_locking_thread()->backtrace()));
#endif
- if (lock = (waitforreal ? nostash->lock : nostash->trylock)(1)) {
+ while (lock = (waitforreal ? nostash->lock : nostash->trylock)(1)) {
+ int mode;
+ if (sizeof(stash) && (mode = getstash(KEEP)) > KEEP)
+ sendcmd(mode); // Force out stash to the server
+ if (!stashcount->drained()) {
+ lock = 0; // Unlock while we wait
stashcount->wait_till_drained();
-
+ continue; // Try again
+ }
#ifdef PG_DEBUGRACE
conxsess sess = conxsess(this);
#endif
- int mode;
- if (sizeof(stash) && (mode = getstash(KEEP)) > KEEP)
- sendcmd(mode); // Force out stash to the server
+
started = lock; // sendcmd() clears started, so delay assignment
#ifdef PG_DEBUGRACE
return sess;