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 1p1BVE-0003cE-EH for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Dec 2022 19:15:16 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1p1BVD-0001v4-0J for pgsql-hackers@arkaria.postgresql.org; Fri, 02 Dec 2022 19:15:15 +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 1p1BVC-0001uu-LC for pgsql-hackers@lists.postgresql.org; Fri, 02 Dec 2022 19:15:14 +0000 Received: from mail-pj1-x102b.google.com ([2607:f8b0:4864:20::102b]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1p1BVA-0004xC-7a for pgsql-hackers@postgresql.org; Fri, 02 Dec 2022 19:15:14 +0000 Received: by mail-pj1-x102b.google.com with SMTP id e7-20020a17090a77c700b00216928a3917so9165440pjs.4 for ; Fri, 02 Dec 2022 11:15:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=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=mRjLqswoqnGJOFp3OQ39UlcjOM5VeTggIeTsHTfhkhg=; b=Bx5xAqoTQTcq+nvIOec7Strjt2NGRBnmFSM4vbS70PMrznGnDghXNtGFDZLtDpxk4D Uzj/sIu3+zLs83jVm3zHi2qTsB3vBHYPMpBsAD0lRJPMBddnOcKrnrMgIq74WpWtD+Sm //+6UvWOKLs6Ph56frsy1KaPEx+ij5qzewLqolDAo71S+xjlfGmVmsb03z8Ra/WlvfeA 38EYiFf0DXjL9oKMlHm6lWmM/xOKAhIDWy1LVEyGh5LAAvo9GiQgnL/d4TVzN/1bZ7y1 N0zwoHUUl/VJS1XlYI/xXM3qKJYzfiQ24ILOh6SQRhg4k5dANwTsbLY/CMdDBs9PIqxG 1MKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=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=mRjLqswoqnGJOFp3OQ39UlcjOM5VeTggIeTsHTfhkhg=; b=TBDjbyiy+ZPHkmgfIU7I/r4zekhYeASqaUmcMKCnQBIDTWWUM8ZdzOidgipWKigR2Z OAVKUtNqZ3U71I3l5KIj+Xz9ZaqK7gS1uSG3z9MfESPdic5eub5cf81KpRtp2xUhjupo aiGc07RWw8jexSVvIZXXdPgwz899Cf8WabE3ktosJR8CJWXJBIN6RXQ99keTDOEFul5C UWZprsJAZgtZg6HABqxawc4C6kqj3gGy+ucTEagkvTj5Qdq43ats+KhBG7O1pDgPUzYf p5iR1K+P5Gzw0q6DQAKufzywunw0S0+oHW/iLZCwH95NsCrk+xUnfgfj6Cf9TKh9J76Z HqEA== X-Gm-Message-State: ANoB5pmwMZlSU+cyacMV/qsLDAKKt6Iaw8GkdzQ4MwYBj5DEg07O4CxD 1ZcF+PAhsqlffd1/z5Fiwlk= X-Google-Smtp-Source: AA0mqf7exwNCLoarFZ4CYe+lKodYYdzQNrtfM7iF8/CTj8TkFA5kgu4d+QF5qqz8FfHiM2cFkfOxCA== X-Received: by 2002:a17:90a:5d81:b0:212:cf2e:2b0b with SMTP id t1-20020a17090a5d8100b00212cf2e2b0bmr83115345pji.169.1670008510351; Fri, 02 Dec 2022 11:15:10 -0800 (PST) Received: from nathanxps13 ([50.47.162.83]) by smtp.gmail.com with ESMTPSA id n5-20020a170902f60500b001871acf245csm5943069plg.37.2022.12.02.11.15.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 02 Dec 2022 11:15:09 -0800 (PST) Date: Fri, 2 Dec 2022 11:15:07 -0800 From: Nathan Bossart To: Bharath Rupireddy Cc: Simon Riggs , Robert Haas , Andres Freund , "Bossart, Nathan" , Maxim Orlov , Amul Sul , Bruce Momjian , "pgsql-hackers@postgresql.org" Subject: Re: O(n) tasks cause lengthy startups and checkpoints Message-ID: <20221202191507.GA2277157@nathanxps13> References: <20221128183129.ip3g5vrcbjrngpp2@awork3.anarazel.de> <20221128234039.GA1119654@nathanxps13> <20221130035653.GA1594993@nathanxps13> <20221130051833.GB1677223@nathanxps13> <20221201214026.GA1799688@nathanxps13> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Dec 02, 2022 at 12:11:35PM +0530, Bharath Rupireddy wrote: > On Fri, Dec 2, 2022 at 3:10 AM Nathan Bossart wrote: >> The test appears to reliably create snapshot and mapping files, so if the >> directories are empty at some point after the checkpoint at the end, we can >> be reasonably certain the custodian took action. I didn't add explicit >> checks that there are files in the directories before the checkpoint >> because a concurrent checkpoint could make such checks unreliable. > > I think you're right. I added sqls to see if the snapshot and mapping > files count > 0, see [1] and the cirrus-ci members are happy too - > https://github.com/BRupireddy/postgres/tree/custodian_review_2. I > think we can consider adding these count > 0 checks to tests. My worry about adding "count > 0" checks is that a concurrent checkpoint could make them unreliable. In other words, those checks might ordinarily work, but if an automatic checkpoint causes the files be cleaned up just beforehand, they will fail. > Having said above, I'm okay to process ShutdownRequestPending as early > as possible, however, should we also add CHECK_FOR_INTERRUPTS() > alongside ShutdownRequestPending? I'm not seeing a need for CHECK_FOR_INTERRUPTS. Do you see one? > While thinking about this, one thing that really struck me is what > happens if we let the custodian exit, say after processing > ShutdownRequestPending immediately or after a restart, leaving other > queued tasks? The custodian will never get to work on those tasks > unless the requestors (say checkpoint or some other process) requests > it to do so after restart. Maybe, we don't need to worry about it. > Maybe we need to worry about it. Maybe it's an overkill to save the > custodian's task state to disk so that it can come up and do the > leftover tasks upon restart. Yes, tasks will need to be retried when the server starts again. The ones in this patch set should be requested again during the next checkpoint. Temporary file cleanup would always be requested during server start, so that should be handled as well. Even today, the server might abruptly shut down while executing these tasks, and we don't have any special handling for that. -- Nathan Bossart Amazon Web Services: https://aws.amazon.com