You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by "shivam-startree (via GitHub)" <gi...@apache.org> on 2026/09/03 21:45:44 UTC

[PR] Log a query on a single line [pinot]

shivam-startree opened a new pull request, #19453:
URL: https://github.com/apache/pinot/pull/19453

   ## Summary
   
   Collapses CR/LF runs in a query to a single space before it is logged, so one logged query occupies one physical log line.
   
   ## Motivation
   
   Clients routinely submit pretty-printed SQL — JDBC and BI tools do so by default — and the broker logs the query verbatim. A single log *event* then renders as one physical *line per line of SQL* as soon as anything downstream splits on newlines: a container runtime, a log shipper, a file tailer.
   
   Measured on one production broker, 60s window, 3,995 queries:
   
   | | lines | per query |
   |---|---|---|
   | `SQL query for request <id>:` headers | 3,995 | 1 |
   | continuation lines after them | 30,975 | 7.8 |
   | completion stats lines | 3,994 | 1 |
   | continuation lines after those | 30,969 | 7.8 |
   | **total continuation lines** | **61,944** | **79.4% of that broker's entire log volume** |
   
   Collapsing newlines removes those 61,944 lines while keeping both log records and every field they carry — 2 lines per query instead of 15.5.
   
   The continuation lines are also harmful beyond their volume: they carry no timestamp, level or logger name, so nothing downstream can filter, sample or attribute them, and a multiline log collector will attach them to whichever record happened to precede them — silently corrupting an unrelated log entry as well as the query. We observed exactly that: SQL fragments glued onto the tail of unrelated broker log lines.
   
   ## Implementation
   
   Applied inside `redactQuery`, which every query-logging call site in the broker already routes through — roughly 45 of them across `QueryLogger`, `BaseSingleStageBrokerRequestHandler` and `MultiStageBrokerRequestHandler`. Every caller is a log statement, so normalising there is consistent with the method's purpose, and the error/cancellation paths get the same treatment rather than only the two `QueryLogger` sites.
   
   ## Backward compatibility
   
   No config changes, no new options, no API changes.
   
   Deliberately conservative: **only line breaks are touched.** Indentation and spacing within a line are left alone, so the logged text stays as close to what the client submitted as a single-line rendering allows and remains copy-pasteable. `SqlRedactionMode.FULL` and `LITERAL_VALUES` are unaffected — neither returns a multi-line value.
   
   The one behavioural edge: a newline inside a string literal becomes a space in the log output. That is already true of any single-line log rendering, and collapsing *all* whitespace (the alternative) would additionally mangle intra-literal spacing — which is why this only touches CR/LF.
   
   ## Tests
   
   Two tests, one per log site (`logQueryReceived` and `logQueryCompleted`), plus a `generateParams` overload so a test can supply the query text.
   
   ## Note for reviewers
   
   I was unable to build locally — `master` now requires JDK 25 and only 21 was available on this machine, and the `-Djdk.version=21` fallback fails on dependency class-file versions. The regex output was verified character-for-character against the assertion strings, but I am relying on CI for compile and test. Opened as a draft for that reason; happy to mark ready once CI is green.
   
   ## Related
   
   Companion draft adds a `QUERY_RECEIVED` marker so the two per-query records become separately routable. Independent of this change — that one affects addressability, this one affects rendering.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Log a query on a single line [pinot]

Posted by "xiangfu0 (via GitHub)" <gi...@apache.org>.
xiangfu0 merged PR #19453:
URL: https://github.com/apache/pinot/pull/19453


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Log a query on a single line [pinot]

Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #19453:
URL: https://github.com/apache/pinot/pull/19453#issuecomment-5532957067

   ## [Codecov](https://app.codecov.io/gh/apache/pinot/pull/19453?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
   :white_check_mark: All modified and coverable lines are covered by tests.
   :white_check_mark: Project coverage is 100.00%. Comparing base ([`ca71554`](https://app.codecov.io/gh/apache/pinot/commit/ca71554fc9d7a6012e5f6cf6c55c9dcd320c8526?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`5c0ed16`](https://app.codecov.io/gh/apache/pinot/commit/5c0ed1652aee93113fc22c5799474949394d4671?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
   
   <details><summary>Additional details and impacted files</summary>
   
   
   
   ```diff
   @@              Coverage Diff               @@
   ##             master    #19453       +/-   ##
   ==============================================
   + Coverage     67.61%   100.00%   +32.38%     
   + Complexity     1430         6     -1424     
   ==============================================
     Files          3488         3     -3485     
     Lines        224395         6   -224389     
     Branches      35422         0    -35422     
   ==============================================
   - Hits         151725         6   -151719     
   + Misses        60638         0    -60638     
   + Partials      12032         0    -12032     
   ```
   
   | [Flag](https://app.codecov.io/gh/apache/pinot/pull/19453/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | |
   |---|---|---|
   | [integration](https://app.codecov.io/gh/apache/pinot/pull/19453/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `100.00% <ø> (ø)` | |
   | [integration1](https://app.codecov.io/gh/apache/pinot/pull/19453/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `100.00% <ø> (ø)` | |
   | [integration2](https://app.codecov.io/gh/apache/pinot/pull/19453/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [java-25](https://app.codecov.io/gh/apache/pinot/pull/19453/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `100.00% <ø> (+32.38%)` | :arrow_up: |
   | [lane-a](https://app.codecov.io/gh/apache/pinot/pull/19453/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `100.00% <ø> (ø)` | |
   | [lane-b](https://app.codecov.io/gh/apache/pinot/pull/19453/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `0.00% <ø> (ø)` | |
   | [temurin](https://app.codecov.io/gh/apache/pinot/pull/19453/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `100.00% <ø> (+32.38%)` | :arrow_up: |
   | [unittests](https://app.codecov.io/gh/apache/pinot/pull/19453/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [unittests1](https://app.codecov.io/gh/apache/pinot/pull/19453/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   | [unittests2](https://app.codecov.io/gh/apache/pinot/pull/19453/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
   </details>
   
   [:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/pinot/pull/19453?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).   
   :loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
   <details><summary> :rocket: New features to boost your workflow: </summary>
   
   - :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
   </details>


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Log a query on a single line [pinot]

Posted by "xiangfu0 (via GitHub)" <gi...@apache.org>.
xiangfu0 commented on PR #19453:
URL: https://github.com/apache/pinot/pull/19453#issuecomment-5593491095

   Documentation follow-up: https://github.com/pinot-contrib/pinot-docs/pull/1037 (merged).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


Re: [PR] Log a query on a single line [pinot]

Posted by "shivam-startree (via GitHub)" <gi...@apache.org>.
shivam-startree commented on PR #19453:
URL: https://github.com/apache/pinot/pull/19453#issuecomment-5536202347

   Good catch — corrected in `f9921e4`.
   
   Replacing a newline with a space is not semantics-preserving, because a newline terminates a line comment. Pinot's grammar accepts both forms:
   
   ```
   <SINGLE_LINE_COMMENT: ("//"|"--")(~["\n","\r"])* ("\n"|"\r"|"\r\n")? >
   ```
   
   so
   
   ```sql
   SELECT a -- note
   FROM t
   ```
   
   would have been logged as `SELECT a -- note FROM t` — which no longer parses, and no longer means what was run. The logged query is something people copy and replay, so quietly changing it is worse than leaving it on several lines.
   
   Now escapes CR/LF as `\r` / `\n` instead. Still one physical line, but no character is removed or reinterpreted, so the record says exactly what was executed. A query already on one line is returned untouched.
   
   The trade-off is that the logged text needs unescaping before replay. That seemed clearly better than a form that is silently wrong, but happy to reconsider if you'd prefer a different rendering.
   
   Also checked for an existing helper before adding one: `LoggerUtils` is the runtime log-level API, and `commons-text` is managed in the root pom but is not a `pinot-broker` dependency — and `StringEscapeUtils.escapeJava` would be too aggressive here, escaping double quotes and unicode and so mangling quoted identifiers. No existing precedent in the tree for escaping newlines in logged user text, hence the local two-character replace. Happy to move it to a shared util if you'd rather.
   
   Added a regression test for the comment case and one asserting single-line queries pass through unchanged.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org