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 1u19yr-00F8Wr-O7 for pgsql-hackers@arkaria.postgresql.org; Sat, 05 Apr 2025 20:19:06 +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 1u19xs-002iDK-3z for pgsql-hackers@arkaria.postgresql.org; Sat, 05 Apr 2025 20:18:04 +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 1u19xr-002iD8-O8 for pgsql-hackers@lists.postgresql.org; Sat, 05 Apr 2025 20:18:04 +0000 Received: from lahtoruutu.iki.fi ([2a0b:5c81:1c1::37]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1u19xp-003AFU-15 for pgsql-hackers@lists.postgresql.org; Sat, 05 Apr 2025 20:18:02 +0000 Received: from [192.168.1.112] (iptv-hkibng21-58c090-167.dhcp.inet.fi [88.192.144.167]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: hlinnaka) by lahtoruutu.iki.fi (Postfix) with ESMTPSA id 4ZVRbz2vp3z49Q7C; Sat, 5 Apr 2025 23:17:51 +0300 (EEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1743884272; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QStOMev9d+W4KOPw+aTahPrBjjO4ntTcr4pimCm/Y+8=; b=tRtfiR9EjjmkWeC7oy7p9mU1bptkDFAagiyIs3vXTXxel61ouDC1nlIfBokDOcXTByTj8U CJHsjOcNGsb2ByDpSqriZhFaO/ITd7SVHiQqgJKt5wq4cSiH1dlI5gHDLcbH8Z2TzVl6Fj wmIUWk2xo2wrDmBUaTwPeGKlaK4IhRYqgmkuOFikVj0/DpJl5sR0+sQQXn6IkguKsR86BN V9sCDVxHCrdesLlGKaZDKQyhfU8gZc1vjLmaeiA35NPURdX8yHx2Kpo+CXq04Hp2ULOy4d a0zzH+WBmUga2bisXcLhAcOXcDyHVJid+qx7L93ZE/1BUr55fQgKSm7kpardyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=iki.fi; s=lahtoruutu; t=1743884272; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QStOMev9d+W4KOPw+aTahPrBjjO4ntTcr4pimCm/Y+8=; b=PmU8BdDW+a373wm+w/SGzWZD22TJJZMEdtPBwcEO+cXDdjm0Ww6DFB7KMBc+8G9Lf7SOzf Ta/7XUVlAP20wfMxcWqhFXX0XKknzmQCz6K8WBiWlxmzlPhGDEsikmc/V2YUJzIJGykoXr 1JEFvK2XUHgSGEXleMVwH6B1lBRZu5f2OPNtvaBgRA16dEbsugZzOg/g6xusHXkpsERYdX wwuTWrbaDbVCalWc6ZR+ZsqopFXXw1HcAlTFCjH5A/TcVD3jJuWgIwAADu8ewvxZHmaoFY Y7i2VIrtrQ9/qGCSRupL/B0ZCkdA80JFVoL92LtnYSPAnbXLn9tOtBgFjKozEg== ARC-Seal: i=1; s=lahtoruutu; d=iki.fi; t=1743884272; a=rsa-sha256; cv=none; b=XXC4e9G8UvZx+f22XCp8IfGDOoHYFpFhXb9+1kWiElH66fOkeleTcmiSLIVfHYH/av8K8V 4GWi1KkJEoPkQGrPBX9GuG3s/FU56GfwM6wgHKMWqMyLf7ZCt7WkEvihO/9taf3L3vn9gU SLUXMElM9m3CIB94jz0t5jyz3hCZ3Va18dMrsmD4qgPCUI3nywopERGg5ExYCtwBn8JdT9 N8z3xYA90hCAJ+ieY6/OBp+SEEywi68TvRDmR50SPeKkJSF44veHAFTWguXgiLnNWGXsan a8lrosPKrQBOo8fPAJxpcWI2h4N/t5HcYZwsGQLTET2YDgwws3zxolwgYsFx/w== ARC-Authentication-Results: i=1; ORIGINATING; auth=pass smtp.auth=hlinnaka smtp.mailfrom=hlinnaka@iki.fi Message-ID: <6f9828f5-e582-4eeb-a781-2d8dc92dff04@iki.fi> Date: Sat, 5 Apr 2025 23:17:50 +0300 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: In-placre persistance change of a relation To: Kyotaro Horiguchi Cc: michael@paquier.xyz, nathandbossart@gmail.com, postgres@jeltef.nl, smithpb2250@gmail.com, vignesh21@gmail.com, jakub.wartak@enterprisedb.com, stark.cfm@gmail.com, barwick@gmail.com, jchampion@timescale.com, pryzby@telsasoft.com, tgl@sss.pgh.pa.us, rjuju123@gmail.com, jakub.wartak@tomtom.com, pgsql-hackers@lists.postgresql.org, bharath.rupireddyforpostgres@gmail.com, Thom Brown References: <20241031.170130.530606308716813197.horikyota.ntt@gmail.com> <1f201ea8-b1e3-4606-9525-c5817e651cda@iki.fi> <20241105.132526.317017969504645384.horikyota.ntt@gmail.com> <20241227.172502.1469028835873784534.horikyota.ntt@gmail.com> Content-Language: en-US From: Heikki Linnakangas In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 05/04/2025 00:29, Thom Brown wrote: > On Fri, 27 Dec 2024 at 08:26, Kyotaro Horiguchi wrote: >> >> Hello. This is the updated version. >> >> (Sorry for the delay; I've been a little swamped.) >> >> - Undo logs are primarily stored in a fixed number of fixed-length >> slots and are spilled into files under some conditions. >> >> The number of slots is 32 (ULOG_SLOT_NUM), and the buffer length is >> 1024 (ULOG_SLOT_BUF_LEN). Both are currently non-configurable. >> >> - Undo logs are now used only during recovery and no longer involved >> in transaction ends for normal backends. Pending deletes for aborts >> have been restored. >> >> - Undo logs are stored on a per-Top-XID basis. >> >> - RelationPreserverStorate() is no longer modified. >> >> In this version, in the part following the introduction of orphan >> storage prevention, the restriction on prepared transactions >> persisting beyond server crashes (i.e., the prohibition) has been >> removed. This is because handling for such cases has been reverted to >> pendingDeletes. >> >> Let me know if you have any questions or concerns. > > I just went to give this a test drive, but HEAD has drifted too far, > at least for 0017 to apply. Could you please rebase and make the > necessary modifications? I had a quick look a this latest version now, up to "v36-0005-Prevent-orphan-storage-files-after-server-crash.patch" (because I'm very interested in that, but not in the rest of the patches). Sorry I haven't gotten around to it earlier. Overall I'm pretty happy with the design. The main thing that's now missing is documentation. The main SGML docs should surely have a section on the UNDO log. A new README to describe how modules should use the undo log etc. would probably also be in order. Off the top of my head, some subtle high-level things that should be explained somewhere: - The UNDO log is only used to clean up after crash of a relation creation. It is *not* used for aborting or crash recovery of data, like on most systems. As a result, it's not as performance critical as you might think. - The UNDO log is not a single sequential log like on many other systems. One way to think about it is that it's a per-transaction file, with a cache in shared memory for performance. - The UNDO log is not used to handle controlled aborts, only for cleanup after a crash. - What happens if you fail to process the UNDO log for some reason? Some storage files are leaked. Is that still considered OK, i.e. is the UNDO log a nice-to-have, or are there some more serious consequences? - The interaction between REDO and UNDO. Every record inserted to the UNDO log of a transaction is WAL-logged in the REDO log. The undo log is like data file in that sense. Writing to the undo log follows the usual "WAL-before-write" rule: the WAL is flushed before the corresponding undo log entry is written to disk. (Is that true? I'm not 100% sure) - When a new relation is created, do you flush the WAL before creating the file? Or is there still a small window where it can leak, if the file creation makes it to disk before crash but the undo log (or the WAL record of the undo log entry) does not? Have you done any performance testing of this? By "this" I mean the overhead of the undo-logging on create/drop table. -- Heikki Linnakangas Neon (https://neon.tech)