Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.92) (envelope-from ) id 1jFbit-0004vF-PK for pgsql-hackers@arkaria.postgresql.org; Sat, 21 Mar 2020 10:51:24 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jFbir-0005rF-KF for pgsql-hackers@arkaria.postgresql.org; Sat, 21 Mar 2020 10:51:21 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1jFbir-0005r8-6D for pgsql-hackers@lists.postgresql.org; Sat, 21 Mar 2020 10:51:21 +0000 Received: from cyclops.postgrespro.ru ([93.174.131.138] helo=mail.postgrespro.ru) by makus.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1jFbin-0003Hl-Ad for pgsql-hackers@lists.postgresql.org; Sat, 21 Mar 2020 10:51:19 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 8EF4521C4CFE for ; Sat, 21 Mar 2020 13:51:14 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at postgrespro.ru X-Spam-Flag: NO X-Spam-Score: 0 X-Spam-Level: X-Spam-Status: No, score=x tagged_above=-99 required=4 WHITELISTED tests=[] autolearn=unavailable Received: from mail.postgrespro.ru (cyclops.l.postgrespro.ru [192.168.27.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mail.postgrespro.ru (Postfix) with ESMTPSA id 2546521C2133 for ; Sat, 21 Mar 2020 13:51:14 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1584787874; bh=sKsHUsamZDv26iw0K3YsLIihu2UDGuEmmc2VEk9osG4=; h=Date:From:To:Subject:In-Reply-To:References; b=XHnY1g/F8WfutPQenK4hwk1Mio2D0NnmQtvOlyLEERa9jVTwNSkBO1TBHLZDgNGKW aCt44OOUUPK1yeXadekuiSvrxJ+BMsAiZrMyou1tkXFpZIBfPgHZKp4DiIMc/qLD2b nB7a9VzAwxi1QgNz1EQh9xCY6wD/IVnAg2RPSHRE= MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Sat, 21 Mar 2020 13:51:13 +0300 From: Anna Akenteva To: pgsql-hackers@lists.postgresql.org Subject: Re: [HACKERS] make async slave to wait for lsn to be replayed In-Reply-To: <774cef59db63a150b6127da2428cba7d@postgrespro.ru> References: <195e2d07ead315b1620f1a053313f490@postgrespro.ru> <774cef59db63a150b6127da2428cba7d@postgrespro.ru> User-Agent: Roundcube Webmail/1.4.0 Message-ID: X-Sender: a.akenteva@postgrespro.ru Organization: Postgres Professional List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk 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