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 1qG1Z7-0005Ah-3s for pgsql-hackers@arkaria.postgresql.org; Sun, 02 Jul 2023 18:12:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1qG1Z5-0001B7-74 for pgsql-hackers@arkaria.postgresql.org; Sun, 02 Jul 2023 18:12:51 +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 1qG1Z4-0001Ax-Th for pgsql-hackers@lists.postgresql.org; Sun, 02 Jul 2023 18:12:50 +0000 Received: from mail-wr1-x436.google.com ([2a00:1450:4864:20::436]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qG1Z1-001f41-K7 for pgsql-hackers@lists.postgresql.org; Sun, 02 Jul 2023 18:12:48 +0000 Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-313fb7f0f80so4120055f8f.2 for ; Sun, 02 Jul 2023 11:12:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; t=1688321565; x=1690913565; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=mYo2tsCrc+8N9KB5iIHICVzBKFMiWhF2p2VMuhMkav8=; b=PQIb38yvJKRkif+UNsHDhfnXo0XRn0IL9cXX6JQPiBNpE+OVWKogzHKHUKVLQSBjUo 6OpjiM576OAYTOLyMxZDY5X6I1NOnJMab2rVdc4XWLvXEytx9uiPFIr7lzhoIjSprbnI JXtr9mJEJKjKrrAcklx9tbYEFGb+5yNCscle1TZVYgMx7BhtSu/qs+7XZD+fJ4f4EObI /hGZIGnyCKFlfXyb7Mj8IMzV9LDnLyzu6kJ5jH6K9RdUIMlqrLdXDZLAS0tUwoeEta49 oonLbQGC9YFjRiPfH7HDjAMwZId6zvKbk3P2Ia6MzyIBH//0oTdaXbEoRw5+ulpdC4St N0SQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688321565; x=1690913565; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=mYo2tsCrc+8N9KB5iIHICVzBKFMiWhF2p2VMuhMkav8=; b=KneFfgtwyavjSToKFpU4oRjhUUjovGOhl0k1ep2n7+ymVpHgKTYAZkVV8I5QumMedj 5TzoYlvuc5/cxtuqiglwds0dZSxhAtEoRTYRClpDConFrVTDR1s0yxuJdzABzEZJVi/m sdOvCWx9dkzrBHaohxpPEEqMnjSVnuMl5vRcv+FT1PnoAlCciFMth4VVonwYdS5qRdqV 1Ut+I7h7o2ygRBkPRc1L3Jq2y2HG0EmfsXqoWc5PZoLh4DOqesLhmzMXqrOkkOfQ8bpu Y/P9a+lPwglnPRrSiow9Jd+e8mQx3EXcTt8tEqcCi4OuBcvsxo2iTRZXZWQR8x23/sp/ RZHA== X-Gm-Message-State: ABy/qLazEwvfSYE70eUP5I6FW/SlHn2PyM3WtJASdmGmNVdV4gsBRJc6 0GK3jxkCx1U0qZ0ImsbbS8himw== X-Google-Smtp-Source: APBJJlFcmdN3qSFYqb1XeUZlcnPK9kcHCL43jspySi340Hq+MqQRkk5x+4i7w5yc7ZElCrQGPvwE1g== X-Received: by 2002:a5d:6acc:0:b0:313:e715:3260 with SMTP id u12-20020a5d6acc000000b00313e7153260mr5881010wrw.48.1688321564536; Sun, 02 Jul 2023 11:12:44 -0700 (PDT) Received: from [10.137.0.17] (ip-86-49-228-220.bb.vodafone.cz. [86.49.228.220]) by smtp.gmail.com with ESMTPSA id u18-20020adfeb52000000b003113943bb66sm23539657wrn.110.2023.07.02.11.12.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 02 Jul 2023 11:12:43 -0700 (PDT) Message-ID: <10616819-5333-e35e-32c8-c0d138542167@enterprisedb.com> Date: Sun, 2 Jul 2023 20:12:42 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.12.0 Subject: Re: possible bug in handling of contrecords in dd38ff28ad (Fix recovery_prefetch with low maintenance_io_concurrency) Content-Language: en-US To: Thomas Munro Cc: PostgreSQL Hackers References: <6a1df56e-4656-b3ce-4b7a-a9cb41df8189@enterprisedb.com> From: Tomas Vondra In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 7/2/23 04:09, Thomas Munro wrote: > On Sun, Jul 2, 2023 at 1:40 AM Tomas Vondra > wrote: >> I think there's some sort of bug in how dd38ff28ad deals with >> contrecords. Consider something as simple as >> >> pgbench -i -s 100 >> >> and then doing pg_waldump on the WAL segments, I get this for every >> single one: >> >> pg_waldump: error: error in WAL record at 0/1FFFF98: missing >> contrecord at 0/1FFFFE0 >> >> This only happens since dd38ff28ad, and revert makes it disappear. >> >> It's possible we still have some issue with contrecords, but IIUC we >> fixed those. So unless there's some unknown one (and considering this >> seems to happen for *every* WAL segment that's hard to believe), this >> seems more like an issue in the error detection. > > Yeah. That message is due to this part of dd38ff28ad's change: > > Also add an explicit error message for missing contrecords. It was a > bit strange that we didn't report an error already, and became a latent > bug with prefetching, since the internal state that tracks aborted > contrecords would not survive retrying, as revealed by > 026_overwrite_contrecord.pl with this adjustment. Reporting an error > prevents that. > > We can change 'missing contrecord' back to silent end-of-decoding (as > it was in 14) with the attached. Here [1] is some analysis of this > error that I wrote last year. The reason for my hesitation in pushing > a fix was something like this: > > 1. For pg_waldump, it's "you told me to decode only this WAL segment, > so decoding failed here", which is useless noise > 2. For walsender, it's "you told me to shut down, so decoding failed > here", which is useless noise > 3. For crash recovery, "I ran out of data, so decoding failed here", > which seems like a report-worthy condition, I think? > > When I added that new error I was thinking about that third case. We > generally expect to detect the end of WAL replay after a crash with an > error ("invalid record length ...: wanted 24, got 0" + several other > possibilities), but in this rare case it would be silent. The effect > on the first two cases is cosmetic, but certainly annoying. Perhaps I > should go ahead and back-patch the attached change, and then we can > discuss whether/how we should do a better job of distinguishing "user > requested artificial end of decoding" from "unexpectedly ran out of > data" for v17? > Yeah, I think that'd be sensible. IMHO we have a habit of scaring users with stuff that might be dangerous/bad, but 99% of the time it's actually fine and perhaps even expected. It's almost as if we're conditioning people to ignore errors. regards -- Tomas Vondra EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company