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 1srM1E-000p4s-AW for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Sep 2024 18:36: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 1srM1B-005zFY-PQ for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Sep 2024 18:36:43 +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 1srM1B-005zFM-Fn for pgsql-hackers@lists.postgresql.org; Thu, 19 Sep 2024 18:36:42 +0000 Received: from mail-io1-xd2f.google.com ([2607:f8b0:4864:20::d2f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1srM1A-0003Bj-DR for pgsql-hackers@lists.postgresql.org; Thu, 19 Sep 2024 18:36:41 +0000 Received: by mail-io1-xd2f.google.com with SMTP id ca18e2360f4ac-82cf3286261so50836039f.0 for ; Thu, 19 Sep 2024 11:36:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1726771000; x=1727375800; darn=lists.postgresql.org; h=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=BqfConarTLiK26ql4fnH0REOhsXMmNlx9W8UjFlbFE8=; b=AotffPgFScLllgDXRuoEFMReTdlPpgXtlRcQEDa8vAmx6pJF8omZ9uP2Vuce1BszHV DWsUiqslMr045CZHLNhJciJyQj7aVu5oGx0NZLb8JVXIkjybOC03MfGZ9a1NimnIUJtd JE8b+YE8rEJIyF9VNU3pIHR22RhcjpHUrdi1kwRi2DBAbQhEqGVyoCZF5oky1pxPra1a jtI5qKqY3/qC1sNTuDdwwOUf3t56PkkIVWBY3+3amE+vlGgx2azP+9N4gxvkeZx1DpfD bIcZZ5YAVGzOGtNEalnIf6ug0g8rIBH0vpR8YZupZIF5AuC+o+aTkfQ3LuNRPSraUcUj 4yYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1726771000; x=1727375800; h=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=BqfConarTLiK26ql4fnH0REOhsXMmNlx9W8UjFlbFE8=; b=KZ7BYUDn9pHs94Slyurht8dnxS1pL4u/dQA4MkiP53EvPLrRGqAjYdVomWfiGeYq6n 4vH8Yi2R7RA1ntGOT8q0aETIZjdsD9alvknAK4LCwxz8sdOH83xI1NVLELYI/pPzsaNr 2eBDrHw7t0otfyUuiZJHwwQQolkBnzfv3fxiEumsuj6iq7+VfNViTkNDz+SdWNR4MSFZ OrP+BtLnEVlMdkIvWdI5+MhcNvLBcX50UO9kOi8woqhpi+Gywi8BM/mOL11KgNPS2A2I 8xhrK2Os3O5hPVpiwrCIhidCkkdSV/XRoxIgefh4V5sMJlQNSkX5QfopgjfMZI3tXtzY xspw== X-Forwarded-Encrypted: i=1; AJvYcCVPwk8SXQgbsp4m+O8O110W54jSr9HPbzwtzOyzOomoYC9eBgODu9tW0CD9fQ10w+H60J7n43DPFV7HUaqt@lists.postgresql.org X-Gm-Message-State: AOJu0YxUyTTsWi8U5fg9OWz3qXTXKrP8Dq+fcwN7vt689jLczaPYjxkV fOeX1sAMXBtwZ4a4WQToELp9QQWPyq8BGuUAFeaxlwDV+I0p+gie X-Google-Smtp-Source: AGHT+IFdPN9Sh1VhHQ99xP8jGHgGmuSSRJukL25DFFI8svAiTzILX4YFVLc51fLBJPYr9YlyZ5xv6w== X-Received: by 2002:a05:6602:1549:b0:81f:75bf:6570 with SMTP id ca18e2360f4ac-83209cfbcb3mr55458939f.5.1726770999652; Thu, 19 Sep 2024 11:36:39 -0700 (PDT) Received: from nathan (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id ca18e2360f4ac-82d4928aa01sm335248339f.15.2024.09.19.11.36.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2024 11:36:38 -0700 (PDT) Date: Thu, 19 Sep 2024 13:36:36 -0500 From: Nathan Bossart To: Alexander Lakhin Cc: Tom Lane , "Jonathan S. Katz" , PostgreSQL Hackers Subject: Re: Large expressions in indexes can't be stored (non-TOASTable) Message-ID: References: <1679756.1725476893@sss.pgh.pa.us> <1812111.1726671296@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="MkYuIQX3nCR/0Ij8" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --MkYuIQX3nCR/0Ij8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Thu, Sep 19, 2024 at 12:00:00PM +0300, Alexander Lakhin wrote: > I've discovered that Jonathan's initial script: > CREATE TABLE def (id int); > SELECT array_agg(n) b FROM generate_series(1,10_000) n \gset > CREATE OR REPLACE FUNCTION vec_quantizer (a int, b int[]) RETURNS bool > AS $$ SELECT true $$ LANGUAGE SQL IMMUTABLE; > CREATE INDEX ON def (vec_quantizer(id, :'b')); > > completed with: > DROP INDEX CONCURRENTLY def_vec_quantizer_idx; > > triggers an assertion failure: > TRAP: failed Assert("HaveRegisteredOrActiveSnapshot()"), File: "toast_internals.c", Line: 668, PID: 3723372 Ha, that was fast. The attached patch seems to fix the assertion failures. It's probably worth checking if any of the adjacent code paths are affected, too. -- nathan --MkYuIQX3nCR/0Ij8 Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="fix_assert.patch" diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index b2b3ecb524..2e378ef4ef 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -2255,6 +2255,7 @@ index_drop(Oid indexId, bool concurrent, bool concurrent_lock_mode) PopActiveSnapshot(); CommitTransactionCommand(); StartTransactionCommand(); + PushActiveSnapshot(GetTransactionSnapshot()); /* * Now we must wait until no running transaction could be using the @@ -2283,8 +2284,10 @@ index_drop(Oid indexId, bool concurrent, bool concurrent_lock_mode) * Again, commit the transaction to make the pg_index update visible * to other sessions. */ + PopActiveSnapshot(); CommitTransactionCommand(); StartTransactionCommand(); + PushActiveSnapshot(GetTransactionSnapshot()); /* * Wait till every transaction that saw the old index state has @@ -2387,6 +2390,8 @@ index_drop(Oid indexId, bool concurrent, bool concurrent_lock_mode) { UnlockRelationIdForSession(&heaprelid, ShareUpdateExclusiveLock); UnlockRelationIdForSession(&indexrelid, ShareUpdateExclusiveLock); + + PopActiveSnapshot(); } } --MkYuIQX3nCR/0Ij8--