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 1s92Lj-00GvL4-3I for pgsql-general@arkaria.postgresql.org; Mon, 20 May 2024 12:42:44 +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 1s92Li-001kGu-UM for pgsql-general@arkaria.postgresql.org; Mon, 20 May 2024 12:42:42 +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 1s90NS-000at9-Vl for pgsql-general@lists.postgresql.org; Mon, 20 May 2024 10:36:22 +0000 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1s90NP-001B28-SY for pgsql-general@lists.postgresql.org; Mon, 20 May 2024 10:36:22 +0000 Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1ee7963db64so2201145ad.1 for ; Mon, 20 May 2024 03:36:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716201378; x=1716806178; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=SGZGvEDj/2YuWMdUeOHMxO/O5TTreRtvUncJTfMJICg=; b=h3krv1KNzSrUMgMkKrCxgjny0MoQ1NkZ09eQgjubMCkRVztGEAGZWBtX4z918dABtQ RplqqdWgvqa3SVliiEeuLVESM+43G2Ko7n3G3yrOpN7O2zQ8FJrwutmLA5L8o2EOeO21 m6f+0NP4RogJ52gx1+JcoIYvEN3IBwY81ZAlcmjkaN1vcIm0HdURpQuBtA8l41FDsWHr JZoVve8h2B3+D4YM7XGmIqgzPTjO3DzBICxdrQVmZfOy0kmgt7tK/PNUHKZqyY+37iLJ Yvnd9mWAlZqbLz4PdXaOT18laOxqiCws7efPw3oJ8ziW0boWFsHzZNb7nHs1Nj73ajx7 3qNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716201378; x=1716806178; h=content-transfer-encoding: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=SGZGvEDj/2YuWMdUeOHMxO/O5TTreRtvUncJTfMJICg=; b=vclhIwnTL5/Fo4j9hPJIaMhN625l+i0tR/LxzKaMrQbphyJFuZNrLeNg9GKmWbNtZG A7CWuE7lCG8Mw7ysx1qQ/yNxa93Rb57ReJ+zR03x6jcbMXBdcTaLiFCJdRCgNE1SYv8i Ic2IfDB3+O2vwCxpaJb+cXOngJxt1S0AB3rn4cYBaRm2NlVSQdxYycAmw9+gdyoI8px0 bs3lIGXyqvP7nC+zV2kU2Fbm2PuBIjy+xKMDPU7i07Rv7sgqjK/URCTx9KB2KoRWT9Pa DL35WBa4yfnfX/BCCAjHZvHKeCk7s88QwELCy5GOuiyfIAdjOvpcM5+naViVBXwnmYZi 1FtA== X-Gm-Message-State: AOJu0Yye0WpjQfvXYIT8bo3K/ttCcpXPPahqoEM3BDm73citGC3rCBoQ rgNwvZJOkKmWK01f1c1zV+fnXDESKufGqNZXEOcIk9Box4UCKghGUSTZurFzXDXN8M7ivKcCnme mNtpo4g7Kr9tTzxmjUlhceZkaeiAk/GoKjuWD6g== X-Google-Smtp-Source: AGHT+IGVqewvyIwMtme/PbbQ52KQLXCP7xHoTG4fcWJ6siGw1ea2mT1Xcd9W+IWvtBgOL6Wdz4z0SA57AzCOO572/ZM= X-Received: by 2002:a17:90a:4a0a:b0:2ba:a1d:5a73 with SMTP id 98e67ed59e1d1-2ba0a1d5b4fmr11935610a91.22.1716201378549; Mon, 20 May 2024 03:36:18 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: PetSerAl Date: Mon, 20 May 2024 13:36:08 +0300 Message-ID: Subject: Re: pg_dump and not MVCC-safe commands To: Guillaume Lelarge Cc: pgsql-general@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk My question: What happens if not MVCC-safe command committed after snapshot but before l= ock? On Mon, May 20, 2024 at 12:33=E2=80=AFPM Guillaume Lelarge wrote: > > Hi, > > Le lun. 20 mai 2024 =C3=A0 11:27, PetSerAl a =C3=A9c= rit : >> >> 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. TR= UNCATE needs an exclusive lock, and pg_dump already has a lock on all table= s of the database it's dumping. So TRUNCATE will be blocked until pg_dump f= inishes all its work. > > (The same will happen for VACUUM FULL, CLUSTER and some (all?) ALTER TABL= E commands.) > > > -- > Guillaume.