pg.ddx.io  GitHub: pgjdbc/pgjdbc (issues + PRs as email threads)  
help / color / mirror / Atom feed
From: vlsi (@vlsi) <noreply+vlsi@github.com>
To: pgjdbc/pgjdbc <noreply+pgjdbc-pgjdbc@github.com>
Subject: Re: [pgjdbc/pgjdbc] PR #4332 (changes requested): fix: limit FINEST Bind, Parse and SimpleQuery log messages to maxLogMessageLength to avoid OOM
Date: Wed, 14 Oct 2026 02:52:58 +0000
Message-ID: <gh-pgjdbc-pgjdbc-4332-r5512510295@github.com> (raw)
In-Reply-To: <gh-pgjdbc-pgjdbc-4332@github.com>
References: <gh-pgjdbc-pgjdbc-4332@github.com>

With `preferQueryMode=simple`, the driver inlines parameters into the SQL text, and `sendSimpleQuery` logs that text whole (`QueryExecutorImpl.java:2300`). A 200 MB `bytea` there still produces a trace of 400 million characters. Please bound this trace too: `LogMessageUtils.truncate(nativeSql, maxLogMessageLength)` inside an `isLoggable(Level.FINEST)` check covers it.

No test runs a statement through `QueryExecutorImpl`, so nothing checks that `maxLogMessageLength` reaches the traces. Please add a test that attaches a handler to the `org.postgresql` logger, runs statements on a live connection in extended and in simple query mode, and asserts the length of every record. Measure each record through `Formatter.formatMessage`: a record logged with parameters, such as the `SimpleQuery` one, carries only the format string in `getMessage()`.

A negative `maxLogMessageLength` is treated as `0`, that is, no limit (`QueryExecutorImpl.java:270`), and the documentation does not say so. Please document it or reject the value.

`BindLogTest` imports `assertEquals` without using it, so `autostyleJavaCheck` fails.

The new default changes what a FINEST trace contains, so the change needs a `CHANGELOG.md` entry.

The branch has a merge commit from master. Please rebase onto master instead of merging it into the branch.

The traces of server messages (`ErrorMessage`, `NoticeResponse`, `AsyncNotify`, `ParameterStatus`), the type-conversion trace in `PgConnection.getObject`, and a separate limit for one parameter, like `log_parameter_max_length` on the server, can wait. I will add them in a follow-up after this PR is merged, starting from the code in #4342.

view thread (58+ messages)  latest in thread

Message-ID: <gh-pgjdbc-pgjdbc-4332-r5512510295@github.com>
Permalink:  ../gh-pgjdbc-pgjdbc-4332-r5512510295@github.com/

 · 


This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox