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 1tGooC-0010C5-2Z for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Nov 2024 00:24:32 +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 1tGoo9-002Sr7-HY for pgsql-hackers@arkaria.postgresql.org; Fri, 29 Nov 2024 00:24:30 +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 1tGoo9-002Sqz-54 for pgsql-hackers@lists.postgresql.org; Fri, 29 Nov 2024 00:24:30 +0000 Received: from udcm-wwu1.uni-muenster.de ([128.176.118.7]) by magus.postgresql.org with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1tGoo7-0003cN-E9 for pgsql-hackers@lists.postgresql.org; Fri, 29 Nov 2024 00:24:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=uni-muenster.de; i=@uni-muenster.de; q=dns/txt; s=uniout; t=1732839869; x=1764375869; h=message-id:date:mime-version:subject:to:cc:references: from:in-reply-to:content-transfer-encoding; bh=uRkwuNzXhepTxaqIMLaGMxlHtPGquIqrWhh8VFfqmVQ=; b=oTFDV3zYHR4J6MhsBICQLjJ52a9VW/lBTQw4LkmeTmAcF2+EirfbVS80 xT9bnIOEp0R+V7Ad00SgLKgrkV8lE51FhoLMvnbmEKu/sGGnbTESgwcJE Zm7stTK+FDdk1bgHwnubM89HUA//skV08z7gRGtzkb6hwGjF4PPkwA7zH zzafSsUBaWmvxo5Pzc+kbIeceUVOLZ+D8PgBFNvpNkAM1WA3q+qgoxXNS fhcM/hvqhQkF9AotW7ACUZ6AayYOwYxt9+6S5uYwbSqw8FAl8FYLdRyQn oXcWvvTUtI30PmJuIA7xwXYK9YDx2ZsGY5XQqeKf2XCUXtRAvg1DgqGCk g==; X-CSE-ConnectionGUID: WPxgcQiARlqXih2Ix7gk/w== X-CSE-MsgGUID: R/jtQpYHT3a+K/yNHcJcnQ== X-IronPort-AV: E=Sophos;i="6.12,194,1728943200"; d="scan'208";a="350054913" Received: from secmail.uni-muenster.de ([128.176.118.4]) by UDCM-RELAY1.UNI-MUENSTER.DE with ESMTP; 29 Nov 2024 01:24:27 +0100 Received: from [192.168.178.27] (dynamic-093-131-193-064.93.131.pool.telefonica.de [93.131.193.64]) by SECMAIL.UNI-MUENSTER.DE (Postfix) with ESMTPSA id 8320E20A61E3; Fri, 29 Nov 2024 01:24:25 +0100 (CET) Message-ID: <8a240667-de9e-455b-b3e2-62f34ec80154@uni-muenster.de> Date: Fri, 29 Nov 2024 01:24:24 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: Truncate logs by max_log_size To: Kirill Gavrilov Cc: Kirill Reshke , "Andrey M. Borodin" , Euler Taveira , pgsql-hackers@lists.postgresql.org 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> Content-Language: en-US From: Jim Jones In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 28.11.24 20:20, Kirill Gavrilov wrote: >   Here is version 3 of this patch. I found another place where this > setting can be applied.  >   Also added some documentation and specified that this setting > truncates queries by size in bytes. Thanks. It is now possible to change the parameter using SET postgres=# SET max_log_size TO 15; SET postgres=# SHOW max_log_size ;  max_log_size --------------  15 (1 row) In the postgresql.conf the default value is set to 0 #max_log_size = 0 But if we take a look at the parameter it shows something else postgres=# SHOW max_log_size ;  max_log_size --------------  5242880 (1 row) Perhaps it would be best to keep the default value in the postgresql.conf consistent with the documentation and the actual max_log_size value. IMHO 0 (or -1) should disable it. There are also several compilation issues: postgres.c: In function ‘exec_simple_query’: postgres.c:1040:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]  1040 |         bool copied = false;       |         ^~~~ elog.c: In function ‘EmitErrorReport’: elog.c:1697:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]  1697 |         const char* old_query_string = debug_query_string;       |         ^~~~~ elog.c:1744:23: warning: passing argument 1 of ‘pfree’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]  1744 |                 pfree(debug_query_string);       |                       ^~~~~~~~~~~~~~~~~~ In file included from ../../../../src/include/postgres.h:47,                  from elog.c:55: ../../../../src/include/utils/palloc.h:86:25: note: expected ‘void *’ but argument is of type ‘const char *’    86 | extern void pfree(void *pointer);       |                   ~~~~~~^~~~~~~ elog.c: In function ‘build_query_log’: elog.c:3798:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]  3798 |         size_t query_len = strlen(query);       |         ^~~~~~ elog.c:3801:24: warning: return discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers]  3801 |                 return query;       |                        ^~~~~ elog.c:3805:9: warning: ISO C90 forbids mixed declarations and code [-Wdeclaration-after-statement]  3805 |         size_t query_log_len = pg_mbcliplen(query, query_len, max_log_size);       |         ^~~~~~ and there is a trailing whitespace at: + *    If query needs to be truncated, copied will be set to true /home/jim/patches/max_log_query/V3-0001-parameter-max_log_size-to-truncate-logs.patch:141: trailing whitespace.  *      If query needs to be truncated, copied will be set to true Checking patch doc/src/sgml/config.sgml... Hunk #1 succeeded at 7865 (offset -48 lines). Checking patch src/backend/tcop/postgres.c... Hunk #1 succeeded at 71 (offset 1 line). Hunk #2 succeeded at 1031 (offset 1 line). Hunk #3 succeeded at 1083 (offset 1 line). Hunk #4 succeeded at 1382 (offset 1 line). Hunk #5 succeeded at 1393 (offset 1 line). Checking patch src/backend/utils/error/elog.c... Hunk #4 succeeded at 3781 (offset -3 lines). Checking patch src/backend/utils/misc/guc_tables.c... Hunk #1 succeeded at 3714 (offset -10 lines). Checking patch src/backend/utils/misc/postgresql.conf.sample... Hunk #1 succeeded at 615 (offset -2 lines). Checking patch src/bin/pg_ctl/t/004_logrotate.pl... Checking patch src/include/utils/elog.h... Applied patch doc/src/sgml/config.sgml cleanly. Applied patch src/backend/tcop/postgres.c cleanly. Applied patch src/backend/utils/error/elog.c cleanly. Applied patch src/backend/utils/misc/guc_tables.c cleanly. Applied patch src/backend/utils/misc/postgresql.conf.sample cleanly. Applied patch src/bin/pg_ctl/t/004_logrotate.pl cleanly. Applied patch src/include/utils/elog.h cleanly. warning: 1 line adds whitespace errors. -- Jim