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 1t4lr8-002A06-1y for pgsql-hackers@arkaria.postgresql.org; Sat, 26 Oct 2024 18:49:46 +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 1t4lr5-00AyNq-Ug for pgsql-hackers@arkaria.postgresql.org; Sat, 26 Oct 2024 18:49: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 1t4lr5-00AyNg-Bw for pgsql-hackers@lists.postgresql.org; Sat, 26 Oct 2024 18:49:43 +0000 Received: from mail-pl1-x633.google.com ([2607:f8b0:4864:20::633]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1t4lr2-002zlp-Ge for pgsql-hackers@postgresql.org; Sat, 26 Oct 2024 18:49:42 +0000 Received: by mail-pl1-x633.google.com with SMTP id d9443c01a7336-20cbb1cf324so25677845ad.0 for ; Sat, 26 Oct 2024 11:49:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1729968579; x=1730573379; darn=postgresql.org; h=user-agent:content-disposition:mime-version:message-id:subject:to :from:date:from:to:cc:subject:date:message-id:reply-to; bh=F3PybU/k9bjW5VuPkTTye9TwRZOfhsq9mv4LoBT4xY0=; b=FuYRq1izUwG/cDQJ9L05o3kKWMsdj/luin2qTb/nxotpWXQ5aZPpXMla5AtbPgXNmp 5Pfj7HmkE2de0CjQ8lluH1PCsNpL6Hj4CtWJYUe2KM/ku4HxOjGunV8rD8ezP9ZIgPr1 XcFgN8mBX+6Viuh7r2O8PGW+HmvqL17Or8Ka0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729968579; x=1730573379; h=user-agent:content-disposition:mime-version:message-id:subject:to :from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=F3PybU/k9bjW5VuPkTTye9TwRZOfhsq9mv4LoBT4xY0=; b=DCo03zoobrMmyi3LgTi9HUkeBPF/3QKnfOyNWFkun5VyAjqxsu2a/UAgD99u8aZVy8 mv2j8kEBATFz3b2/ux9kTgd6F1nAJGuAaUopbSBihTNEbPBVgsiXConHMXf6WvyaiQcq Qv9F+P9ZjKK6Ir67ANKa5Mcm0HmxrDBRWwS/PmGMjbGMXpe/X05brLBocDD4FXQ8qlJH YQ1Q5eam4LrN6/rAf0wautFJ2okYszfcF9ACwgbSKzYAKi4WqeN/5NME9orPSln64/w/ ioVCDBBIbB/6vC0eNvIBKSxf2zEo0/Q0U+YHBLK+UNYLZ1V5zsZbV/Su8Jvu+XHgneJO xMCg== X-Gm-Message-State: AOJu0Yyp+7epPS9s0m+8mETZwznKmj+IfzNnz3ry+smPjGIIhiZwrVyZ VH0ve+ihsyvNFFhNlPTexFyeUTVFiEc13+kAMeVJXprQTGMakUbAXLJywxJrEEg0EAiHxiEcBHY = X-Google-Smtp-Source: AGHT+IEKslDZQivNeTaplDwSz8/W0h/rTJysdahIxR2nFb05uZaUoKB/i2s4XSKc7VmMMJCHl5TVwA== X-Received: by 2002:a17:903:41cc:b0:20c:8a91:3b43 with SMTP id d9443c01a7336-210c68d4396mr54815955ad.16.1729968578457; Sat, 26 Oct 2024 11:49:38 -0700 (PDT) Received: from google.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-7edc8a77412sm2977303a12.94.2024.10.26.11.49.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sat, 26 Oct 2024 11:49:37 -0700 (PDT) Date: Sat, 26 Oct 2024 11:49:36 -0700 From: Noah Misch To: pgsql-hackers@postgresql.org Subject: heap_inplace_lock vs. autovacuum w/ LOCKTAG_TUPLE Message-ID: <20241026184936.ae.nmisch@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 intra-grant-inplace-db.spec got a novel failure today: https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=sarus&dt=2024-10-26%2014%3A08%3A58 The isolationtester_waiting query is supposed to detect that step vac2 is blocked. vac2 didn't finish within the timeout, but isolationtester_waiting never considered it blocked. Most-relevant postmaster.log lines: === 2024-10-26 14:22:51.791 UTC [2444667:6] isolation/intra-grant-inplace-db/s1 LOG: statement: BEGIN; 2024-10-26 14:22:51.791 UTC [2444667:7] isolation/intra-grant-inplace-db/s1 LOG: statement: GRANT TEMP ON DATABASE isolation_regression TO regress_temp_grantee; 2024-10-26 14:22:51.791 UTC [2444668:6] isolation/intra-grant-inplace-db/s2 LOG: statement: VACUUM (FREEZE); 2024-10-26 14:22:51.813 UTC [2444663:1] LOG: skipping analyze of "pg_attribute" --- lock not available 2024-10-26 14:22:51.815 UTC [2444666:7] isolation/intra-grant-inplace-db/control connection LOG: execute isolationtester_waiting: SELECT pg_catalog.pg_isolation_test_session_is_blocked($1, '{2444667,2444668,2444669}') 2024-10-26 14:22:51.815 UTC [2444666:8] isolation/intra-grant-inplace-db/control connection DETAIL: Parameters: $1 = '2444668' [... omitting most other lines from PID 2444666: >37000 isolationtester_waiting calls ...] 2024-10-26 14:22:51.851 UTC [2444663:2] LOG: skipping analyze of "pg_class" --- lock not available 2024-10-26 14:22:51.892 UTC [2444663:3] LOG: skipping analyze of "pg_depend" --- lock not available 2024-10-26 14:23:52.833 UTC [2444663:4] ERROR: canceling autovacuum task 2024-10-26 14:23:52.833 UTC [2444663:5] CONTEXT: while updating tuple (0,20) in relation "pg_database" 2024-10-26 14:24:52.768 UTC [2447791:1] ERROR: canceling autovacuum task 2024-10-26 14:24:52.768 UTC [2447791:2] CONTEXT: while updating tuple (0,20) in relation "pg_database" 2024-10-26 14:25:52.777 UTC [2451018:1] ERROR: canceling autovacuum task 2024-10-26 14:25:52.777 UTC [2451018:2] CONTEXT: while updating tuple (0,20) in relation "pg_database" 2024-10-26 14:26:52.789 UTC [2454071:1] ERROR: canceling autovacuum task 2024-10-26 14:26:52.789 UTC [2454071:2] CONTEXT: while updating tuple (0,20) in relation "pg_database" 2024-10-26 14:27:16.322 UTC [2442306:1] LOG: checkpoint starting: time 2024-10-26 14:27:52.798 UTC [2457311:1] ERROR: canceling autovacuum task 2024-10-26 14:27:52.798 UTC [2457311:2] CONTEXT: while updating tuple (0,20) in relation "pg_database" 2024-10-26 14:28:51.755 UTC [2444666:37889] isolation/intra-grant-inplace-db/control connection LOG: execute isolationtester_waiting: SELECT pg_catalog.pg_isolation_test_session_is_blocked($1, '{2444667,2444668,2444669}') 2024-10-26 14:28:51.755 UTC [2444666:37890] isolation/intra-grant-inplace-db/control connection DETAIL: Parameters: $1 = '2444668' 2024-10-26 14:28:51.810 UTC [2463672:1] [unknown] LOG: connection received: host=[local] 2024-10-26 14:28:51.812 UTC [2444668:7] isolation/intra-grant-inplace-db/s2 ERROR: canceling statement due to user request 2024-10-26 14:28:51.812 UTC [2444668:8] isolation/intra-grant-inplace-db/s2 CONTEXT: while scanning block 0 of relation "pg_catalog.pg_database" 2024-10-26 14:28:51.812 UTC [2444668:9] isolation/intra-grant-inplace-db/s2 STATEMENT: VACUUM (FREEZE); === I would have expected these locking-relevant events: - GRANT stamped a pg_database tuple with an xmax. - auto-analyze sought to update the same tuple, so it acquired LOCKTAG_TUPLE and entered XactLockTableWait(xmax-from-GRANT). - Non-auto VACUUM from step vac2 blocked on acquiring LOCKTAG_TUPLE. pg_isolation_test_session_is_blocked() considers this not blocked, since blocking on autovacuum doesn't count for test output purposes. - Deadlock detector notices auto-analyze is blocking vac2, hence "canceling autovacuum task" after 1s. - vac2 finishes its LOCKTAG_TUPLE acquisition and enters XactLockTableWait(xmax-from-GRANT). - pg_isolation_test_session_is_blocked() now considers vac2 blocked. The timeout suggests some subset of that didn't happen. It's odd that a new auto-analyze starts every minute, each of which exits due to blocking vac2. I likely got something wrong in commit aac2c9b or its parent (2024-09-24). I'll work on reproducing this. Thanks, nm