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 1sGqpb-000I5V-5c for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Jun 2024 02:01:51 +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 1sGqpZ-0010dL-Hb for pgsql-hackers@arkaria.postgresql.org; Tue, 11 Jun 2024 02:01:50 +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 1sGqpZ-0010dD-6k for pgsql-hackers@lists.postgresql.org; Tue, 11 Jun 2024 02:01:50 +0000 Received: from mail-io1-xd2b.google.com ([2607:f8b0:4864:20::d2b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sGqpT-000ikU-B7 for pgsql-hackers@postgresql.org; Tue, 11 Jun 2024 02:01:48 +0000 Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-7eb85e80661so69687039f.1 for ; Mon, 10 Jun 2024 19:01:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718071302; x=1718676102; darn=postgresql.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=YDEi7UpKZJEjTl2kUp4ltW6HnogIQyYPGeiKDi7qopA=; b=Psg1PJcAjzotgx1zE/B5FPAPMvl1h5QquXXnpXzHCoKuZL/Rmv5JToRriy9GPe6wNn /Ldcrpt7Nsebw4ClwiW4yf9fd3DoJtro8mxywAUZvYQhCraCv0GN9WiVPsl7pQbDmRdI Z7EHWot9U3/TeQWHJcABKDu5VAPZDTDFRpUB3qVWFiufmfIM+OnMjDf55zjZke9ElBOy X+o/20VX6UkZPyXJ8s8myoy7UjwWBcm5eCzrj7T115L2Qx+fsX9pv3RL99ar5fCDAgo6 Sj1hzfR0j4aH7/LfQT0TdecnmLZfyXExqEhnskOTQeyyChtH4g1h3zec8BFYZ+VwnDgW VuCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718071302; x=1718676102; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=YDEi7UpKZJEjTl2kUp4ltW6HnogIQyYPGeiKDi7qopA=; b=K022W5UYqpFLi3VYi0m5j1LdN3uqm4WMVrtnFSZemUnWd/a+1K2fsGtcZP08h14h1I Cx1+lqTeCeS+72vHF7lI/e02jst2QWsevMkwjQkAa5nSaABxiTXtZA2mNj8UR166u8SH 2igUm81wakam0SqfTF+yN2W6O42pwPDPhiUeQ3/CtAPRzq1AbcmxJMpI5lAChC1POGRV ygrDjhuuE7275Y6X+oLv4hx/HabNQgozS3m5FxVbOAZM8f9r2eHUp6mPKrIziYW0NFqg yE1k2sZ/95J18j3XY/sgFkovDG66sTRaJLR1tgpruPCtJVjTKkGE0oeVJBjmvZY+8FGK 2u7Q== X-Forwarded-Encrypted: i=1; AJvYcCXQOwXNJQQBycc7F/Lv0OcOZUvTmKkD73OidsoiuS9jCEar6M4TQrtjtjnvFK20vg2WmTwHvfUtKqTqzhOsxCRCuJUNkJFZlIjTw55m X-Gm-Message-State: AOJu0Yw5Px3Wk6jaEHBGsl0jgzhIHEq70dloj5kNm3RlfX5MNhk66qXN iptWdQxBQ5YLSeXQjfJ90er3ersQkNVmM2B2jOdFShu83WoLDEI+ X-Google-Smtp-Source: AGHT+IHePsKLbBHgVZCbqeuFv2lrVVuTmPn8qyR32naggEZnOVZGBAnSKw/9Ae1aqk+O9mOK0SfKxQ== X-Received: by 2002:a05:6602:14d0:b0:7eb:7bc9:7fc5 with SMTP id ca18e2360f4ac-7eb7bc981c6mr687816239f.19.1718071302185; Mon, 10 Jun 2024 19:01:42 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id 8926c6da1cb9f-4b920261b66sm646726173.133.2024.06.10.19.01.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 19:01:41 -0700 (PDT) Date: Mon, 10 Jun 2024 21:01:40 -0500 From: Nathan Bossart To: Matthias van de Meent Cc: Dilip Kumar , Ranier Vilela , pgsql-hackers@postgresql.org Subject: Re: use CREATE DATABASE STRATEGY = FILE_COPY in pg_upgrade Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Jun 07, 2024 at 11:10:25AM +0200, Matthias van de Meent wrote: > My primary concern isn't the IO, but the O(shared_buffers) that we > have to go through during a checkpoint. As I mentioned upthread, it is > reasonably possible the new cluster is already setup with a good > fraction of the old system's shared_buffers configured. Every > checkpoint has to scan all those buffers, which IMV can get (much) > more expensive than the IO overhead caused by the WAL_LOG strategy. It > may be a baseless fear as I haven't done the performance benchmarks > for this, but I wouldn't be surprised if shared_buffers=8GB would > measurably impact the upgrade performance in the current patch (vs the > default 128MB). I did a handful of benchmarks on an r5.24xlarge that seem to prove your point. The following are the durations of the pg_restore step of pg_upgrade: * 10k empty databases, 128MB shared_buffers WAL_LOG: 1m 01s FILE_COPY: 0m 22s * 10k empty databases, 100GB shared_buffers WAL_LOG: 2m 03s FILE_COPY: 5m 08s * 2.5k databases with 10k tables each, 128MB shared_buffers WAL_LOG: 17m 20s FILE_COPY: 16m 44s * 2.5k databases with 10k tables each, 100GB shared_buffers WAL_LOG: 16m 39s FILE_COPY: 15m 21s I was surprised with the last result, but there's enough other stuff happening during such a test that I hesitate to conclude much. > I'll note that the documentation for upgrading with pg_upgrade has the > step for updating postgresql.conf / postgresql.auto.conf only after > pg_upgrade has run already, but that may not be how it's actually > used: after all, we don't have full control in this process, the user > is the one who provides the new cluster with initdb. Good point. I think it's clear that FILE_COPY is not necessarily a win in all cases for pg_upgrade. >>> If such a change were implemented (i.e. no checkpoints for FILE_COPY >>> in binary upgrade, with a single manual checkpoint after restoring >>> template1 in create_new_objects) I think most of my concerns with this >>> patch would be alleviated. >> >> Yeah, I think that's a valid point. The second checkpoint is to ensure >> that the XLOG_DBASE_CREATE_FILE_COPY never gets replayed. However, for >> binary upgrades, we don't need that guarantee because a checkpoint >> will be performed during shutdown at the end of the upgrade anyway. > > Indeed. It looks like pg_dump always uses template0, so AFAICT we don't even need the suggested manual checkpoint after restoring template1. I do like the idea of skipping a bunch of unnecessary operations in binary upgrade mode, since it'll help me in my goal of speeding up pg_upgrade. But I'm a bit hesitant to get too fancy here and to introduce a bunch of new "if (IsBinaryUpgrade)" checks if the gains in the field won't be all that exciting. However, we've already sprinkled such checks quite liberally, so maybe I'm being too cautious... -- nathan