Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1krHer-0007v2-TM for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Dec 2020 09:39:13 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1krHeq-00074D-Q6 for pgsql-hackers@arkaria.postgresql.org; Mon, 21 Dec 2020 09:39:12 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1krHeq-000746-B0 for pgsql-hackers@lists.postgresql.org; Mon, 21 Dec 2020 09:39:12 +0000 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1krHen-0000aV-S9 for pgsql-hackers@postgresql.org; Mon, 21 Dec 2020 09:39:10 +0000 Received: by mail-pf1-x432.google.com with SMTP id f9so6131285pfc.11 for ; Mon, 21 Dec 2020 01:39:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=TcF5rqXNWIqey4/Cc3iUclGrntfWVKLMu0Js3vAaZEs=; b=Zm7LHjE4XcJ2E0PcZ34MGEHaVIs5U5Sj1hLE66Z/l5yBK3IX7YyHnvxVfbf5Kr/wzF Rcuxd+N/T7Lvaq6V+L2GXp2qLm1suIJEYH/QI94224IZlBstMdtoqyvoLpLtE7Y4f7a9 hlVMTLB6bKFCTYgzw89bMsleT+fBapKY8P6OI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=TcF5rqXNWIqey4/Cc3iUclGrntfWVKLMu0Js3vAaZEs=; b=bWkBq5zl4kU7VPQi1zdhl4t0ZRwhG7/TszXJChxroWTUtAH+cLVdF50GalINeU5cJ/ Brds4XWKYn54ekYGr0R9UV9Yb+0XCGXeXe3813NE1wzralA1wWi8pxenQcbLUrylCzut tWlSKOcRpite8OcNaR/7XaaogKWgg185EfuqrgOs0sYKA67l2cb9fNc52dLUNSRZkgcu 0TDGnG5cSD2u3jPn9Rx3Wp5A7OMZ210OGz8y16iOz243TLzovZN4v637NavMyHKTgwTm oNtXt30u3mXv5evDGZeJF9m9W3p1aW4MtxvRnt/x2hsoLRdK+iL0YPOc4RIxkob36bDw FpQw== X-Gm-Message-State: AOAM5315tj2bu1EPj5Lmdx9wF/TDxDuryF8khG9QYXCBJMi8AEvQaInD Qm8dOB/mCHwctl1xzoPmKw24Rw== X-Google-Smtp-Source: ABdhPJyQ+fVWy4ZKWoXbUMnj5hxJKHKCHCJLK5zIELer+XculMCzwgbkyj0gZrrJSUmM6dAZAk7fQQ== X-Received: by 2002:a63:4504:: with SMTP id s4mr14566347pga.284.1608543548668; Mon, 21 Dec 2020 01:39:08 -0800 (PST) Received: from rfd.leadboat.com ([2600:1702:a20:5750::43]) by smtp.gmail.com with ESMTPSA id w31sm15883674pgl.87.2020.12.21.01.39.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Dec 2020 01:39:07 -0800 (PST) Date: Mon, 21 Dec 2020 01:39:04 -0800 From: Noah Misch To: Amit Kapila Cc: Peter Eisentraut , Alvaro Herrera , Andres Freund , Marco Nenciarini , Petr Jelinek , Thomas Munro , Simon Riggs , PostgreSQL-development Subject: Re: [PATCH] Logical decoding of TRUNCATE Message-ID: <20201221093904.GA3777719@rfd.leadboat.com> References: <20180405170712.av633jvnnizmd5sn@alvherre.pgsql> <1baed811-47b2-5b7d-c641-4b7eb01d650f@2ndquadrant.com> <20201220041319.GA3602688@rfd.leadboat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On Sun, Dec 20, 2020 at 03:54:31PM -0800, Peter Geoghegan wrote: > On Sun, Dec 20, 2020 at 3:13 PM Andres Freund wrote: > > Hm. Do I understand correctly that this problem is hit solely because > > the parallel mode code relies on there already have been a transaction > > snapshot set, thus avoiding the error? And that the code normally only > > works because GetTransactionSnapshot() will already have been called > > somewhere, before EnterParallelMode()? I think so. > It seems unlikely that InitializeParallelDSM() was ever intended to be > run in a background worker. That wouldn't surprise me. Nonetheless, when worker_spi runs parallel queries, they work fine. The logical replication worker experiences novel scenarios, because it calls ExecuteTruncateGuts() directly, not as part of an actual TRUNCATE query. That bypasses some of the usual once-per-query setup. On Mon, Dec 21, 2020 at 12:29:37PM +0530, Amit Kapila wrote: > I think the TRUNCATE operation should not use parallelism either via > apply worker or without it because there is nothing to scan in heap. That's fair. > Additionally, we can have an Assert or elog in InitializeParallelDSM > to ensure that it is never invoked by parallel worker. I don't know whether InitializeParallelDSM() operates correctly from inside a parallel worker. That is orthogonal to the bug here.