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 1u3FZh-00CsAy-V6 for pgsql-bugs@arkaria.postgresql.org; Fri, 11 Apr 2025 14:41:45 +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 1u3FZg-00AbS5-7V for pgsql-bugs@arkaria.postgresql.org; Fri, 11 Apr 2025 14:41:44 +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 1u3FZf-00AbRw-N3 for pgsql-bugs@lists.postgresql.org; Fri, 11 Apr 2025 14:41:44 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1u3FZZ-004Fkh-10 for pgsql-bugs@lists.postgresql.org; Fri, 11 Apr 2025 14:41:42 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-227b828de00so19651605ad.1 for ; Fri, 11 Apr 2025 07:41:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1744382496; x=1744987296; darn=lists.postgresql.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=6ERomYClV+VrxHfkbGv6HerigOC/9xU5mv0OohmFhPA=; b=Sst4ZKpWdqib2tWMDZCCzlMEez3x+YTlRUEWyy7tQUMN2kPq5qw74O8BodbVxEoZg9 nj5qUxoU+fR9CzUm7lu4HKs6wgJivab0+H2x+DX3AcdnkwzGEhThvnYSxsvzqUPBdb+C l+ggxQRFyLkYqTmAaO70+jj3xaUaB1vfHj65o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1744382496; x=1744987296; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6ERomYClV+VrxHfkbGv6HerigOC/9xU5mv0OohmFhPA=; b=DtlsfQMqd6UWtB2yEK6YTqxyllIuEnkVWMMtvXwyNGqEH34Jm5KWQWxnVfz4ZbNCem RgHO7l1tBezepjpD3of7vYYidvIZGfxxavUnKCqH+IAdsLjJS5pPvlOSq+jDXweKTHS3 nsqmD405vcGauoNk1fMcKC9s9TAdox3rWHEjK9UVsXSEhy8IuXOJDMY+jPNLBJtosENp Fm1eDV1eC7EfX2plIWrEdPcYt7T9LfCEOxMX5iPvnVdvUQOjNsyHPAMSLo6Uk5Wn0TQf KIOT9DFmGw7nLw6e4j9oyR6G9BpLIiO7lCMaGaM+uwdCYyQlKIwccy+cX3YxSh3sOlDh xM2g== X-Forwarded-Encrypted: i=1; AJvYcCUHVC0DOCmi9q0dZA+rBcO8D3TZB9K04UKdrL7BRLWx60hdMrr8kiTxbc2bhx+/1438RuB4HIT9Q0LL@lists.postgresql.org X-Gm-Message-State: AOJu0YwloJhn/kz5JEGmGcvkGVpGe2WQK/84NGgkymFlL1wjFsH6cGEd lmlGCBq8Xm7a4lu9FU+TwSPCREOF6Uq8af8vCA8JooLKcSISJE3LaSPNjMC9qA== X-Gm-Gg: ASbGncuOtB/XoaxBytPN3Xv6rWp95ugL8NJWZF0PJ38FeUEG0yzPLtRe0v6ufCxI9cC p42eVc4lbMGHPFNMr4huIf5XTvqWlL0jGZ64pGxD02mtvK9Ss9fDOm6M6ptCfdMljNNGl/2jN+r SOs+Vps5GmTOTt7whB8Cs2KsZSdDYg/OkKvuvxfPf13DogWtdile7nEq0WMMrW/rrHy5hiXoEOx E0TWijtIZ/s86cJTDMxK0WeqegxUlIYUqqtb4Sc1UqIVPqAZNTeY2fhdfRdF9Rd/z/FIbUvdwtL bkZVxjo8q+MR1NGLeOo2G8CSFJhJWjiIZCiFKA== X-Google-Smtp-Source: AGHT+IHWbxhOhtpY5JUNl1w8x2aGPXLR28jsox2V3G3Oc3ezPdCWBhbGe0OUNSXvu14BvoV5dAwGRA== X-Received: by 2002:a17:903:1c7:b0:224:584:6f07 with SMTP id d9443c01a7336-22bea4f2723mr45412145ad.37.1744382496223; Fri, 11 Apr 2025 07:41:36 -0700 (PDT) Received: from google.com ([2601:647:5600:80d0::31cd]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-22ac7c97212sm49595675ad.119.2025.04.11.07.41.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Apr 2025 07:41:35 -0700 (PDT) Date: Fri, 11 Apr 2025 07:41:33 -0700 From: Noah Misch To: Robins Tharakan Cc: Richard Guo , PostgreSQL mailing lists Subject: Re: ERROR: tuple to be updated was already modified by an operation triggered by the current command Message-ID: <20250411144133.d5.nmisch@google.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/2.2.12 (2023-09-09) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Apr 11, 2025 at 10:18:04PM +0930, Robins Tharakan wrote: > On Thu, 23 Jan 2025 at 19:42, Richard Guo wrote: > Repro SQL > ========= > CREATE TEMPORARY TABLE a(b boolean , UNIQUE(b)) ON COMMIT DELETE ROWS ; > CREATE TEMP TABLE d() INHERITS(a) ON COMMIT DROP ; > ANALYSE; Confirmed. Thanks for the report. This is a variant of the bug that commit 7102070 fixed. Key events: - The second CREATE sets relhassubclass=t on "a". - ANALYZE does heap_update() to set relhassubclass=f, since ON COMMIT DROP removed the child. - ON COMMIT DELETE ROWS does an empty index build at end-of-xact, which does an inplace update on the pg_class row of "a". There was no CommandCounterIncrement() since the heap_update(), hence this error. Changing to "ANALYSE a" makes the error go away, because standard_ProcessUtility() does a CCI (added for bug #15631). So I'm inclined to fix that by putting the CCI here for plain "ANALYSE": --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -657,6 +657,8 @@ vacuum(List *relations, VacuumParams *params, BufferAccessStrategy bstrategy, if (use_own_xacts) { PopActiveSnapshot(); + /* standard_ProcessUtility() does CCI if !use_own_xacts */ + CommandCounterIncrement(); CommitTransactionCommand(); } else > > This error happens in heap_inplace_lock(), and git-bisect says the > > first bad commit is: > > > > a07e03fd8fa7daf4d1356f7cb501ffe784ea6257 is the first bad commit That commit made it an error to inplace-update an invisible tuple; before that, we silently lost the inplace update.