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 1rksBW-00G3nS-7C for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Mar 2024 21:00:18 +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 1rksBT-003KgR-Rh for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Mar 2024 21:00:16 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1rksBT-003Kfa-IT for pgsql-hackers@lists.postgresql.org; Thu, 14 Mar 2024 21:00:16 +0000 Received: from mail-il1-x133.google.com ([2607:f8b0:4864:20::133]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1rksBQ-004WZP-Ci for pgsql-hackers@lists.postgresql.org; Thu, 14 Mar 2024 21:00:14 +0000 Received: by mail-il1-x133.google.com with SMTP id e9e14a558f8ab-366587c387bso8220535ab.1 for ; Thu, 14 Mar 2024 14:00:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710450012; x=1711054812; darn=lists.postgresql.org; 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=qrxSIJezCh5EzV/WpZO8KjR4UBgxGNKdh9lLvZsZsSw=; b=VJOhAGXepTyG6jd47OBsSDQGepnQaebMbTMKAKvpuwOPhRVJF6ZGghbNuJabbroyVR 3lutJHkB4H+HKpFtGqgsb4/QRVduXxAh9+sh81HSJNUfOQ/4Vc6DTSHZH2nTD+mpN5Ft 1emcW63SrFIlTzZIKWM4ouhb15FRxAlN2yE98HC+rQCdjNF9ZoYUEriKY15Tqz4hoQgm 2QT80yvpdjq35t/g2w5LLVn5ino4E1RXtILQ1Q+wC5ByOe3OytNvabW5sVSF0nBvjlaQ 3wWdofKkXvHPIrZGcPI0p81H28sWr12KLhn3V/e1yaGrd/zV/NDfzPVAE76QJ3e7UefU XEbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710450012; x=1711054812; 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=qrxSIJezCh5EzV/WpZO8KjR4UBgxGNKdh9lLvZsZsSw=; b=KqXr3tshe8QQkIPBwdlUmuioSIlFA+d6IQxW5FEPThH37EOE99bfrOfO93gDoYz6T2 m/n8wwua2o2SI2Y8i6KBjTJhUShlsvbhrlE7OImykX/IlwmhHiJm3B6bcL/dzf4tyWCG z0bNN1CGh9cZzBPIpfm6ghI24pv4UYGaq5ayi3KSwMmpO0xMSTpCHLXryCOB1m2dFkTA M1Qq/3CWFHJ228YItymAtg7Sl4/ytu636WmWgGrZlUnHU6Schk4YjgrM1G4PY8kyMtlC XSLLYw/hsthraPh0IyIjJAwkqdTNg59w+pU/08ykqF0vLYmK2Bxx19xORapN3PhOrNKG eGtg== X-Forwarded-Encrypted: i=1; AJvYcCWANVAaL6vbOa3Nozcu4C4D96CSEHLJoXEA9FDPKn7s2whe2M8xzLbLCAQDRqPtG1CmSSvwervHhSUfUC6pPPxJeBwpl6amTWiPTUgm/IhKqxm4 X-Gm-Message-State: AOJu0YyN8j+x7QZX9fln08R5fc3p9Q0n9eiLad2X9BUDbPfu3jWOTkl3 r1f4ANkFf1ewOEoFFwiXx8ZdbODztU0hNjE6aIVqlHBUOK1+87gn X-Google-Smtp-Source: AGHT+IFkjv7+Y7pEbr7n2LV3hnKaYPVmlT8iEmLbtT5qPd5HRxwxsHxYHU8mdLOpFZVAXaQpXA2ORA== X-Received: by 2002:a92:b709:0:b0:366:80a1:5f78 with SMTP id k9-20020a92b709000000b0036680a15f78mr2180118ili.2.1710450012421; Thu, 14 Mar 2024 14:00:12 -0700 (PDT) Received: from nathanxps13 (162-195-168-172.lightspeed.stlsmo.sbcglobal.net. [162.195.168.172]) by smtp.gmail.com with ESMTPSA id g4-20020a056e021e0400b00365cdc51c7esm349307ila.30.2024.03.14.14.00.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Mar 2024 14:00:12 -0700 (PDT) Date: Thu, 14 Mar 2024 16:00:10 -0500 From: Nathan Bossart To: Robert Haas Cc: Matthias van de Meent , PostgreSQL Hackers Subject: Re: cleanup patches for incremental backup Message-ID: <20240314210010.GA3056455@nathanxps13> References: <20240124170846.GA2643050@nathanxps13> <20240124180515.GA2709722@nathanxps13> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="rwEMma7ioTxnRzrJ" Content-Disposition: inline In-Reply-To: <20240124180515.GA2709722@nathanxps13> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --rwEMma7ioTxnRzrJ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Jan 24, 2024 at 12:05:15PM -0600, Nathan Bossart wrote: > There might be an overflow risk in the cutoff time calculation, but I doubt > that's the root cause of these failures: > > /* > * Files should only be removed if the last modification time precedes the > * cutoff time we compute here. > */ > cutoff_time = time(NULL) - 60 * wal_summary_keep_time; I've attached a short patch for fixing this overflow risk. Specifically, it limits wal_summary_keep_time to INT_MAX / SECS_PER_MINUTE, just like log_rotation_age. I considering checking for overflow when we subtract the keep-time from the result of time(2), but AFAICT there's only a problem if time_t is unsigned, which Wikipedia leads me to believe is unusual [0], so I figured we might be able to just wait this one out until 2038. > Otherwise, I think we'll probably need to add some additional logging to > figure out what is happening... Separately, I suppose it's probably time to revert the temporary debugging code adding by commit 5ddf997. I can craft a patch for that, too. [0] https://en.wikipedia.org/wiki/Unix_time#Representing_the_number -- Nathan Bossart Amazon Web Services: https://aws.amazon.com --rwEMma7ioTxnRzrJ Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="overflow_fix.patch" diff --git a/src/backend/postmaster/walsummarizer.c b/src/backend/postmaster/walsummarizer.c index ec2874c18c..c820d1f9ed 100644 --- a/src/backend/postmaster/walsummarizer.c +++ b/src/backend/postmaster/walsummarizer.c @@ -139,7 +139,7 @@ static XLogRecPtr redo_pointer_at_last_summary_removal = InvalidXLogRecPtr; * GUC parameters */ bool summarize_wal = false; -int wal_summary_keep_time = 10 * 24 * 60; +int wal_summary_keep_time = 10 * HOURS_PER_DAY * MINS_PER_HOUR; static void WalSummarizerShutdown(int code, Datum arg); static XLogRecPtr GetLatestLSN(TimeLineID *tli); @@ -1474,7 +1474,7 @@ MaybeRemoveOldWalSummaries(void) * Files should only be removed if the last modification time precedes the * cutoff time we compute here. */ - cutoff_time = time(NULL) - 60 * wal_summary_keep_time; + cutoff_time = time(NULL) - wal_summary_keep_time * SECS_PER_MINUTE; /* Get all the summaries that currently exist. */ wslist = GetWalSummaries(0, InvalidXLogRecPtr, InvalidXLogRecPtr); diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index 57d9de4dd9..1e71e7db4a 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -3293,9 +3293,9 @@ struct config_int ConfigureNamesInt[] = GUC_UNIT_MIN, }, &wal_summary_keep_time, - 10 * 24 * 60, /* 10 days */ + 10 * HOURS_PER_DAY * MINS_PER_HOUR, /* 10 days */ 0, - INT_MAX, + INT_MAX / SECS_PER_MINUTE, NULL, NULL, NULL }, --rwEMma7ioTxnRzrJ--