Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rrb78-001YCq-MB for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Apr 2024 10:11:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1rrb76-007Ae5-2g for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Apr 2024 10:11:32 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rrb75-007Adx-L4 for pgsql-hackers@lists.postgresql.org; Tue, 02 Apr 2024 10:11:32 +0000 Received: from mail.postgrespro.ru ([93.174.131.139]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rrb73-0009jS-CT for pgsql-hackers@lists.postgresql.org; Tue, 02 Apr 2024 10:11:31 +0000 Received: from mail.postgrespro.ru (webmail.mstn.postgrespro.ru [192.168.2.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) (Authenticated sender: i.kartyshov@postgrespro.ru) by mail.postgrespro.ru (Postfix/587) with ESMTPSA id B777BE20C31; Tue, 2 Apr 2024 13:11:27 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=postgrespro.ru; s=mx2023; t=1712052687; bh=9FY/Drm9W3rS1fV+2zUbsb7D9KaA32X6y3quqzJ0710=; h=Date:From:To:Cc:Subject:In-Reply-To:References:User-Agent: Message-ID:From; b=zAvn7wuNtZwLQg/Xi8hvLMib8ykOwMafOk4Lc/kFLYDsEqpoCVOUNvACtBefZgtUb hpwUQseS1kfFnogb2gOl2mpBvtnzLufw/EHnr9hSQNAkhW0YB3KS2+M/xPxOVaAN34 6BjjcSbZeLWGm4TD2ZPyDc+MIlc8w5KLgndNErmq/w7kAY1j0gXi21wWTdw49Tlcqv wmF0Aw+fM7Z2PYEThreiXLWKmCOMwQPVCb/d+PMEqLkwr1wYectEKGIikUy0yWw89P jnVWQDvzM5+e0HVJUVQaToHLY8zAhMek5hnX6AdwM5MRjpIUXQQ0w1mHk1jmsu8MKh 5O+tlu6CBs94Q== MIME-Version: 1.0 Date: Tue, 02 Apr 2024 13:11:27 +0300 From: Kartyshov Ivan To: Andy Fan Cc: Alexander Korotkov , Bharath Rupireddy , Euler Taveira , Thomas Munro , Peter Eisentraut , Amit Kapila , Dilip Kumar , Peter Smith , pgsql-hackers@lists.postgresql.org Subject: Re: [HACKERS] make async slave to wait for lsn to be replayed In-Reply-To: <87h6gk9nvc.fsf@163.com> References: <5358d911a08ef2952b1e9f74062426ee@postgrespro.ru> <88449be3-93e8-4d78-a0d8-c37e4cf26850@app.fastmail.com> <8aec133e-5d7f-4fa1-8223-257647dd1ccd@app.fastmail.com> <432592e4d09341d41bf5cad1df26b3f3@postgrespro.ru> <87le5wa1dw.fsf@163.com> <87h6gk9nvc.fsf@163.com> User-Agent: Roundcube Webmail/1.6.5 Message-ID: <6eb8c9f22b075964f502080dadc16cb2@postgrespro.ru> X-Sender: i.kartyshov@postgrespro.ru Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2024-04-02 11:14, Andy Fan wrote: > If so, when users call pg_wal_replay_wait, they can get informed when > the wal is replaied to the target_lsn, but they can't know how long > time > it waits unless they check it in application side, I think such > information will be useful for monitor purpose sometimes. > > select pg_wal_replay_wait(lsn, 1000); may just take 1ms in fact, in > this case, I want this function return 1. Hi Andy, to get timing we can use \time in psql. Here is an example. postgres=# \timing Timing is on. postgres=# select 1; ?column? ---------- 1 (1 row) Time: 0.536 ms > void And returning VOID is the best option, rather than returning TRUE|FALSE or timing. It left the logic of the procedure very simple, we get an error if LSN is not reached. 8 years, we tried to add this feature, and now we suggest the best way for this feature is to commit the minimal version first. Let's discuss further improvements in future versions. -- Ivan Kartyshov Postgres Professional: www.postgrespro.com