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 1rPZda-00CaL2-FE for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Jan 2024 02:57:15 +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 1rPZdY-0015S7-Q9 for pgsql-hackers@arkaria.postgresql.org; Tue, 16 Jan 2024 02:57:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rPZdY-0015Rz-Gk for pgsql-hackers@lists.postgresql.org; Tue, 16 Jan 2024 02:57:12 +0000 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rPZdU-001kGx-U3 for pgsql-hackers@lists.postgresql.org; Tue, 16 Jan 2024 02:57:10 +0000 Received: by mail-ot1-x329.google.com with SMTP id 46e09a7af769-6dde173384aso4767077a34.1 for ; Mon, 15 Jan 2024 18:57:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1705373828; x=1705978628; darn=lists.postgresql.org; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:from:subject:cc:to:message-id:date:from:to:cc:subject :date:message-id:reply-to; bh=JdDsGPHd4Oe4bb15aIoehlWLPoCer0W8qqcmYHOp36I=; b=YtVibBxDOF7dJ9ozS+gGtSNrRsJLjw304IwAK/i9rOz3Zvv2XOEY1q2nPRs2TjgURP qa5RR6ArvdRh/We+zXGyhBayVz7itiCGpHOzvBEoFM4nwe6gacTIGZt188j9DkhMs0E0 8jUWBL5KnGM62Ej7+rkyhaqE4YmMm7IneK1S92tFipIBCzBI+P9K0Qwcww9qIGlAzJU0 yu+dIOme0TXmsHO+h5kXxKy/C0KV5aW9W62cHcZYhYSQ48CXXrWJmj3mFMKTUTJV7Ad9 J0bomYpeibW3A9oH5kcq97pyKfKdIPXKbpn/mXzXlYVLF+qEmwVJeF3fQYPvdY9Onxa7 Dz8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705373828; x=1705978628; h=content-transfer-encoding:mime-version:user-agent:references :in-reply-to:from:subject:cc:to:message-id:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=JdDsGPHd4Oe4bb15aIoehlWLPoCer0W8qqcmYHOp36I=; b=SDwoX6bMKjYvJYuTHvTya31EAvP2OU2NMlwGoUcHr/hPBy2tC4DVcf2lCSI/fYDR1Y vfK12q1M+WUpQay6mWwadXncIc8Dg+zAfDUN60VQ7EmdiUYCjoS2zju1zToWRc1UJdv5 +p2TRiKLuG3tGnwdWhUZ/MAii3J1J8M6G7Oclizoq065ItVewL57LjJ58QBfmCONq+rs /+88/w751j5s7hBDKBNxsDwnjbNuTpzgljobd5lFVtAuoZSdnNGM/i5oPsKKjINSIlFE Ivk2mBhPayuE+60ViTgCfSCeernatpQz+abmRIou1wzwbIs9bAtk8bTTGnTNH1NaWF/w 9hHg== X-Gm-Message-State: AOJu0YybyqbIhZ1M+iRA205DQMtNaKnw3Tx72zooYiOH9S976a59edcP T7lrD925FPZ9zJE2S0Hwtoc= X-Google-Smtp-Source: AGHT+IE1JexO/dRI2WAvMXsZfrBb/yzvKZBYWyuva7YIBPCm3Vh3aaK80cmqpXHBmC6f2Iben/P+rg== X-Received: by 2002:a05:6808:3c4e:b0:3bd:7ddd:18d2 with SMTP id gl14-20020a0568083c4e00b003bd7ddd18d2mr3177299oib.115.1705373828173; Mon, 15 Jan 2024 18:57:08 -0800 (PST) Received: from localhost (KD036014041111.ppp-bb.dion.ne.jp. [36.14.41.111]) by smtp.gmail.com with ESMTPSA id m11-20020a62f20b000000b006daa809584csm8102685pfh.182.2024.01.15.18.57.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 18:57:07 -0800 (PST) Date: Tue, 16 Jan 2024 11:57:03 +0900 (JST) Message-Id: <20240116.115703.2298339297458587094.horikyota.ntt@gmail.com> To: aleksander@timescale.com Cc: pgsql-hackers@lists.postgresql.org, vignesh21@gmail.com, stark.cfm@gmail.com, alvherre@alvh.no-ip.org, pryzby@telsasoft.com, andres@anarazel.de, ashu.coek88@gmail.com, pashkin.elfe@gmail.com, michael@paquier.xyz, bossartn@amazon.com, david@pgmasters.net, peter.eisentraut@2ndquadrant.com, jtc331@gmail.com, robertmhaas@gmail.com Subject: Re: Make mesage at end-of-recovery less scary. From: Kyotaro Horiguchi In-Reply-To: References: <20240111.161816.1259268425616323411.horikyota.ntt@gmail.com> User-Agent: Mew version 6.8 on Emacs 27.2 Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Thank you for the comments. At Fri, 12 Jan 2024 15:03:26 +0300, Aleksander Alekseev wrote in > ``` > + p = (char *) record; > + pe = p + XLOG_BLCKSZ - (RecPtr & (XLOG_BLCKSZ - 1)); > + > + while (p < pe && *p == 0) > + p++; > + > + if (p == pe) > ``` > > Just as a random thought: perhaps we should make this a separate > function, as a part of src/port/. It seems to me that this code could > benefit from using vector instructions some day, similarly to > memcmp(), memset() etc. Surprisingly there doesn't seem to be a > standard C function for this. Alternatively one could argue that one > cycle doesn't make much code to reuse and that the C compiler will > place SIMD instructions for us. However a counter-counter argument > would be that we could use a macro or even better an inline function > and have the same effect except getting a slightly more readable code. Creating a function with a name like memcmp_byte() should be straightforward, but implementing it with SIMD right away seems a bit challenging. Similar operations are already being performed elsewhere in the code, probably within the stats collector, where memcmp is used with a statically allocated area that's filled with zeros. If we can achieve a performance equivalent to memcmp with this new function, then it definitely seems worth pursuing. > ``` > - * This is just a convenience subroutine to avoid duplicated code in > + * This is just a convenience subroutine to avoid duplicate code in > ``` > > This change doesn't seem to be related to the patch. Personally I > don't mind it though. Ah, I'm sorry. That was something I mistakenly thought I had written at the last moment and made modifications to. > All in all I find v28 somewhat scary. It does much more than "making > one message less scary" as it was initially intended and what bugged > me personally, and accordingly touches many more places including > xlogreader.c, xlogrecovery.c, etc. > > Particularly I have mixed feeling about this: > > ``` > + /* > + * Consider it as end-of-WAL if all subsequent bytes of this page > + * are zero. We don't bother checking the subsequent pages since > + * they are not zeroed in the case of recycled segments. > + */ > ``` > > If I understand correctly, if somehow several FS blocks end up being > zeroed (due to OS bug, bit rot, restoring from a corrupted for > whatever reason backup, hardware failures, ...) there is non-zero > chance that PG will interpret this as a normal situation. To my > knowledge this is not what we typically do - typically PG would report > an error and ask a human to figure out what happened. Of course the > possibility of such a scenario is small, but I don't think that as > DBMS developers we can ignore it. For now, let me explain the basis for this patch. The fundamental issue is that these warnings that always appear are, in practice, not a problem in almost all cases. Some of those who encounter them for the first time may feel uneasy and reach out with inquiries. On the other hand, those familiar with these warnings tend to ignore them and only pay attention to details when actual issues arise. Therefore, the intention of this patch is to label them as "no issue" unless a problem is blatantly evident, in order to prevent unnecessary concern. > Does anyone agree or maybe I'm making things up? regards. -- Kyotaro Horiguchi NTT Open Source Software Center