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 1tHHRT-005WBg-F2 for pgsql-hackers@arkaria.postgresql.org; Sat, 30 Nov 2024 06:58:59 +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 1tHHRP-00E3Vc-T6 for pgsql-hackers@arkaria.postgresql.org; Sat, 30 Nov 2024 06:58:57 +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 1tHHRP-00E3VU-JM for pgsql-hackers@lists.postgresql.org; Sat, 30 Nov 2024 06:58:56 +0000 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1tHHRK-000H7v-3R for pgsql-hackers@lists.postgresql.org; Sat, 30 Nov 2024 06:58:56 +0000 Received: by mail-lj1-x22a.google.com with SMTP id 38308e7fff4ca-2ffc86948dcso26181411fa.2 for ; Fri, 29 Nov 2024 22:58:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1732949929; x=1733554729; darn=lists.postgresql.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=c5Po6y1eOn5zON0+P5Io7Ei1v5tvmItjhjRaFaSAODk=; b=mlNZv3M/ByyMdp5LmADZSrqleFTmYDk/tK8j/UGSU1SsIz5psIxcAPHu2RHIkPgIUl YVhvvt8xecmVOsigOpylEehiErAR+9mc3777S0ZJTFQZgwXDrwlFP+DJs5SQi2EWyYgG hLTQuxv0vL5n05TKa5/+whoqAd1ijzXNOZ/AbNf8FTQlKlD1FU515fFYihGDF3O2WQBW UHQbkexQQgWjxI8mR5/FH0vdoewN2oSBY4GcoCBJweK5XGgzwsg8JhfAcr0UrUryMmbZ 3Has3agLF2h4O//K6CJyUnF1cC6xTiuBlV5aUYam6DYFYdTqhy4bqfKaGvrbpYdct0eR wTpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1732949929; x=1733554729; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=c5Po6y1eOn5zON0+P5Io7Ei1v5tvmItjhjRaFaSAODk=; b=jC5X6X2mZhAaaC1TaWsk3Pq/SSJ3tQf9CYyEgieeTRFbpPPlqFDELUPgZ4TPd6W4IX cn7PYEzEoU+Vzn2AIofZ0iZofgnxRiOIxbjmPmQ5QhrtAcbqhtGqWP5iDejxXQbSJVAz 9vyLHUCiowhM4MeZZH1UHhsrNNIbaCnPk3MDFT941YGij5VRfF41C+5MTJGtCKymSSws PD2jtSkmo5MziSS56zb5JYLY7BrrXeRyNPhw2DPTVW6+PxtXYxMHRJ7Oqh+hWKT/VDdm ykd6kww7XHPD3Iet2ko4Nj4cQSZaag4ME7kxiSghIlRWsdwXl10mVXhchQdiNfdSHl7X D4Fw== X-Forwarded-Encrypted: i=1; AJvYcCWKi35b0LR5ClOgGaD3u9E241FDYkqsaJn94eoUY0/0o7oPMtDs0xayPxB41Ni/V/eTYZLK+mKhOmCkSe22@lists.postgresql.org X-Gm-Message-State: AOJu0Ywa2HcMZZgIaO+E2gd00UjXcz4jmQA+EeWFNbZEeCAP0vYjIUPe FeWKITHUXFP+O+cvSrnju0lEUHy2SqeL9AF0ALkdMU/ercdXhstS28fr7RYVa7j0mOo9qqFIo6U mydmW4nvRmh21lNjnLMdrFU7Y2nk= X-Gm-Gg: ASbGncujv2GbG/A0aliG++JSI/UMpt/94ZtCBEQFM3nOzNZk/LQwtrYESydFm1dorgp f/9+8CO1nSaBV4V0lno/6XaRrO33Y X-Google-Smtp-Source: AGHT+IEImR7Spsi92bFhkfvW3HW9JY4RLvI4Ed2LAQmRcrZASl/esyuRZ3c2uBqF6BjKO2yNYYfpSo8uoI85Ols+yhc= X-Received: by 2002:a05:651c:b0b:b0:2ff:d2c8:84fb with SMTP id 38308e7fff4ca-2ffd6086d63mr78116541fa.24.1732949929239; Fri, 29 Nov 2024 22:58:49 -0800 (PST) MIME-Version: 1.0 References: <94d53a41-d1f5-4fd1-8d1e-ff36ac569848@app.fastmail.com> <4DA5A159-39FD-47DB-95E5-A4F65BC5782A@yandex-team.ru> <53e96b5a-cc77-4afa-8103-79c69afef1a6@uni-muenster.de> <748a7ec0-9126-4f27-a2a7-e3e449d6fdd7@uni-muenster.de> <8a240667-de9e-455b-b3e2-62f34ec80154@uni-muenster.de> <3f1b817f-6e7a-4e01-bfc5-50ea3724225e@uni-muenster.de> In-Reply-To: From: Kirill Reshke Date: Sat, 30 Nov 2024 11:58:38 +0500 Message-ID: Subject: Re: Truncate logs by max_log_size To: Kirill Gavrilov Cc: Jim Jones , "Andrey M. Borodin" , Euler Taveira , pgsql-hackers@lists.postgresql.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Sat, 30 Nov 2024 at 01:57, Kirill Gavrilov wrote: > > On Fri, Nov 29, 2024 at 10:12=E2=80=AFPM Jim Jones wrote: >> >> >> >> On 29.11.24 12:05, Kirill Gavrilov wrote: >> > Setting max_log_size to 0 already disables truncation. >> > I changed guc units to bytes, just to make it more human-friendly. >> > Did some refactoring and fixed all warnings. Set default value in >> > postgresql.conf. >> >> Nice. The patch applies cleanly and the warnings are gone. >> >> A few other things: >> >> IMHO the documentation can be a bit clearer. It says to input the values >> in bytes, but the default value is in megabytes. >> >> + If greater than zero, each query logged is truncated to this >> many bytes. >> + Zero disables the setting. >> + Default value is 5MB. >> >> Perhaps something like "If this value is specified without units, it is >> taken as bytes." (see wal_keep_size) > > > Added to documentation. I hope it's clear now. > >> >> >> And a pedantic note: This hint suggests that you can use TB as unit .. >> >> postgres=3D# set max_log_size =3D '1foo'; >> ERROR: invalid value for parameter "max_log_size": "1foo" >> HINT: Valid units for this parameter are "B", "kB", "MB", "GB", and "TB= ". >> >> .. but it can never be used, as it exceeds the integer range: >> >> postgres=3D# SET max_log_size =3D '1TB'; >> ERROR: invalid value for parameter "max_log_size": "1TB" >> HINT: Value exceeds integer range. >> >> Thanks >> >> -- >> Jim > > > Same thing applies to log_parameter_max_length, for example. > > postgres=3D# set log_parameter_max_length =3D '1foo'; > ERROR: invalid value for parameter "log_parameter_max_length": "1foo" > HINT: Valid units for this parameter are "B", "kB", "MB", "GB", and "TB"= . > postgres=3D# set log_parameter_max_length =3D '1TB'; > ERROR: invalid value for parameter "log_parameter_max_length": "1TB" > HINT: Value exceeds integer range. > > I think we can leave it as is. Hi > +for (my $attempts =3D 0; $attempts < $max_attempts; $attempts++) > +{ > + eval { > + $current_logfiles =3D slurp_file($node->data_dir . '/current_logfiles')= ; > + }; > + last unless $@; > + usleep(100_000); > +} `usleep` in tap tests is usually a bad pattern. Do we have a chance to test this using `wait_for_log` or similar? --=20 Best regards, Kirill Reshke