This is an automated email from the ASF dual-hosted git repository.
xiangfu0 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pinot.git
The following commit(s) were added to refs/heads/master by this push:
new 2f8fd729c30 Apply the query log length limit to the query received log
line (#20430)
2f8fd729c30 is described below
commit 2f8fd729c3030f90220e6b3f3ba061c07541a183
Author: Arunkumar Saravanan <[email protected]>
AuthorDate: Wed Dec 2 02:46:54 2026 +0530
Apply the query log length limit to the query received log line (#20430)
Apply the configured broker query log length to the redacted SQL in the
received record, matching the completion record.
To reproduce the original issue, set pinot.broker.query.log.length to 20,
leave received logging enabled, and submit SQL longer than 20 characters. The
received record prints the full SQL.
---
.../org/apache/pinot/broker/querylog/QueryLogger.java | 2 +-
.../org/apache/pinot/broker/querylog/QueryLoggerTest.java | 15 +++++++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git
a/pinot-broker/src/main/java/org/apache/pinot/broker/querylog/QueryLogger.java
b/pinot-broker/src/main/java/org/apache/pinot/broker/querylog/QueryLogger.java
index f1df0ae5c46..7619a14aa85 100644
---
a/pinot-broker/src/main/java/org/apache/pinot/broker/querylog/QueryLogger.java
+++
b/pinot-broker/src/main/java/org/apache/pinot/broker/querylog/QueryLogger.java
@@ -138,7 +138,7 @@ public class QueryLogger {
if (_logBeforeProcessing) {
_logger.info(QUERY_RECEIVED_MARKER, "SQL query for request {}: {}",
requestId,
- redactQuery(query, queryFingerprint));
+ StringUtils.substring(redactQuery(query, queryFingerprint), 0,
_maxQueryLengthToLog));
}
tryLogDropped();
diff --git
a/pinot-broker/src/test/java/org/apache/pinot/broker/querylog/QueryLoggerTest.java
b/pinot-broker/src/test/java/org/apache/pinot/broker/querylog/QueryLoggerTest.java
index 796a0df53e2..2b1732e7e2f 100644
---
a/pinot-broker/src/test/java/org/apache/pinot/broker/querylog/QueryLoggerTest.java
+++
b/pinot-broker/src/test/java/org/apache/pinot/broker/querylog/QueryLoggerTest.java
@@ -243,6 +243,21 @@ public class QueryLoggerTest {
Assert.assertTrue(_infoLog.get(0).contains("SQL query for request 123"));
}
+ @Test
+ public void shouldTruncateQueryReceivedToMaxQueryLength() {
+ // Given: a query longer than the configured max length, e.g. one carrying
a large vector literal
+ when(_logRateLimiter.tryAcquire()).thenReturn(true);
+ QueryLogger queryLogger = new QueryLogger(_logRateLimiter, 20, true, true,
+ SqlRedactionMode.NONE, _logger, _droppedRateLimiter);
+
+ // When:
+ queryLogger.logQueryReceived(123L, "SELECT * FROM foo WHERE
vectorSimilarity(v, ARRAY[0.1, 0.2, 0.3], 10)",
+ null);
+
+ // Then: the received record honors the same limit as the completion record
+ assertEquals(_infoLog, List.of("SQL query for request 123: SELECT * FROM
foo WH"));
+ }
+
@Test
public void shouldMarkOnlyTheQueryReceivedRecord() {
// Given:
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]