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 1jABzL-0006zD-GM for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Mar 2020 12:22:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1jABzJ-00069r-Sc for pgsql-hackers@arkaria.postgresql.org; Fri, 06 Mar 2020 12:21:57 +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 1jABzI-00068q-Fq for pgsql-hackers@lists.postgresql.org; Fri, 06 Mar 2020 12:21:57 +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 1jABzE-0001W7-75 for pgsql-hackers@postgresql.org; Fri, 06 Mar 2020 12:21:54 +0000 Received: from localhost (localhost [127.0.0.1]) by mail.postgrespro.ru (Postfix) with ESMTP id 7C03E21C210F; Fri, 6 Mar 2020 15:21:49 +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 4490C21C1F83; Fri, 6 Mar 2020 15:21:49 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mail; t=1583497309; bh=Ml+IpoaaQSTIsCSPsZbqN6oebKvfndgr4w4wMzdF86E=; h=Date:From:To:Cc:Subject; b=clMm0iYEk5GPiYJfxyz+Ui29SR9aqwZUaCEiSb7MnscN2BozE3ZMsm92Vs/Om8Epd bz9LIbNla1fyTMfF0kAusuT7Rn53eKmqeUDhi/Zt/QJ5x9i6g8kDYAeJtjCCd7s/gJ Y8xoUqZZRjDZPbscn5RAtUpdgDeyC5Hy/F+8+Wb0= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Fri, 06 Mar 2020 15:21:49 +0300 From: Kartyshov Ivan To: Kyotaro Horiguchi Cc: pgsql-hackers@postgresql.org Subject: Re: [HACKERS] make async slave to wait for lsn to be replayed User-Agent: Roundcube Webmail/1.4.0 Message-ID: <195e2d07ead315b1620f1a053313f490@postgrespro.ru> X-Sender: i.kartyshov@postgrespro.ru List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 2020-03-06 08:54, Kyotaro Horiguchi wrote: > The syntax seems getting confused. What happens if we typed in the > command "WAIT FOR TIMESTAMP '...' UNTIL TIMESTAMP '....'"? It seems > to me the options is useles. Couldn't the TIMEOUT option be a part of > event? I know gram.y doesn't accept that syntax but it is not > apparent from the description above. I`ll fix the doc file. Synopsis ========== WAIT FOR [ANY | SOME | ALL] event [, event ...] and event is: LSN value [options] TIMESTAMP value and options is: TIMEOUT delay UNTIL TIMESTAMP timestamp > As I read through the previous thread, one of the reason for this > feature implemented as a syntax is it was inteded to be combined into > BEGIN statement. If there is not any use case for the feature midst > of a transaction, why don't you turn it into a part of BEGIN command? It`s seem to have some limitations on hot standbys. I`ll take few days to make a prototype. >> Description >> ========== >> WAIT FOR - make to wait statements (that are beneath) on sleep until >> event happens (Don’t process new queries until an event happens). > ... >> Notice: WAIT FOR will release on PostmasterDeath or Interruption >> events >> if they come earlier then LSN or timeout. > > I think interrupts ought to result in ERROR. > > wait.c adds a fair amount of code and uses proc-array based > approach. But Thomas suggested queue-based approach and I also think > it is better. We already have a queue-based mechanism that behaves > almost the same with this feature in the comit code on master-side. It > avoids spurious backend wakeups. Couldn't we extend SyncRepWaitForLSN > or share a part of the code/infrastructures so that this feature can > share the code? I`ll take a look on. Thank you for your review. Rebased patch is attached. -- Ivan Kartyshov Postgres Professional: http://www.postgrespro.com The Russian Postgres Company