Skip to content

branch-4.2: [fix](fe) Backport prepared statement protocol fixes to branch-4.2 - #69463

Merged
yiguolei merged 1 commit into
apache:branch-4.2from
CalvinKirs:backport-69314-branch-4.2
Oct 24, 2026
Merged

yiguolei merged 1 commit into
apache:branch-4.2from
CalvinKirs:backport-69314-branch-4.2

Conversation

@CalvinKirs

Copy link
Copy Markdown
Member

What problem does this PR solve?

Related PR: #69314

Problem Summary:

  • COM_STMT_SEND_LONG_DATA returns an unexpected response and does not bind uploaded chunks, leaving streaming clients out of sync. Accept chunks without replying, defer upload errors until EXECUTE, and clear uploaded data after execution or RESET.
  • Reusing cached server-prepared statements through a non-master FE can fail because the master prepares each forwarded execution independently. Forward complete parameter types and values, including streamed parameters, and use the active prepare-stage context during proxy planning.
  • Empty results with useCursorFetch=true can hang or leave unread packets, including when connection attributes are absent or rewritten. Return an empty cursor, complete FETCH with LAST_ROW_SENT, and preserve framing for older FEs through an optional peer capability.
  • Completed EXECUTE payloads can remain attached to idle connections. Release command payload buffers after response finalization and forwarding finish.

Backport adaptations for branch-4.2:

  • Keep protocol state in the existing ConnectContext/ConnectProcessor architecture and preserve branch-4.2's expansion of cached parameter types only when forwarding.
  • Regenerate regression expectations with the standard test script to retain branch-4.2's existing VARBINARY function semantics.

Release note

Fix streamed prepared parameters, repeated prepared execution through non-master FEs, and empty cursor fetch hangs.

Check List (For Author)

  • Test

    • Regression test: prepared_stmt_p0/send_long_data and prepared_stmt_p0/cursor_fetch_empty_result passed with run-regression-test.sh.
    • Unit Test: 91 FE tests passed with run-fe-ut.sh, with zero failures, errors or skips.
    • Manual test: Connector/J 8.0.27, 8.0.33, 8.4.0 and 9.7.0 each passed 428 checks against the built branch-4.2 FE and BE 4.1.3. Connect explicitly to master and follower endpoints; verify streamed bytes, empty streams and statement reuse; run 50 batches of three rows per version and compare all stored values; alternate empty/nonempty cursor results with and without connection attributes, including forwarded execution and connection reuse.
    • Full FE build passed via build.sh --fe; Checkstyle passed with zero violations.
  • Behavior changed:

    • Yes. Long-data uploads have no response; forwarded parameters are self-contained; empty cursors complete through FETCH; completed command buffers are released.
  • Does this need documentation?

    • No.

Check List (For Reviewer who merge this PR)

  • Confirm the release note
  • Confirm test cases
  • Confirm document
  • Add branch pick label

### What problem does this PR solve?

Related PR: apache#69314

Problem Summary:
- COM_STMT_SEND_LONG_DATA incorrectly sends a response and does not bind uploaded chunks, leaving streaming clients out of sync. Accumulate data per statement, defer errors to EXECUTE and clear data after execution or RESET.
- Preserve complete parameter types and uploaded values when forwarding prepared execution to the master. Keep branch-4.2's existing expansion of cached types only on the forwarding path, and use the active prepare context during proxy planning.
- Empty cursor results can consume their only terminator and hang Connector/J. Advertise an empty cursor and complete FETCH locally, track actual rows, and retain old-FE framing through an optional peer capability.
- Release execute payload buffers when the command completes.

Adapt protocol state to branch-4.2's existing ConnectContext and ConnectProcessor. Generate regression expectations using branch-4.2's existing VARBINARY function semantics.

### Release note

Fix streamed prepared parameters, prepared execution through non-master FEs, and empty cursor fetch hangs.

### Check List (For Author)

- Test: Unit Test / Regression test / Manual test
    - 91 FE unit tests passed; full FE build and Checkstyle passed.
    - send_long_data and cursor_fetch_empty_result regression suites passed.
    - Connector/J 8.0.27, 8.0.33, 8.4.0 and 9.7.0 passed master/follower streaming, 50-round batched inserts and empty/nonempty cursor checks against the built FE and BE 4.1.3.
- Behavior changed: Yes (correct no-response upload and empty-cursor protocol behavior)
- Does this need documentation: No

(cherry picked from commit 6fafa31)
@CalvinKirs
CalvinKirs requested a review from yiguolei as a code owner October 22, 2026 10:14
@hello-stephen

Copy link
Copy Markdown
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?

@CalvinKirs

Copy link
Copy Markdown
Member Author

run buildall

@CalvinKirs CalvinKirs changed the title [fix](fe) Backport prepared statement protocol fixes to branch-4.2 branch-4.2: [fix](fe) Backport prepared statement protocol fixes to branch-4.2 Oct 22, 2026
@hello-stephen

Copy link
Copy Markdown
Contributor

FE Regression Coverage Report

Increment line coverage 65.31% (96/147) 🎉
Increment coverage report
Complete coverage report

@hello-stephen

Copy link
Copy Markdown
Contributor

BE Regression && UT Coverage Report

Increment line coverage 100% (0/0) 🎉

Increment coverage report
Complete coverage report

Category Coverage
Function Coverage 76.36% (34499/45177)
Line Coverage 61.17% (389486/636684)
Region Coverage 57.94% (327856/565851)
Branch Coverage 58.92% (151386/256939)

@yiguolei

Copy link
Copy Markdown
Contributor

skip buildall

@yiguolei
yiguolei merged commit f61f79c into apache:branch-4.2 Oct 24, 2026
38 of 39 checks passed
@CalvinKirs
CalvinKirs deleted the backport-69314-branch-4.2 branch October 26, 2026 06:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants