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 1s8zP7-00GZuO-5E for pgsql-general@arkaria.postgresql.org; Mon, 20 May 2024 09:34:02 +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 1s8zP7-0007EO-7I for pgsql-general@arkaria.postgresql.org; Mon, 20 May 2024 09:34:01 +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 1s8zP6-0007EG-OI for pgsql-general@lists.postgresql.org; Mon, 20 May 2024 09:34:00 +0000 Received: from mail-yb1-xb2d.google.com ([2607:f8b0:4864:20::b2d]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s8zP3-0016EV-QM for pgsql-general@lists.postgresql.org; Mon, 20 May 2024 09:33:59 +0000 Received: by mail-yb1-xb2d.google.com with SMTP id 3f1490d57ef6-dcd7c526cc0so2556849276.1 for ; Mon, 20 May 2024 02:33:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=lelarge-info.20230601.gappssmtp.com; s=20230601; t=1716197637; x=1716802437; darn=lists.postgresql.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=BV5Y+In2/BUe8Ey8Qeku44DQQLFchEJPt2RyZ5YBXHs=; b=mqGolJaSQ4I3MItawlM6QeXy1VuemzSqJUwUhwPRUOHYLz2XIWoBqDZQoaHmFAiv5i V9tFNCb62DkNZbjda5EsXiAGX0Gxc/yyIqSuyOkmwLPWyQ32VsG7YsD338OOQvQUuptn mFlkkwW4j2eI0YO84wAUvK00J6p3IWb6enKxp+o1Nrii/EmegkfdzWfXYckQkKZ9YObz S3iKPJlngAvXYOOpDR4w/5qtPZCohIX2yTxvh46oEuYK5l4558BGwRniQbNRbQLoSj/v TFcbn5FI+wPq1bPwiK7sqXGRQkYETG4lghAzEmCnU7He0scS6CKlozw/MI3auVYhciUe aDww== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716197637; x=1716802437; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=BV5Y+In2/BUe8Ey8Qeku44DQQLFchEJPt2RyZ5YBXHs=; b=QV8IDJ+mhsTsxYUZqD5Mh5gDMtqXK+8+hDLPvic3LYUITaXqx4twLbPu5DeIQXw4Mm YWUCYbyuRuaFe+uh76zcWvkb6CQB5UEDv3p4o6RkbIpxoYCUTHmTUSoALXYItKCy5hlt r/JBsqKRa1z3vceeUsyDTq5au2SiE0baaOrQmkXjsuvioJGQaaO7MSgjZHLCh6K/Li9B C5XAI1R/t6lJJqZWC17wpZe1sAxbR93UX3Z9i8gthwj7wLhV+JfkeXZKeEOipz+7nlzu fppkWg4A3hoQJDnOuVS0rG7TZL/KuDYCeL8TxBLCAC/GN9k0Q6ITl36UKdldsWA+S96o sSpw== X-Gm-Message-State: AOJu0YyysWiMXr0MtKwlbc+tK0WU5T89FVUzmm3tlVxJb+kyx9+4DNWd jYBncMg18BsvdBhyIBZvC8emUOSQ8bTFvwGd+vVzSnjSra9Nvy4D9GgqVhIuRxo6pSMadNUZ53M BQ1jz4R53FbqcpT+gzW8yE0pemPThSfF+QqkkmQ== X-Google-Smtp-Source: AGHT+IHBpQdUd1iGySRZZMRkg+3uM1DSgeL3jJ1VE6OV26Zga8FeKZCiQzZrQi85esA1+bz8FkjsGMk+8tycv30zuUE= X-Received: by 2002:a05:6902:1007:b0:df4:ab39:8c1d with SMTP id 3f1490d57ef6-df4ab398ce1mr2592882276.46.1716197636807; Mon, 20 May 2024 02:33:56 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Guillaume Lelarge Date: Mon, 20 May 2024 11:33:45 +0200 Message-ID: Subject: Re: pg_dump and not MVCC-safe commands To: PetSerAl Cc: pgsql-general@lists.postgresql.org Content-Type: multipart/alternative; boundary="00000000000081b5c50618df66fc" List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --00000000000081b5c50618df66fc Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Hi, Le lun. 20 mai 2024 =C3=A0 11:27, PetSerAl a =C3=A9cri= t : > How pg_dump interact with not MVCC-safe commands? > > As I understand, pg_dump first take snapshot and then lock all tables > it intended to dump. What happens if not MVCC-safe command committed > after snapshot but before lock? From comment to pg_dump.c I understand > that it may fail with 'cache lookup failed' error. But, can it happen, > that pg_dump not fail, but instead capture inconsistent dump? For > example TRUNCATE committed after snapshot and pg_dump will see result > of TRUNCATE but not result of other commands in TRUNCATE transaction? > > > You can't truncate an already existing table while pg_dump is running. TRUNCATE needs an exclusive lock, and pg_dump already has a lock on all tables of the database it's dumping. So TRUNCATE will be blocked until pg_dump finishes all its work. (The same will happen for VACUUM FULL, CLUSTER and some (all?) ALTER TABLE commands.) --=20 Guillaume. --00000000000081b5c50618df66fc Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi,

Le=C2=A0lun. 20 mai 2024 =C3=A0=C2= =A011:27, PetSerAl <petseral@gmail= .com> a =C3=A9crit=C2=A0:
How pg_dump interact with not MVCC-safe commands?

As I understand, pg_dump first take snapshot and then lock all tables
it intended to dump. What happens if not MVCC-safe command committed
after snapshot but before lock? From comment to pg_dump.c I understand
that it may fail with 'cache lookup failed' error. But, can it happ= en,
that pg_dump not fail, but instead capture inconsistent dump? For
example TRUNCATE committed after snapshot and pg_dump will see result
of TRUNCATE but not result of other commands in TRUNCATE transaction?



You can't truncate an already ex= isting table while pg_dump is running. TRUNCATE needs an exclusive lock, an= d pg_dump already has a lock on all tables of the database it's dumping= . So TRUNCATE will be blocked until pg_dump finishes all its work.

(The same will happen for VACUUM FULL, CLUSTER and some (a= ll?) ALTER TABLE commands.)


--
Guillaume.
--00000000000081b5c50618df66fc--