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 1nKlRR-0001qU-QT for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Feb 2022 18:23:45 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nKlRQ-0004ZY-Gy for pgsql-hackers@arkaria.postgresql.org; Thu, 17 Feb 2022 18:23:44 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nKlRQ-0004ZP-55 for pgsql-hackers@lists.postgresql.org; Thu, 17 Feb 2022 18:23:44 +0000 Received: from mail-pg1-x52b.google.com ([2607:f8b0:4864:20::52b]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nKlRN-0003xO-8x for pgsql-hackers@postgresql.org; Thu, 17 Feb 2022 18:23:43 +0000 Received: by mail-pg1-x52b.google.com with SMTP id z4so5707222pgh.12 for ; Thu, 17 Feb 2022 10:23:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=1EjYKVZlPZ0XDeDXOixH1vd8gtO+ABt23AYiwWvs7UQ=; b=oEUPvMikGCPh/LyApppcfv+zsv3o6b+uML8TnZEuv5YO7JFFpmXqUTDRRQpi/Mx4vq m/q5cS/+UAQRhHo7a1Zpvh3PuLXxUdBWdq/ZH5y0owZshQYUaXhrgnZO4lN8Bg3J/PH7 rSc43PdbOEhGi9oHBqD5YNpMzvmYXtSYCxmtCAqYCMvFoP5i5jjFxZA9fX2ix086cRWS JVEtsjZwlUcwv+HMFLKFkfCJMUD7ZpjAEPlpSueDMCjX4PPG3qw27QcOVsFWrwBendhP 3YH/pp/iiBjvx9CvIeTvrMDxtqz12gu8rh8fgszrHP2b4kZucoIgqrJf3H8X4l7urc0R TxbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=1EjYKVZlPZ0XDeDXOixH1vd8gtO+ABt23AYiwWvs7UQ=; b=G9OHz1dCN0e715k5Hfs7UlVixieMuxT8o1XqMRs4gxxKOymJ+cwFCjUGUgBzeJrXxQ +kqAmYAHP7dpJ14hUtUm0NUwLevLeKRuq8XSM/NNI8TWd7B+5voIkiGuFf7nA2SEYro3 e2hTS97x8TR0ylzO21Dc1Nx067/24c/jxaBp/8E5H2jCsFA9SBRIVGlhOvlu4DZDaFKQ fhkculY9q20WhuyB9mxt/amphgEdZ7ijrWHScpPob8nyFYec2/Su4HUCdejDgkSbkMOc KYPPRhKt1IpjwuZzO9q8eUCRlSDswH+hqW5W7S7zAyGaWA2XNQH0cKRUT0KZFk9Yt6+n boLg== X-Gm-Message-State: AOAM5328S3LImcRnfIWmdQrqYgEYFtv8jTsyt/LTg/CM6xyiGlT57e6+ o0o+TinRgPf04OXQHwDUlZI= X-Google-Smtp-Source: ABdhPJzzZIFf5bjrnZKxV+Hx5nf9Nabv196NcGk/xw3QEmFa+RiqRvnnc0uubkTSEAUS1hTLb8MTew== X-Received: by 2002:a05:6a00:893:b0:4de:8a29:c12a with SMTP id q19-20020a056a00089300b004de8a29c12amr4318467pfj.2.1645122220239; Thu, 17 Feb 2022 10:23:40 -0800 (PST) Received: from nathanxps13 ([50.54.155.70]) by smtp.gmail.com with ESMTPSA id 12sm8873716pgb.71.2022.02.17.10.23.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Feb 2022 10:23:39 -0800 (PST) Date: Thu, 17 Feb 2022 10:23:37 -0800 From: Nathan Bossart To: Andres Freund Cc: "Bossart, Nathan" , Bharath Rupireddy , Maxim Orlov , Amul Sul , Bruce Momjian , Robert Haas , "pgsql-hackers@postgresql.org" Subject: Re: O(n) tasks cause lengthy startups and checkpoints Message-ID: <20220217182337.GA3247866@nathanxps13> References: <83BE6E07-CEF5-445B-A8F9-2A2DD56F08CA@amazon.com> <83A7426F-A7B6-4A10-A8F0-179AE30B871D@amazon.com> <20220211180249.GA1886051@nathanxps13> <20220217005057.GA3201038@nathanxps13> <20220217015052.2y3wxibeommk37ey@alap3.anarazel.de> <20220217041404.GA3243546@nathanxps13> <20220217065938.x2esfdppzypegn5j@alap3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220217065938.x2esfdppzypegn5j@alap3.anarazel.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Feb 16, 2022 at 10:59:38PM -0800, Andres Freund wrote: > On 2022-02-16 20:14:04 -0800, Nathan Bossart wrote: >> >> - while ((spc_de = ReadDirExtended(spc_dir, "pg_tblspc", LOG)) != NULL) >> >> + while (!ShutdownRequestPending && >> >> + (spc_de = ReadDirExtended(spc_dir, "pg_tblspc", LOG)) != NULL) >> > >> > Uh, huh? It strikes me as a supremely bad idea to have functions *silently* >> > not do their jobs when ShutdownRequestPending is set, particularly without a >> > huge fat comment. >> >> The idea was to avoid delaying shutdown because we're waiting for the >> custodian to finish relatively nonessential tasks. Another option might be >> to just exit immediately when the custodian receives a shutdown request. > > I think we should just not do either of these and let the functions > finish. For the cases where shutdown really needs to be immediate > there's, uhm, immediate mode shutdowns. Alright. >> > Why does this not open us up to new xid wraparound issues? Before there was a >> > hard bound on how long these files could linger around. Now there's not >> > anymore. >> >> Sorry, I'm probably missing something obvious, but I'm not sure how this >> adds transaction ID wraparound risk. These files are tied to LSNs, and >> AFAIK they won't impact slots' xmins. > > They're accessed by xid. The LSN is just for cleanup. Accessing files > left over from a previous transaction with the same xid wouldn't be > good - we'd read wrong catalog state for decoding... Okay, that part makes sense to me. However, I'm still confused about how this is handled today and why moving cleanup to a separate auxiliary process makes matters worse. I've done quite a bit of reading, and I haven't found anything that seems intended to prevent this problem. Do you have any pointers? -- Nathan Bossart Amazon Web Services: https://aws.amazon.com