On 2020-03-17 15:47, Kartyshov Ivan wrote:
Synopsis ========== WAIT FOR [ANY | SOME | ALL] event [, event ...]
I'm confused as to what SOME would mean in this command's syntax, but I can see you removed it from gram.y since the last patch. Did you decide to not implement it after all?
Also, I had a look at the code and tested it a bit. ================ If I specify many events, here's what happens: For WAIT_FOR_ALL strategy, it chooses - maximum LSN - maximum delay and waits for the resulting event. For WAIT_FOR_ANY strategy - same, but it uses minimal LSN/delay. In other words, statements (1) WAIT FOR ALL LSN '7F97208' TIMEOUT 11, LSN '3002808' TIMEOUT 50; (2) WAIT FOR ANY LSN '7F97208' TIMEOUT 11, LSN '3002808' TIMEOUT 50; are essentially equivalent to: (1) WAIT FOR LSN '7F97208' TIMEOUT 50; (2) WAIT FOR LSN '3002808' TIMEOUT 11; It seems a bit counter-intuitive to me, because I expected events to be treated independently. Is this the expected behaviour? ================ In utility.c: if (event->delay < time_val) time_val = event->delay / 1000; Since event->delay is an int, the result will be zero for any delay value less than 1000. I suggest either dividing by 1000.0 or explicitly converting int to float. Also, shouldn't event->delay be divided by 1000 in the 'if' part as well? ================ You compare two LSN-s using pg_lsn_cmp(): res = DatumGetUInt32( DirectFunctionCall2(pg_lsn_cmp, lsn, trg_lsn)); As far as I understand, it'd be enough to use operators such as "<=", as you do in wait.c: /* If LSN has been replayed */ if (trg_lsn <= cur_lsn) -- Anna Akenteva Postgres Professional: The Russian Postgres Company http://www.postgrespro.com