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 1sOmUf-001A1S-RQ for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Jul 2024 23:01:01 +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 1sOmTd-004pqA-NB for pgsql-hackers@arkaria.postgresql.org; Tue, 02 Jul 2024 22:59:58 +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 1sOmTd-004pq2-60 for pgsql-hackers@lists.postgresql.org; Tue, 02 Jul 2024 22:59:58 +0000 Received: from mail-yw1-x1129.google.com ([2607:f8b0:4864:20::1129]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sOmTb-0007md-7i for pgsql-hackers@lists.postgresql.org; Tue, 02 Jul 2024 22:59:57 +0000 Received: by mail-yw1-x1129.google.com with SMTP id 00721157ae682-6507469c34bso565277b3.0 for ; Tue, 02 Jul 2024 15:59:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1719961192; x=1720565992; darn=lists.postgresql.org; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=TJVzrF3qTZMH8dwTj+hwP/BkTN3A/CHm1TSkCnx71Fc=; b=PWJgQJUNyaX8L3bqeFOZgDli+9/wUOupFj1iGiuhCe9FSvEnrCncCq3YEJ4TNwFTO9 vsZx1rsAdKgFCe5dGGTpPySDKxXFhDKU/2DyGvYSFlkL14lvO5CIHonSg3/sS2N+VgwO F/RbrnKIe/eD+6KmDGjEOPG5z2TXOqMXhKMP8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719961192; x=1720565992; h=user-agent:in-reply-to:content-transfer-encoding :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=TJVzrF3qTZMH8dwTj+hwP/BkTN3A/CHm1TSkCnx71Fc=; b=LRP/jywu79jAeF3sQvjZPfVxfctUXlrW+oXJlVWoXzmtcKOFrx9G0AUQzL32wbXPZW yx4qQGhRBT3AsZKyfNHEUHI+cUKXcDrprUv2kg1KLryrAkvjku6O8RjXtC+kK31JEtnG be4c9ZGE9TDoFu2grKh7O4KzkxDv7c2z3d2tUFnt3p+eG5LUBBnrxUjFZKjx5l3wx22+ HUnYfBQj3p4EH+p2P8beByE1TCBhJflEmWN/m62MpFF0lSISvi7dinBKvjZVJOKHQEmD uDjGbz7qCxsmIJl+dWc0C6g9ZjeeBmrGeKkzwWJfKHn3YZlKwhLcKis1fRsJgo/tdVBI uy3Q== X-Forwarded-Encrypted: i=1; AJvYcCX9lK6FrvJDacFV5Nyg2dyVst6GsCMBqs+jFzZo1+7rrkNQQsM01xjco2oNtmVqJNEtS6cwYQlhmByl2al0fvD6J6BEaxib/oKJ8hq8kXQMsyYa X-Gm-Message-State: AOJu0YydDXtvnRlJhTOa5uQh+FaS/DoS671yrjKei4JChdKirzEoJGIH 32FDf7OsIwmfs768N+tJ9fe808UJ5DLNjWR4PhVUce1n5jMN8x+lwiYt3QNq3Q== X-Google-Smtp-Source: AGHT+IGZtuwYUu70eLGu5CKNXWYZt8KuXf6qP7YvPwS5eyMPqLdRZ5gYMDU1TBHV4Q6NAuwEjf6OVg== X-Received: by 2002:a05:690c:6891:b0:631:399f:2e87 with SMTP id 00721157ae682-64af4e70401mr101444017b3.16.1719961191934; Tue, 02 Jul 2024 15:59:51 -0700 (PDT) Received: from google.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id 00721157ae682-64a9c409087sm19306687b3.136.2024.07.02.15.59.50 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 02 Jul 2024 15:59:51 -0700 (PDT) Date: Tue, 2 Jul 2024 15:59:49 -0700 From: Noah Misch To: Alexander Korotkov Cc: Dmitry Koval , pgsql-hackers@lists.postgresql.org Subject: Re: collect_corrupt_items_vacuum.patch Message-ID: <20240702225949.ed.nmisch@google.com> References: <8e6bd629-fa69-371c-966d-aaf071aafeb8@gmail.com> <918b9dc0-9af0-a62a-19cc-cb858b163299@gmail.com> <20240630231816.bf.nmisch@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit 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 Wed, Jul 03, 2024 at 12:31:48AM +0300, Alexander Korotkov wrote: > On Mon, Jul 1, 2024 at 2:18 AM Noah Misch wrote: > > Commit e85662d wrote: > > > --- a/src/backend/storage/ipc/procarray.c > > > +++ b/src/backend/storage/ipc/procarray.c > > > > > @@ -2740,6 +2741,8 @@ GetRunningTransactionData(void) > > > */ > > > for (index = 0; index < arrayP->numProcs; index++) > > > { > > > + int pgprocno = arrayP->pgprocnos[index]; > > > + PGPROC *proc = &allProcs[pgprocno]; > > > TransactionId xid; > > > > > > /* Fetch xid just once - see GetNewTransactionId */ > > > @@ -2760,6 +2763,13 @@ GetRunningTransactionData(void) > > > if (TransactionIdPrecedes(xid, oldestRunningXid)) > > > oldestRunningXid = xid; > > > > > > + /* > > > + * Also, update the oldest running xid within the current database. > > > + */ > > > + if (proc->databaseId == MyDatabaseId && > > > + TransactionIdPrecedes(xid, oldestRunningXid)) > > > + oldestDatabaseRunningXid = xid; > > > > Shouldn't that be s/oldestRunningXid/oldestDatabaseRunningXid/? > > Thank you for catching this. > > > While this isn't a hot path, I likely would test TransactionIdPrecedes() > > before fetching pgprocno and PGPROC, to reduce wasted cache misses. > > And thanks for suggestion. > > The patchset is attached. 0001 implements > s/oldestRunningXid/oldestDatabaseRunningXid/. 0002 implements cache > misses optimization. > > If no objection, I'll backpatch 0001 and apply 0002 to the head. Looks fine. I'd drop the comment update as saying the obvious, but keeping it is okay.