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 1tdqCJ-009v1o-J2 for pgsql-hackers@arkaria.postgresql.org; Fri, 31 Jan 2025 12:32: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 1tdqCI-000E5t-Es for pgsql-hackers@arkaria.postgresql.org; Fri, 31 Jan 2025 12:32:34 +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 1tdqCI-000E5l-3z for pgsql-hackers@lists.postgresql.org; Fri, 31 Jan 2025 12:32:34 +0000 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1tdqCE-002VxP-35 for pgsql-hackers@postgresql.org; Fri, 31 Jan 2025 12:32:33 +0000 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-436281c8a38so13862995e9.3 for ; Fri, 31 Jan 2025 04:32:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cybertec.at; s=google; t=1738326750; x=1738931550; darn=postgresql.org; h=message-id:date:content-id:mime-version:comments:references :in-reply-to:subject:cc:to:from:from:to:cc:subject:date:message-id :reply-to; bh=3Hq3mmsnDcaWpf42j1aNe+tefheRfj1hex0SCXlC8u4=; b=BMDGPZB9v1csbCE0PNa6hlYIKtH6xFsMAdMyzH/L9pFK76ukRBxxMjEjfBoCSeGIPk mFyaI0BRyOEWzf/tk0gOVozvLpJ9bV/tWIehFSy16n+XUVlvvG7zCUgojcpqxlggiwBf pekJJK6tTFi2uSBfqACRuSVomUMSN3ERK1cb3DaVsLWSqfsKUMGbAXfB2lxaD9LhqGcy sSnSpyjvvFNdW1IV35agFUpz9Uwe/0pRXzHM1RdoT4FP/NRta2vGWz+4ku57jsk4uCpP zfM2rkn1jmvtVFzEDucGbUTwrqJzC63f9Y9jkYwHcls7PK7lQyXawODfX0ZWIxTixawM Jh9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1738326750; x=1738931550; h=message-id:date:content-id:mime-version:comments:references :in-reply-to:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3Hq3mmsnDcaWpf42j1aNe+tefheRfj1hex0SCXlC8u4=; b=OzLTEhzUKHyiWCNsQcxxIFWCWW++5NZXIvemrOA61Kvv9zeiajQ6r9YApJq29G0cPb ZF8Ojvy4YMZKL7b5gi8bnwuGV1bUtLtR8Q7VylmEG/HY3AkmeozQypEWevaNZ02anbb+ wXaOrunRhDlia6sGVXgoXX9CUYM8ZCgSz7LstnUcV2LZDDBrS8E/Y2qjqMlsLiIihPum I88wsWya4l0YYYtZypAF9j5/S2jbqfE83OIBi/Cqy5QDZ0qFN4wjqYIMngmpeyq8mO7Y bNFbMHMB6ebhmanvwtcbpnDXlsp0zFbvXyT5e/9NnYOIZtCuEFS6OBITNDoZkbOhHDqd vWzA== X-Forwarded-Encrypted: i=1; AJvYcCXVTypuqX62eqaGOcX9Wkx+1WhlXp8CsP1Q47wAWAvTBO+fsqsLQ2ix6Aq7SWKcoepjsaYE/suCrDtd2iwu@postgresql.org X-Gm-Message-State: AOJu0Yz8nmSXqbwRItFZZ3fOfO7ILrh2v7sNYlx15qvZPkCCU/Xui3fF lS/OO7M4VPK/CQ0QYe3kNn/vpOTi8qZGwpL2egBfJIZlu492ihxeS5hpzTpb3Go= X-Gm-Gg: ASbGncvZyjX44KTTUrfnIfMkm6qb0iYeTtjzlkeMXtrLHL4qVXnqS1LKHhDEBOLlIbI xSYKayRYTC95soaHqWgMShNiEpVIV1rWkoIpSGrEPPMFmWN743+CSaFUEkuQAFa0It+9dCFE7vk LaKpFE0rBeG0jfhdlLRFOEK3ugtmJUot2QkqgpRkd5QPK40/APvtMsujV0SDHnr6Br8Dxo1vdQr qwIVizpFRiQxdidy68sC804A03vY5Uf09FDH1CImQ+yI2H5Br8FyzpXkLdhb6RuRIWmXk5LHDxD j49jsKTDZA0RnbuK8i8= X-Google-Smtp-Source: AGHT+IEncJ3sUjvzq1Og2UhbfxxoxUZh+qOZvfXF1H+6H1VlWuClYQEVLmluB5qXVxXn41ETwZn8Qg== X-Received: by 2002:a05:600c:5112:b0:434:a91e:c709 with SMTP id 5b1f17b1804b1-438dc40f2bcmr81588615e9.28.1738326750201; Fri, 31 Jan 2025 04:32:30 -0800 (PST) Received: from antos (109-81-174-36.rct.o2.cz. [109.81.174.36]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438e23d42dfsm55029915e9.4.2025.01.31.04.32.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 31 Jan 2025 04:32:29 -0800 (PST) From: Antonin Houska To: Matthias van de Meent cc: Alvaro Herrera , Michael Banck , Junwang Zhao , Kirill Reshke , Pavel Stehule , Michael Paquier , PostgreSQL Hackers Subject: Re: why there is not VACUUM FULL CONCURRENTLY? In-reply-to: References: <679b3979.5d0a0220.115578.3e08@mx.google.com> <202501301529.ejggbtao2skr@alvherre.pgsql> Comments: In-reply-to Matthias van de Meent message dated "Fri, 31 Jan 2025 11:38:57 +0100." X-Mailer: MH-E 8.6+git; nmh 1.8; GNU Emacs 28.3 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <26220.1738326749.1@antos> Date: Fri, 31 Jan 2025 13:32:29 +0100 Message-ID: <26221.1738326749@antos> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Matthias van de Meent wrote: > Further observations: > > First, due to the XLog-based change detection this feature can't work > for unlogged tables without first changing them to logged (which > implies first writing the whole table to XLog, to not cause issues on > any replicas). However, documentation for this limitation seems to be > missing from the patches, and I hope a solution can be found without > requiring LOGGED. Currently I've got no idea how to handle UNLOGGED table. I'll at least fix the documentation. > Second, I'm concerned about long-running snapshots: While I've not > read the patches fully, I think they work something like the > following: > > 1. Mark some start LSN as start for decoding changes > 2. Do the usual REPACK operations, but with reduced locking > 3. Apply the decoded changes > 4. Switch the relfilenodes over > > For (2), I think the scan needs a snapshot to guarantee we keep the > original tuples of updates around, wich will hold back any other > VACUUM activity in the database. For CIC/RIC, a solution is being > created [0], but I'm not sure the same can be applied to this REPACK > CONCURRENTLY: while CIC/RIC doesn't care much about cross-page update > chains (it's only interested in TID+field values for possibly-live > tuples), REPACK seems to require access to the fields of the old > versions of updated tuples to correctly apply updates, thus requiring > a single snapshot for the full scan. > > Maybe that's something that can be further improved upon, maybe not. > REPACK CONCURRENTLY is an improvement over the current situation > w.r.t. locks, but it'd be nice if this new system does not impact the > visibility horizons of the cluster by more than the current. A single snapshot is used because there is a single stream of decoded data changes. Thus a new version of a tuple is either visible to the snapshot or it appears in the stream, but not both. If part of the table was scanned using one snapshot, and another part with another one, it'd be difficult to "put things together". For example, if the first scan does not see a tuple for which the corresponding stream contains an UPDATE change (because the old version is in the not-yet-scanned part of the table), that UPDATE needs to be moved to the stream associated with another snapshot. But that snapshot might not see that tuple either because it was either deleted in between, or should be found by yet another scan. Doing the repacking in several steps might be interesting, but I admit I haven't yet thought that far. -- Antonin Houska Web: https://www.cybertec-postgresql.com