Skip to content

Conversation

@zddr
Copy link
Contributor

@zddr zddr commented Jul 29, 2025

…us queryId when parseSQL fails. (#53107)

pick: #53107

…us queryId when parseSQL fails. (apache#53107)

### What problem does this PR solve?

Issue:
- When parsing SQL, the queryId has not yet been generated. However, the
audit log retrieves the queryId from ConnectContext, which means it uses
the queryId from the previous execution.
- The queryId stored in queryCache is from the previous query, not the
current one.

Solution:
- Since parsing may produce multiple SQL statements, each should have
its own queryId. Therefore, the queryId should not be set during
parsing. As a compromise, we clear the queryId before parsing, ensuring
that the audit log records an empty queryId if parsing fails.
- Set the queryId when adding the cache, not in the constructor.
# Conflicts:
#	fe/fe-core/src/main/java/org/apache/doris/common/cache/NereidsSqlCacheManager.java
#	fe/fe-core/src/main/java/org/apache/doris/qe/ConnectContext.java
#	fe/fe-core/src/main/java/org/apache/doris/qe/ConnectProcessor.java
#	fe/fe-core/src/test/java/org/apache/doris/qe/ConnectContextTest.java
@zddr zddr requested a review from yiguolei as a code owner July 29, 2025 03:54
@hello-stephen
Copy link
Contributor

Thank you for your contribution to Apache Doris.
Don't know what should be done next? See How to process your PR.

Please clearly describe your PR:

  1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
  2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
  3. What features were added. Why was this function added?
  4. Which code was refactored and why was this part of the code refactored?
  5. Which functions were optimized and what is the difference before and after the optimization?

@zddr
Copy link
Contributor Author

zddr commented Jul 29, 2025

run buildall

@zddr
Copy link
Contributor Author

zddr commented Jul 29, 2025

run feut

1 similar comment
@zddr
Copy link
Contributor Author

zddr commented Jul 29, 2025

run feut

@zddr
Copy link
Contributor Author

zddr commented Aug 15, 2025

run buildall

@github-actions github-actions bot added the approved Indicates a PR has been approved by one committer. label Sep 11, 2025
@github-actions
Copy link
Contributor

PR approved by at least one committer and no changes requested.

@github-actions
Copy link
Contributor

PR approved by anyone and no changes requested.

@yiguolei yiguolei merged commit 5146a59 into apache:branch-2.1 Sep 11, 2025
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by one committer. reviewed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants