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 1uRBbl-008C7Y-MW for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Jun 2025 15:18:49 +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 1uRBbj-0013sy-Bs for pgsql-hackers@arkaria.postgresql.org; Mon, 16 Jun 2025 15:18:48 +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 1uRBbj-0013sq-06 for pgsql-hackers@lists.postgresql.org; Mon, 16 Jun 2025 15:18:47 +0000 Received: from mail-il1-x136.google.com ([2607:f8b0:4864:20::136]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uRBbh-002Ktu-2w for pgsql-hackers@lists.postgresql.org; Mon, 16 Jun 2025 15:18:46 +0000 Received: by mail-il1-x136.google.com with SMTP id e9e14a558f8ab-3ddd38ee5b8so41901685ab.1 for ; Mon, 16 Jun 2025 08:18:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1750087125; x=1750691925; darn=lists.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=aseySIDQwet4aFThsCLKh0+s6MNKnYZ2pWB0WL1qpw8=; b=HmHeuuyJLDX6KIWRXZoWB485OhZJJBkQoNcfdD15RF7WGEww3PoQtGfUsyvpCIs5JL KbZWNeJhQK6Um+1w93aZxQ4at09oiJfVhalI8PfPqHm57OY2KDvtrlNH6YLL2czReTa7 14DL93sj+pf0eiRjBi6fIq8eWUHhuKKncqKPsNcw4i3O2xqp4h2J7I1U752RXMTmO3js bltZWTQljJYxqrAtm8OSJX/6yH/eFjtBrzNo/y7fdLsF/fQsosReSHvoIZCin7CHQJfC 14IRd17e/2HHZXaZ2lEiQ9jZy6XvLJEb8MAW6ltgp10LL+H/CSaUBR61oDxIPPM29HKK Ss3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1750087125; x=1750691925; 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=aseySIDQwet4aFThsCLKh0+s6MNKnYZ2pWB0WL1qpw8=; b=LWblrZK6cs5TBxzTPj7ywTByJnhZ7ePHMgBLBCkFWsAOFACMH7NYD65AhkHC6VU3Vv u5Egf4CrXpijfHxf1OOnYvkAUzJtC2M5x5QdROGszTx5nR1ME/lnf/x4c1kQDtqYsoRX tAKEy2C2mdGfDiJPGn9XEhqVWnSyXhMdzb6ssLZ64JDgD58fy7quRPfg2X633vyZJ26f h7A+a9XNDE7lO2FlszVDYtKWBnye4BWh9yKsvWDxUc2od63Hud6JpIv9pNndWvSGz5Nf nYvxSL10626r3FJYA0+W3B7pQ33q8a9qwORw5OUr/buGo/fdj8czOU3dT8u7p5R6DypW dd6A== X-Forwarded-Encrypted: i=1; AJvYcCX4wTPy/6vTrOX0M6XfxIXH9EKiDnrhYa360d53tIDccQ4FOg8PtyW70UZshWRWafcOc3SBtQCdcEy43opE@lists.postgresql.org X-Gm-Message-State: AOJu0YzZxTjXXQrQu0197vp9vP8IpMhdBR5aF+Txtp5aBlni7wEaDgm/ vA7jN8ofn6CnbD9m4MRd8/kb/dpjzU2RQI/QcjWOjys8nEA4eJNIwsA2 X-Gm-Gg: ASbGncsIYS0KBqUlS/s4e48LrWWE9N0kqcznc6uJMkQFEuGH6msmpIrU4lQvELCMm3J 738YFCm795RbXIrkziaAzfZfgqKfHriAvTmdUnUwxMX4/i/IHuJDvOvp9r/UjHnzgcKQbRRDSNO LRLG+d77nn4XaQyQSd6K2TJZlElarIQ0Z+wZ6j2paKVIFTDfoL1ZcbGApmDoUVnyU0/g5qKGJNk baH333x8lRDwIfK9fzppOeZDI5AKJmwqjNYnuM6fWv2/DNNiomPyaP033bQA+5B1rbNH66TFIGh wJoXjZvSWCxp/CMj/DdL3mRC1T7c8p+s/OxlLpUOl9BcvU8H5rTSmpSTauUZP4mZpK64lHprHW1 XC3Lrhpv5kF8tkPtwDbQhZhqchYZ80FPgYodVpf5X7wRyDWQVm/TitWahp8OKn40= X-Google-Smtp-Source: AGHT+IF5xVk4QJKjoyiEUGFavPzREC+NSDVke6QxnkO4TVW4sl46pMbEp5ZRC0FnXYDRxpZ33sxGzA== X-Received: by 2002:a05:6e02:2401:b0:3dd:f3e1:2899 with SMTP id e9e14a558f8ab-3de07c3718amr117340005ab.2.1750087123726; Mon, 16 Jun 2025 08:18:43 -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-50149b9d485sm1775494173.43.2025.06.16.08.18.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Jun 2025 08:18:43 -0700 (PDT) Date: Mon, 16 Jun 2025 10:18:41 -0500 From: Nathan Bossart To: Christoph Berg Cc: Laurenz Albe , Fujii Masao , Andres Freund , PostgreSQL Hackers Subject: Re: CHECKPOINT unlogged data Message-ID: References: <086ab9ad5a2c06eb16f6f4e50a04764ba6fafd1b.camel@cybertec.at> 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 Mon, Jun 16, 2025 at 04:36:59PM +0200, Christoph Berg wrote: > I spent some time digging through the code, but I'm still not entirely > sure what's happening. There are several parts to it: > > 1) the list of buffers to flush is determined at the beginning of the > checkpoint, so running a 2nd FLUSH_UNLOGGED checkpoint will not make > the running checkpoint write these > > 2) running CHECKPOINT updates the checkpoint flags in shared memory so > I think the currently running checkpoint picks "MODE FAST" up and > speeds up. (But I'm not entirely sure, the call stack is quite deep > there.) > > 3) running CHECKPOINT (at least when waiting for it) seems to actually > start a new checkpoint, so FLUSH_UNLOGGED should still be effective. > (See the code arount "start_cv" in checkpointer.c) > > Admittedly, adding these points together raises some question marks > about the flag handling, so I would welcome clarification by someone > more knowledgeable in this area. I think you've got it right. With CHECKPOINT_WAIT set, RequestCheckpoint() will wait for a new checkpoint to start, at which point we know that the new flags have been seen by the checkpointer. If an immediate checkpoint is pending, CheckpointWriteDelay() will skip sleeping in the currently-running one, so the current checkpoint will be "upgraded" to immediate in some sense, but IIUC there will still be another immediate checkpoint after it completes. But AFAICT it doesn't pick up FLUSH_UNLOGGED until the next checkpoint begins. Another thing to note is what I mentioned earlier: + Note that the server may consolidate concurrently requested checkpoints or + restartpoints. Such consolidated requests will contain a combined set of + options. For example, if one session requested an immediate checkpoint and + another session requested a non-immediate checkpoint, the server may combine + these requests and perform one immediate checkpoint. -- nathan