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 1v684O-00HIir-ML for pgsql-admin@arkaria.postgresql.org; Tue, 07 Oct 2025 13:49:36 +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 1v684M-0000A4-46 for pgsql-admin@arkaria.postgresql.org; Tue, 07 Oct 2025 13:49:35 +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 1v684L-000096-Nf for pgsql-admin@lists.postgresql.org; Tue, 07 Oct 2025 13:49:34 +0000 Received: from mail-wm1-x32c.google.com ([2a00:1450:4864:20::32c]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1v684K-000rre-1E for pgsql-admin@lists.postgresql.org; Tue, 07 Oct 2025 13:49:34 +0000 Received: by mail-wm1-x32c.google.com with SMTP id 5b1f17b1804b1-46e491a5b96so36295815e9.2 for ; Tue, 07 Oct 2025 06:49:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1759844969; x=1760449769; darn=lists.postgresql.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:from:to:cc:subject:date :message-id:reply-to; bh=QxQtUZ9NO8gNU6q4zCJTDPL3f2jEmgHpk3GRCUvjgoU=; b=FN7NrvqPneRZ2fQcHAxPSUVAUNxE/PVMv++hcbSbU/s/4749Jp+tw/T4VV6UJ8KQLJ W4aA9SkoLUEftG8AS4KodmwBAYTp2YDdM0FE5dg6yHmJVg3+EWPKycqErouwLrTuxBf3 YDOvNrMPLdtOd59Pjmjg2iT4ikt09rRGoP8vQWXVas+RQWUh5R/H/bWrZm0WBpvOJFaM r4zVtMDxESyPqcJQQ6/XlbK3PXZy1lSNFvso9/YUQHq3Tv5y7xszTu2cNZbr5jnpgSAm HxKjGYIqal/zN0Zl58gYvyn9r1Fj9CUBjx6KiuAPrX+OaHn62VQp1td1uiANlzVg7dtw JuDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1759844969; x=1760449769; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:to:from:subject:message-id:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=QxQtUZ9NO8gNU6q4zCJTDPL3f2jEmgHpk3GRCUvjgoU=; b=UiCTZVGu5GdNGfx1XXGJXFOpVBzH+3tvUbnhZwHfmeyVb+deE6gvIxzMUTdbbnyJc8 AHc93QLi51rMTWQH0pO+Sis5Qpqj7AyLQij1JQpsU81DVF4XXiHPac1/x42yNv8uDDC+ w4UX1eey/14V6vwTDPH7WMf0VSmbny526tjM7XZcbKUFnTcSwuqnqW1ymu4gvX/ke1DJ G1Nt1vJ681CZx+f84BHscBgTFFKJngnbpPgzusVLswLnyTDYIAa2pyCUJB7sS68lqERu +r/BPwPaxkl1xAPLi2N1P/qnz8JBZTRRx+k9DpUqJo/xI7o3Qy4I+VkznmslAhppOdA2 5cPQ== X-Forwarded-Encrypted: i=1; AJvYcCVUtsoNYGAtCAStu4uMYoe+RKF7PO8jzpH5zMwCW2LR4cdH3ewXjJG5rpXD4xbBRi+qw8YDD+WVqU0Hvw==@lists.postgresql.org X-Gm-Message-State: AOJu0YyexFj89crbmTgOTa0z+/Zez+9qJqdVu5SDWzKgaO5wIoYi/3j7 GEyN2fEvVSUNo79LL7bjPFE4qlwf+0sd3X14BQz7xpL6zFXR6sWKGAbiStzB6iRyb+8= X-Gm-Gg: ASbGncvIA+LuSOKflc4VuWOxw9JW8hXe+fQ6PttTp6jN+TXqnVqS99qLwFVeEbcKNX+ KKLHtCgzXLg+5gvvuZOGZTNw2RtntQxAUwpIm7/HHDLzSLpVSQLEKNWar4fFwRQ6dDufTdu7j2H ZsgGBk6yUYLzN9xmA2Uv6SzWnA1jv5nzNTNfrL/3eFEtXgk1NympnVc1/rTbzo2uWc9hCHas+kh 9kBlY+Jo85bRskDsNZP7vfV0rER3VevSm+KhX6ZycvhuyuEwIPwcx/x0PLVwJkeLqvKKhWPBPgA +xb5e8HFaggaqDnAVcxHlWIw73Kzbk1KUP0Ci9OpUfnfIibjBwgqqWqpOAEeFSH+qeXgTM0jiAj Y9Q1Hf7YuI1ut/R5V/PC7c2QuJmkMjdB2z4R9YNmiVVjxCqmB+tjj1W26ZwW6eSJszGlcS2j6jz QghA== X-Google-Smtp-Source: AGHT+IEdEpvNJ3LhbHIL83orK51SMnbZCmLUhltllsrSiauErxJBSVlQN0kO2/WWRXxcWAl8oRyyLA== X-Received: by 2002:a05:600c:c162:b0:456:13b6:4b18 with SMTP id 5b1f17b1804b1-46e7114486bmr121898395e9.31.1759844969215; Tue, 07 Oct 2025 06:49:29 -0700 (PDT) Received: from laurenz.albe-K4N0CV00F97414D ([2001:871:70:8028:1318:1a3c:a58d:2b79]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-46e723614c9sm203210125e9.14.2025.10.07.06.49.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Oct 2025 06:49:28 -0700 (PDT) Message-ID: Subject: Re: Effect of COMMIT on WAL-Buffers + Effect of Check pointer. From: Laurenz Albe To: "Subramanian,Ramachandran" , "pgsql-admin@lists.postgresql.org" Date: Tue, 07 Oct 2025 15:49:28 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.56.2 (3.56.2-2.fc42) MIME-Version: 1.0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue, 2025-10-07 at 11:22 +0000, Subramanian,Ramachandran wrote: > Coming from a Db2 =E2=80=93 mainframe world trying to understand Postgres= . > Kindly forgive my ignorance and the somewhat long winded question. =20 > =20 > When a particular transaction TRAN1, inserts/updates/deletes data, > the changes are made to the memory blocks in the Shared Buffer > ( data buffers ) and corresponding Undo and Redo Logs are written > to the Log buffers. While TRAN1 is running , TRAN2 TRAN3 =E2=80=A6. TRAN= 4 > can run concurrently and be writing information tot he WAL-Buffers. There are no undo logs. PostgreSQL doesn't ever undo work. Otherwise, yes. =20 > Let us assume that TRAN1 began at 0000 Hours and at has updated 1 > rows at 0001 Hours. >=20 > Let us further assume for simplicity that TRAN1 TRAN2 TRAN3 and > TRAN4 have updated 1 row each and written 2 WAL-Records each in the > WAL-Buffer BUT NOT issued a COMMIT yet. >=20 > Now at 0002 Hours TRAN4 alone has issued a COMMIT. >=20 > Will all the 8 WAL-Buffer records be written to the WAL files? Yes, unless "wal_writer_delay" has expired first, and the WAL writer process has already written the data. > Obviously TRAN1 2 and 3 are IN-FLIGHT ( un committed ) at 0002 > Hours, while TRAN4 is committed. ( This is how DB2 works . When a > COMMIT is issued by any transaction ALL the log buffers are written > to disk, immaterial of if they are commited or not. There is a BEGIN > Unit of Recovery Log record, a END Unit of Recovery log Record > associated with each transaction . Each Unit of Recovery is an > unique identifier. Every log record that belongs to this Unit of > Recovery ID has this identifier in it. So after a crash, the logs > are scanned forward since the last check point and only those > logrecords with a matching BEGIN UR and END UR are redone, and > those with just a BEGIN UR and no matching END UR are rolled back. In PostgreSQL, *all* the WAL is replayed, even the changes from uncommitted transactions. Nothing is ever rolled back. Instead, PostgreSQL records the status of all transactions in the *commit log*. Changes from transactions that didn't commit simple remain invisible, and the next VACUUM run will clean them up. =20 > Does a COMMIT even cause the ALL the WAL-Buffers to be written to > WAL-Files in Postgres? All the WAL up to and including the COMMIT, yes. > Additionally, after the check pointer externalizes all the comitted > Shared Buffer Data to disk, does it write a check point record to > the WAL-Buffer alone? Yes, and that is flushed to disk. =20 > if the check point information is just written to the WAL-Buffer > by the Check-Pointer background process and before it is copied down > to a file on the disk, Postgres crashes, is this check point not lost ? > Does a Check point record force a WAL-Buffer write to WAL-Files ? Sure. Once a checkpoint is complete, all data it wrote are safely on disk. Yours, Laurenz Albe