[Bug][Arrow Flight SQL] DDL statements via Flight SQL crash with getMysqlChannel RuntimeException after 4.0.5 CLIENT_DEPRECATE_EOF fix

Open Beginner friendly
#62,017 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
82/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
java, sql

Research direction

Start in StmtExecutor.java at the sendFields locations around lines 1537 and 1587, then inspect FlightSqlConnectContext.java and the existing guard in InsertIntoTableCommand.java around line 383. Reproduce the failure with the provided ADBC Flight SQL CREATE DATABASE example and verify that DDL succeeds through Flight SQL while MySQL EOF handling remains unchanged.

Written by the indexing model from the issue text.

Description

Search before asking
  • I had searched in the issues and found no similar issues.
Version

4.0.5

What happened

DDL statements (CREATE DATABASE, CREATE TABLE, etc.) executed via Arrow Flight SQL protocol crash with:

java.lang.RuntimeException: getMysqlChannel not in mysql connection

This is a regression introduced in 4.0.5 (works in 4.0.3). The root cause is commit 1a8590e0b22 ("fix Support CLIENT_DEPRECATE_EOF to fix empty result with MySQL driver 9.5.0 #61050 (#61062)").

Root Cause Analysis

The CLIENT_DEPRECATE_EOF fix added context.getMysqlChannel().clientDeprecatedEOF() calls in StmtExecutor.java at two locations (lines ~1537 and ~1587):

if (!context.getMysqlChannel().clientDeprecatedEOF()) {
    // send EOF packet
}

These code paths are also traversed during Flight SQL DDL execution. However, FlightSqlConnectContext.getMysqlChannel() throws RuntimeException("getMysqlChannel not in mysql connection") (see FlightSqlConnectContext.java:54-56), because Flight SQL does not use MySQL channels.

The fix should add a connectType check before calling getMysqlChannel():

if (context.getConnectType() == ConnectType.MYSQL 
    && !context.getMysqlChannel().clientDeprecatedEOF()) {
    // send EOF packet
}

Similar guards already exist in other parts of the codebase, e.g., InsertIntoTableCommand.java:383:

if (ctx.getConnectType() == ConnectType.MYSQL && ctx.getMysqlChannel() != null) {
    ctx.getMysqlChannel().reset();
}
Full Stack Trace
INTERNAL: [FlightSQL] get flight info statement failed, after executeQueryStatement handleQuery, 
java.lang.RuntimeException: after executeQueryStatement handleQuery, error code: ERR_UNKNOWN_ERROR, 
error msg: RuntimeException, msg: getMysqlChannel not in mysql connection (Internal; ExecuteQuery)

  at org.apache.doris.service.arrowflight.sessions.FlightSqlConnectContext.getMysqlChannel(FlightSqlConnectContext.java:55)
  at org.apache.doris.qe.StmtExecutor.sendFields(StmtExecutor.java:1537)
What you expected to happen

DDL statements should execute successfully via Arrow Flight SQL, as they did in 4.0.3.

How to reproduce
  1. Connect to Doris 4.0.5 using ADBC Flight SQL client (e.g., adbc_driver_flightsql)
  2. Execute any DDL statement:
import adbc_driver_flightsql.dbapi as flight_sql

conn = flight_sql.connect(uri="grpc://fe-host:8070", db_kwargs={"username": "root", "password": "pass"})
cursor = conn.cursor()
cursor.execute("CREATE DATABASE IF NOT EXISTS test_db")  # CRASHES
  1. Error: RuntimeException: getMysqlChannel not in mysql connection
Anything else
  • Workaround: Execute DDL statements via the HTTP SQL API (POST /api/query/{catalog}/{db}) instead of Flight SQL.
  • Affected versions: 4.0.5, 4.0.5-rc01
  • Working versions: 4.0.3-rc03 and earlier
  • Regression commit: 1a8590e0b22 (cherry-pick of #61050 as #61062)
Are you willing to submit PR?
  • Yes I am willing to submit a PR!
Code of Conduct
Dominant language
Java
Stars
16k
Forks
4k
Avg merge
2d 12h
Merged PRs (30d)
569

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from apache/doris

All issues in apache/doris

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.