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 1sO3oQ-00C932-E8 for pgsql-hackers@arkaria.postgresql.org; Sun, 30 Jun 2024 23:18:26 +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 1sO3oO-00DpEv-1J for pgsql-hackers@arkaria.postgresql.org; Sun, 30 Jun 2024 23:18:24 +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 1sO3oN-00DpEl-CN for pgsql-hackers@lists.postgresql.org; Sun, 30 Jun 2024 23:18:24 +0000 Received: from mail-oa1-x34.google.com ([2001:4860:4864:20::34]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1sO3oL-004NYd-Bt for pgsql-hackers@lists.postgresql.org; Sun, 30 Jun 2024 23:18:22 +0000 Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-250ca14422aso1417189fac.0 for ; Sun, 30 Jun 2024 16:18:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=leadboat.com; s=google; t=1719789499; x=1720394299; 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=sgivu3FqQqEBeRSkN5yTDyJmQqgJ2o1lZnOS9ZNTTsE=; b=Dpp1hr2jyiBeoKxseu16PgQ9C5omnXPoWBt6VkTvdqnhoLRbeK1S4n4m0Ul6Swz6p/ Yu12qbQzCD1bJ2Bfw2spnLyUYODrku48rpBYozS3sYTfw1aLJ91FKZG+LMZV9VVK4xrk k0v9xsFiji/BTM1jhIuQ572SaqE7nF5jZe12s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719789499; x=1720394299; 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=sgivu3FqQqEBeRSkN5yTDyJmQqgJ2o1lZnOS9ZNTTsE=; b=pKN0lBqiJv38xg9PZtJs5cX40lReyxkF8Lo6Re16O1AJcMP5bFf21AqYM3coJdBppx 5bJ/e4RLkOOCT/nj35HjX6rBZFhrcsxRI3ec9H+FVLwGkvachOHnBwnT3ua4SuV1opw5 +OwY6uGXOgLiC+LeeDFs/3JvvWLMkVYUoIpxviPcvkrz/iU1+/uMM1WoDZysf/IurJ++ XxGmohdd8T1KtCcvZ25WBtCNIgak+S/Et0F9lPcdbobFD48AsCNKqiZSe/bX2VF1mDSf cmlv2uG/i/AeaC+7Hy8D/9Y45TqDNBSSp5Y8VApv1/FA/j0u41++H1oMQkFMUjE1Q2Bi MHlg== X-Forwarded-Encrypted: i=1; AJvYcCVFa0aNJ3IeXcGz6Iu5RCCT61PPiXpQ8TPbOf3ed0JynNLPK8kQ5IHv2LvpuuphRmKl3co3nNEnfq7kGYSZLRXK4w3c7anxSjp/AewpejJtTsQ3 X-Gm-Message-State: AOJu0Yyj4fjoMBc+C+PQN3A8LtvlmTUwBK01o6JKU8Uj0GFYjiOLhpiQ ZrSDjUJ9gc8a3id4oEn99iRwFHLNL0Oj9teVKMkYiGAYiExWiLRyyViqvWv7nVQnkhyhMH7mHKY 5tw== X-Google-Smtp-Source: AGHT+IH44omg4F96YT2halPxvYZDVwxUfMwAA5UsW99J13VZg9W41+dWm+5RFFheC0llkHuiHcXoFA== X-Received: by 2002:a05:6871:88f:b0:254:bc92:9b8c with SMTP id 586e51a60fabf-25db36207b1mr4241847fac.55.1719789499170; Sun, 30 Jun 2024 16:18:19 -0700 (PDT) Received: from google.com ([2600:1702:a20:5750::48]) by smtp.gmail.com with ESMTPSA id 586e51a60fabf-25d8e1f278fsm1489710fac.24.2024.06.30.16.18.18 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 30 Jun 2024 16:18:18 -0700 (PDT) Date: Sun, 30 Jun 2024 16:18:16 -0700 From: Noah Misch To: Alexander Korotkov Cc: Dmitry Koval , pgsql-hackers@lists.postgresql.org Subject: Re: collect_corrupt_items_vacuum.patch Message-ID: <20240630231816.bf.nmisch@google.com> References: <8e6bd629-fa69-371c-966d-aaf071aafeb8@gmail.com> <918b9dc0-9af0-a62a-19cc-cb858b163299@gmail.com> 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 Tue, Mar 12, 2024 at 02:10:59PM +0200, Alexander Korotkov wrote: > I'm going to push this if no objections. 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/? While this isn't a hot path, I likely would test TransactionIdPrecedes() before fetching pgprocno and PGPROC, to reduce wasted cache misses.