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 1qcIQf-00Ej9H-H1 for pgsql-hackers@arkaria.postgresql.org; Sat, 02 Sep 2023 04:40:13 +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 1qcIPe-002tLA-C5 for pgsql-hackers@arkaria.postgresql.org; Sat, 02 Sep 2023 04:39:10 +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 1qcIPe-002tL1-0V for pgsql-hackers@lists.postgresql.org; Sat, 02 Sep 2023 04:39:09 +0000 Received: from mail-oo1-xc2b.google.com ([2607:f8b0:4864:20::c2b]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1qcIPZ-002TQe-JA for pgsql-hackers@lists.postgresql.org; Sat, 02 Sep 2023 04:39:09 +0000 Received: by mail-oo1-xc2b.google.com with SMTP id 006d021491bc7-5732481b22eso1739195eaf.3 for ; Fri, 01 Sep 2023 21:39:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1693629543; x=1694234343; darn=lists.postgresql.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=POn8USK6NJtK1bd7HpFpTh9h+jjMfWinsnlbtmIAKwQ=; b=ncwEhSG+aYCZBIA+TDOVsu1p2dXXFDLXTpGQaX1sXZXVHTIXlh1FC622XPctUDIjSV NdgVIIB690yzTizQihP18o4RKCO7nVRhA6ouCKwP2IVL43cS7Z05yz+EEKNqXMv6Bg2u bkOB7LvQnhGUZO+n+7bIr5YKRCPcmLHHY/iAUyJZohcotNY/33P3wfIJjvkYpgk1A9yH hDKsEJgh51cbwWJX15s8k+DnzsAwVfGepppS97HvRmDY5kHP9AY2DcUmr4qzuGdlCwLh 9x5IXfr3jRSKGiyeXJK4HxI53rzQCZ8y9nTD2eRzk1/I3LRWZLOmUrMReQTGUarHk/Zv NeNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693629543; x=1694234343; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=POn8USK6NJtK1bd7HpFpTh9h+jjMfWinsnlbtmIAKwQ=; b=QePgwiMLNQ0RT+IcIdcpDNevZI4XEXAVWqLq9MOq9mV6S4jiW+OXx+P3OGc0u836EU mSefLpMYFmondiLx4xVkdM2IqVhsTM7ru1UWAGik+Gr5wCjYPSsWTRSSFsYmzBD97bVf 10gVjbv6v2UkcVgPTZgMRnkulRq4zezyxRBVJ4qxLq7ZEvo08zLnla8CmuuNt/vr/sAl Gs2rUX+ZQP/BIh7y8oAMDjGAs1CPaTFQmmrEL7WnoAcJf4yy+GEX0iiF63kJhlfXlsMX qmZPz7JRwRcNQY6b9VMg08DOSQeVQjkuFhEY0NvWqkS9t0RGj5xAJ82NhglDaPeD7V83 m8kw== X-Gm-Message-State: AOJu0Yy1Sxsoh5NuLE9fNH6iJcISVLvrew8QwAFTXfow1NzI/QxBNHD1 eDxaWf5kB3/qRDZA9BJPQwpYTBVS+OB1xft4PgkZdkn6iXYt/w== X-Google-Smtp-Source: AGHT+IFvvYFT4neTNTk8rXWbAAlc3pkQ1LTvC3H4nGapgC+YJoG+Lb+O5IZcWPe96Nwi3bQCe48RtNBL4/kyQvZm/Vc= X-Received: by 2002:a4a:840f:0:b0:571:28d5:2c71 with SMTP id l15-20020a4a840f000000b0057128d52c71mr3434519oog.2.1693629542748; Fri, 01 Sep 2023 21:39:02 -0700 (PDT) MIME-Version: 1.0 From: Amit Kapila Date: Sat, 2 Sep 2023 10:08:51 +0530 Message-ID: Subject: Impact of checkpointer during pg_upgrade To: PostgreSQL Hackers , Sawada Masahiko , Dilip Kumar , "Hayato Kuroda (Fujitsu)" , vignesh C , =?UTF-8?B?SG91LCBaaGlqaWUv5L6vIOW/l+adsA==?= , Peter Smith Content-Type: text/plain; charset="UTF-8" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk During pg_upgrade, we start the server for the old cluster which can allow the checkpointer to remove the WAL files. It has been noticed that we do generate certain types of WAL records (e.g XLOG_RUNNING_XACTS, XLOG_CHECKPOINT_ONLINE, and XLOG_FPI_FOR_HINT) even during pg_upgrade for old cluster, so additional WAL records could let checkpointer decide that certain WAL segments can be removed (e.g. say wal size crosses max_slot_wal_keep_size_mb) and invalidate the slots. Currently, I can't see any problem with this but for future work where we want to migrate logical slots during an upgrade[1], we need to decide what to do for such cases. The initial idea we had was that if the old cluster has some invalid slots, we won't allow an upgrade unless the user removes such slots or uses some option like --exclude-slots. It is quite possible that slots got invalidated during pg_upgrade due to no user activity. Now, even though the possibility of the same is less I think it is worth considering what should be the behavior. The other possibilities apart from not allowing an upgrade in such a case could be (a) Before starting the old cluster, we fetch the slots directly from the disk using some tool like [2] and make the decisions based on that state; (b) During the upgrade, we don't allow WAL to be removed if it can invalidate slots; (c) Copy/Migrate the invalid slots as well but for that, we need to expose an API to invalidate the slots; (d) somehow distinguish the slots that are invalidated during an upgrade and then simply copy such slots because anyway we ensure that all the WAL required by slot is sent before shutdown. Thoughts? [1] - https://www.postgresql.org/message-id/TYAPR01MB58664C81887B3AF2EB6B16E3F5939%40TYAPR01MB5866.jpnprd01.prod.outlook.com [2] - https://www.postgresql.org/message-id/flat/CALj2ACW0rV5gWK8A3m6_X62qH%2BVfaq5hznC%3Di0R5Wojt5%2Byhyw%40mail.gmail.com -- With Regards, Amit Kapila.