Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kBf9R-0004MO-4Q for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Aug 2020 14:14:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1kBf9Q-0002n4-3R for pgsql-hackers@arkaria.postgresql.org; Fri, 28 Aug 2020 14:14:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kBf9P-0002mx-RE for pgsql-hackers@lists.postgresql.org; Fri, 28 Aug 2020 14:14:43 +0000 Received: from smtp-fw-33001.amazon.com ([207.171.190.10]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kBf9L-0001Ak-3o for pgsql-hackers@postgresql.org; Fri, 28 Aug 2020 14:14:42 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amazon.com; i=@amazon.com; q=dns/txt; s=amazon201209; t=1598624079; x=1630160079; h=to:cc:references:from:message-id:date:mime-version: in-reply-to:content-transfer-encoding:subject; bh=fAI1Mdp5fFTMEUPz97c73c/aJjh81fKxfhUrLFqQsOo=; b=QwZLjolHszmug9LnLwlGkqHqElTJ7v7tK2AU2IyG4KiKQKjH1R6ijZ3v CvxhCuJZtYKu7O2V8YnyYTwWcpcd4YECSXhHC4CB+BO0gr8KJ23BMvn4F yaE3t+wegqp3DmQGHiYHf8TeYST+ZuszKZxnQ1ZtLGNp73+0gFzKCgvUA M=; X-IronPort-AV: E=Sophos;i="5.76,364,1592870400"; d="scan'208";a="70465159" Subject: Re: Add Information during standby recovery conflicts Received: from sea32-co-svc-lb4-vlan3.sea.corp.amazon.com (HELO email-inbound-relay-1e-27fb8269.us-east-1.amazon.com) ([10.47.23.38]) by smtp-border-fw-out-33001.sea14.amazon.com with ESMTP; 28 Aug 2020 14:14:33 +0000 Received: from EX13D03EUC003.ant.amazon.com (iad55-ws-svc-p15-lb9-vlan2.iad.amazon.com [10.40.159.162]) by email-inbound-relay-1e-27fb8269.us-east-1.amazon.com (Postfix) with ESMTPS id ADF86A2415; Fri, 28 Aug 2020 14:14:32 +0000 (UTC) Received: from 38f9d36c4abb.ant.amazon.com (10.43.161.34) by EX13D03EUC003.ant.amazon.com (10.43.164.192) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Fri, 28 Aug 2020 14:14:30 +0000 To: Masahiko Sawada CC: PostgreSQL-development References: <9a60178c-a853-1440-2cdc-c3af916cff59@amazon.com> <3aededb3-8eb7-bfd6-6fd4-b6487f8f1d74@amazon.com> <85c21e8e-4b12-9ff6-92bf-24fac2166632@amazon.com> <45fba139-8415-ae3e-0637-f9c698432f00@amazon.com> <05621ec8-6e62-25db-14c4-50079304617d@amazon.com> From: "Drouvot, Bertrand" Message-ID: <0fb96369-cc7c-cddb-a474-ca3d29904123@amazon.com> Date: Fri, 28 Aug 2020 16:14:25 +0200 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Originating-IP: [10.43.161.34] X-ClientProxiedBy: EX13D13UWA001.ant.amazon.com (10.43.160.136) To EX13D03EUC003.ant.amazon.com (10.43.164.192) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 8/28/20 7:03 AM, Masahiko Sawada wrote: > CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you can confirm the sender and know the content is safe. > > > > On Thu, 27 Aug 2020 at 20:58, Drouvot, Bertrand wrote: >> >> On 8/27/20 10:16 AM, Masahiko Sawada wrote >>> On Mon, 10 Aug 2020 at 23:43, Drouvot, Bertrand wrote: >>>> Hi, >>>> >>>> On 7/31/20 7:12 AM, Masahiko Sawada wrote: >>>>> + tmpWaitlist = waitlist; >>>>> + while (VirtualTransactionIdIsValid(*tmpWaitlist)) >>>>> + { >>>>> + tmpWaitlist++; >>>>> + } >>>>> + >>>>> + num_waitlist_entries = (tmpWaitlist - waitlist); >>>>> + >>>>> + /* display wal record information */ >>>>> + if (log_recovery_conflicts && >>>>> (TimestampDifferenceExceeds(recovery_conflicts_log_time, >>>>> GetCurrentTimestamp(), >>>>> + DeadlockTimeout))) { >>>>> + LogBlockedWalRecordInfo(num_waitlist_entries, reason); >>>>> + recovery_conflicts_log_time = GetCurrentTimestamp(); >>>>> + } >>>>> >>>>> recovery_conflicts_log_time is not initialized. And shouldn't we >>>>> compare the current timestamp to the timestamp when the startup >>>>> process started waiting? >>>>> >>>>> I think we should call LogBlockedWalRecordInfo() inside of the inner >>>>> while loop rather than at the beginning of >>>>> ResolveRecoveryConflictWithVirtualXIDs(). In lock conflict cases, the >>>>> startup process waits until 'ltime', then enters >>>>> ResolveRecoveryConflictWithVirtualXIDs() after reaching 'ltime'. >>>>> Therefore, it makes sense to call LogBlockedWalRecordInfo() at the >>>>> beginning of ResolveRecoveryConflictWithVirtualXIDs(). However, in >>>>> snapshot and tablespace conflict cases (i.g. >>>>> ResolveRecoveryConflictWithSnapshot() and >>>>> ResolveRecoveryConflictWithTablespace()), it enters >>>>> ResolveRecoveryConflictWithVirtualXIDs() without waits and waits for >>>>> reaching ‘ltime’ inside of the inner while look. So the above >>>>> condition could always be false. >>>> That would make the information being displayed after >>>> max_standby_streaming_delay is reached for the multiple cases you just >>>> described. >>> Sorry, it should be deadlock_timeout, not max_standby_streaming_delay. >>> Otherwise, the recovery conflict log message is printed when >>> resolution, which seems not to achieve the original purpose. Am I >>> missing something? >> Ok, I understand where the confusion is coming from. >> >> Indeed the new version is now printing the recovery conflict log message >> during the conflict resolution (while the initial intention was to be >> warned as soon as the replay had to wait). >> >> The advantage of the new version is that it would be consistent across >> all the conflicts scenarios (if not, we would get messages during the >> resolution or when the replay started waiting, depending of the conflict >> scenario). >> >> On the other hand, the cons of the new version is that we would miss >> messages when no resolution is needed (replay wait duration < >> max_standby_streaming_delay), but is that really annoying? (As no >> cancellation would occur) >> >> Thinking about it, i like the new version (being warned during the >> resolution) as we would get messages only when cancelation will occur >> (which is what the user might want to avoid, so the extra info would be >> useful). >> >> What do you think? > Hmm, I think we print the reason why backends are canceled even of as > now by ProcessInterrupts(). With this patch and related patches you > proposed on another thread, the startup process reports virtual xids > being interrupted, the reason, and LSN of blocked WAL, then processes > will also report its virtual xid and reason. Therefore, the new > information added by these patches is only the LSN of blocked WAL. That's completely right, let's come back to the original intention of this patch (means, don't wait for the conflict resolution to log messages). I'll submit a new version once updated. Thanks! Bertrand