Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k3TGJ-0000YR-Vu for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Aug 2020 23:56:00 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1k3TGI-0003JQ-54 for pgsql-hackers@arkaria.postgresql.org; Wed, 05 Aug 2020 23:55:58 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1k3TGH-0003JI-Oz for pgsql-hackers@lists.postgresql.org; Wed, 05 Aug 2020 23:55:57 +0000 Received: from mail-qt1-x843.google.com ([2607:f8b0:4864:20::843]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1k3TGE-0000ld-Lj for pgsql-hackers@lists.postgresql.org; Wed, 05 Aug 2020 23:55:57 +0000 Received: by mail-qt1-x843.google.com with SMTP id s16so35085934qtn.7 for ; Wed, 05 Aug 2020 16:55:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=2ndquadrant-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :content-transfer-encoding:in-reply-to:user-agent; bh=7YJ4yUAV1DrVB1rzoCTBuphCBiAdd/emJLYQahghTQ0=; b=CmDC0KEZqkPRP7R1bKnj1wHp83AUUcaUSyvKZ225jsQBqdakQOfNnHTvZYaeJ2/J/7 ugxwYDp7xvP+AKgmKDTSiphBxbbUQA1IvLLoBfqSgK7f3BAa55q74bqhH/md9pzNXOmk 0cS+9L0Q7f7TcHafsOS/A6jgxCff5ngWrPXljxLXUyjZtYigAEG7TEl03Y41cqJ53+Gd R3srC7IOkQjysX9mKMSLknrAsj8/PobvBEu9ak8sjzT84HNPsZtLltxHUyc6QYUosXVy Djv7hVkIpj3O0KHynqJ1omOW1RG5jDfElxa5luikh+FFqreG8FcxjsdUOXxnyyhc2Ldr CzWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:content-transfer-encoding:in-reply-to :user-agent; bh=7YJ4yUAV1DrVB1rzoCTBuphCBiAdd/emJLYQahghTQ0=; b=dipTx2iuw3c4N6xHi6g/+VIzfDotA54wCVHa2hgKuLxYSTwymZmP8UJET5K4QDzSZE hQ6DG90/fzjwgqgbGG8vCpXUnixqY4MkRdzxiLO45rCIjrZ4BlLZo2PWtysebPuxnAGv JeZavhvmZw4KlRVuT0LTm2RMu6xxLZomuLJqY5VE+Ip/bQp/bh8JXesVzHwDUoKdQ6su AuZ2qrxpr3NuUnFpyd3d7AHdUqk1S1jcTvfj2BaCZF6OjK8vRmcyTGWFY4WZk3rGtKzB Lb38KH2glBJhrGkfQ6WI+fZAfEN9sy1ED9HoCV3E5foDzpzM6FVhf82jY8S5H38HAcC3 KlQA== X-Gm-Message-State: AOAM532UX8Z34FFZxm+WUJ2dNnCsRZ0ANOAuRKjaxAWQe042Ta0I1gFF UjrMdzmu0IIFGQmKgvFsFjrONw== X-Google-Smtp-Source: ABdhPJz3B6c65ZXdMFT7q+ZVuVpu7t2NntiUK3gQ5H5w3uQmA23ztou3B16Ja1ZbnJzL1USUVJqTOQ== X-Received: by 2002:ac8:ec7:: with SMTP id w7mr6170848qti.118.1596671752730; Wed, 05 Aug 2020 16:55:52 -0700 (PDT) Received: from perhan.alvh.no-ip.org ([190.95.19.47]) by smtp.gmail.com with ESMTPSA id t8sm3536603qtc.50.2020.08.05.16.55.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2020 16:55:51 -0700 (PDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 542732A0D0F; Wed, 5 Aug 2020 19:55:49 -0400 (-04) Date: Wed, 5 Aug 2020 19:55:49 -0400 From: Alvaro Herrera To: Andres Freund Cc: James Coleman , pgsql-hackers , simon@2ndquadrant.com Subject: PROC_IN_ANALYZE stillborn 13 years ago Message-ID: <20200805235549.GA8118@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="Kj7319i9nmIyA2yE" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200805021435.GA9523@alvherre.pgsql> User-Agent: Mutt/1.10.1 (2018-07-13) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --Kj7319i9nmIyA2yE Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit Back in the 8.3 cycle (2007) when the autovacuum launcher/worker split was done, we annoyed people because it blocked DDL. That led to an effort to cancel autovac automatically when that was detected, by Simon Riggs. https://postgr.es/m/1191526327.4223.204.camel@ebony.site https://postgr.es/m/1192129897.4233.433.camel@ebony.site I was fixated on only cancelling when it was ANALYZE, to avoid losing any VACUUM work. https://postgr.es/m/20071025164150.GF23566@alvh.no-ip.org That turned into some flags for PGPROC to detect whether a process was ANALYZE, and cancel only those. https://postgr.es/m/20071024151328.GG6559@alvh.no-ip.org Commit: https://postgr.es/m/20071024205536.CB425754229@cvs.postgresql.org https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=745c1b2c2ab However, I was outvoted, so we do not limit cancellation to analyze. Patch and discussion: https://postgr.es/m/20071025164150.GF23566@alvh.no-ip.org Commit: https://postgr.es/m/20071026204510.AA02E754229@cvs.postgresql.org https://git.postgresql.org/gitweb/?p=postgresql.git;a=commitdiff;h=acac68b2bca ... which means the flag I had added two days earlier has never been used for anything. We've carried the flag forward to this day for almost 13 years, dutifully turning it on and off ... but never checking it anywhere. I propose to remove it, as in the attached patch. -- Álvaro Herrera https://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services --Kj7319i9nmIyA2yE Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="0001-Remove-PROC_IN_ANALYZE.patch" From f96b28defe856e284a44b207c2016c72a48a2ff2 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Wed, 5 Aug 2020 18:57:50 -0400 Subject: [PATCH] Remove PROC_IN_ANALYZE --- src/backend/commands/analyze.c | 13 +------------ src/include/storage/proc.h | 3 +-- src/include/storage/procarray.h | 7 ------- 3 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index 924ef37c81..e0fa73ba79 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -247,11 +247,8 @@ analyze_rel(Oid relid, RangeVar *relation, } /* - * OK, let's do it. First let other backends know I'm in ANALYZE. + * OK, let's do it. First, initialize progress reporting. */ - LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); - MyPgXact->vacuumFlags |= PROC_IN_ANALYZE; - LWLockRelease(ProcArrayLock); pgstat_progress_start_command(PROGRESS_COMMAND_ANALYZE, RelationGetRelid(onerel)); @@ -279,14 +276,6 @@ analyze_rel(Oid relid, RangeVar *relation, relation_close(onerel, NoLock); pgstat_progress_end_command(); - - /* - * Reset my PGXACT flag. Note: we need this here, and not in vacuum_rel, - * because the vacuum flag is cleared by the end-of-xact code. - */ - LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); - MyPgXact->vacuumFlags &= ~PROC_IN_ANALYZE; - LWLockRelease(ProcArrayLock); } /* diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index b20e2ad4f6..5ceb2494ba 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -52,7 +52,6 @@ struct XidCache */ #define PROC_IS_AUTOVACUUM 0x01 /* is it an autovac worker? */ #define PROC_IN_VACUUM 0x02 /* currently running lazy vacuum */ -#define PROC_IN_ANALYZE 0x04 /* currently running analyze */ #define PROC_VACUUM_FOR_WRAPAROUND 0x08 /* set by autovac only */ #define PROC_IN_LOGICAL_DECODING 0x10 /* currently doing logical * decoding outside xact */ @@ -60,7 +59,7 @@ struct XidCache /* flags reset at EOXact */ #define PROC_VACUUM_STATE_MASK \ - (PROC_IN_VACUUM | PROC_IN_ANALYZE | PROC_VACUUM_FOR_WRAPAROUND) + (PROC_IN_VACUUM | PROC_VACUUM_FOR_WRAPAROUND) /* * We allow a small number of "weak" relation locks (AccessShareLock, diff --git a/src/include/storage/procarray.h b/src/include/storage/procarray.h index a5c7d0c064..01040d76e1 100644 --- a/src/include/storage/procarray.h +++ b/src/include/storage/procarray.h @@ -29,8 +29,6 @@ */ #define PROCARRAY_VACUUM_FLAG 0x02 /* currently running lazy * vacuum */ -#define PROCARRAY_ANALYZE_FLAG 0x04 /* currently running - * analyze */ #define PROCARRAY_LOGICAL_DECODING_FLAG 0x10 /* currently doing logical * decoding outside xact */ @@ -42,7 +40,6 @@ * have no corresponding PROC flag equivalent. */ #define PROCARRAY_PROC_FLAGS_MASK (PROCARRAY_VACUUM_FLAG | \ - PROCARRAY_ANALYZE_FLAG | \ PROCARRAY_LOGICAL_DECODING_FLAG) /* Use the following flags as an input "flags" to GetOldestXmin function */ @@ -50,10 +47,6 @@ #define PROCARRAY_FLAGS_DEFAULT PROCARRAY_LOGICAL_DECODING_FLAG /* Ignore vacuum backends */ #define PROCARRAY_FLAGS_VACUUM PROCARRAY_FLAGS_DEFAULT | PROCARRAY_VACUUM_FLAG -/* Ignore analyze backends */ -#define PROCARRAY_FLAGS_ANALYZE PROCARRAY_FLAGS_DEFAULT | PROCARRAY_ANALYZE_FLAG -/* Ignore both vacuum and analyze backends */ -#define PROCARRAY_FLAGS_VACUUM_ANALYZE PROCARRAY_FLAGS_DEFAULT | PROCARRAY_VACUUM_FLAG | PROCARRAY_ANALYZE_FLAG extern Size ProcArrayShmemSize(void); extern void CreateSharedProcArray(void); -- 2.20.1 --Kj7319i9nmIyA2yE--