-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[feat](protocol)extract protocol definitions (part 1) #60355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
CalvinKirs
wants to merge
13
commits into
apache:master
Choose a base branch
from
CalvinKirs:master-new-protocol
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Contributor
|
Thank you for your contribution to Apache Doris. Please clearly describe your PR:
|
# Conflicts: # fe/fe-core/src/main/java/org/apache/doris/mysql/MysqlPassword.java # fe/fe-core/src/test/java/org/apache/doris/qe/ConnectContextTest.java
Member
Author
|
run buildall |
Member
Author
|
run buildall |
Member
Author
|
run buildall |
1 similar comment
Member
Author
|
run buildall |
Member
Author
|
run buildall |
When an insert task is canceled during execution, the shared `ctx` object may be set to null. Currently, after `command.runWithUpdateInfo(...)`, the code directly accesses `ctx.getState()`. If `ctx` is null or its state is null, this leads to a NullPointerException (NPE). ### Solution - Cache the `ctx` reference to a local variable to avoid race conditions. - Check both `ctx` and `ctx.getState()` for null before accessing. - If the task was canceled or the state is null, safely return without throwing an exception. - Maintain existing behavior: if the task completes with a non-OK state, still throw `JobException`. ### Impact - Prevents NPE when a task is canceled during execution. - Makes the insert task more robust in concurrent cancel scenarios.
Contributor
FE UT Coverage ReportIncrement line coverage |
Member
Author
|
run buildall |
Contributor
FE UT Coverage ReportIncrement line coverage |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What problem does this PR solve?
#60361
Overview
This document describes Apache Doris multi-protocol support. The architecture uses SPI
(Service Provider Interface) to decouple protocol implementations from the kernel.
Core Design
SPI Loading Flow
Configuration Flow
fe-corebuilds aProtocolConfigand passes it into protocol handlers:Configuration Key Mapping
Config.mysql_service_io_threads_nummysql.io.threadsConfig.mysql_nio_backlog_nummysql.backlogConfig.mysql_nio_enable_keep_alivemysql.keep.aliveFrontendOptions.isBindIPV6()mysql.bind.ipv6Config.max_mysql_service_task_threads_nummysql.max.task.threadsThreadPoolManagerexecutormysql.task.executorDesign Principles
Protocol modules are independent
Kernel is decoupled from protocols
Shared API can evolve
Protocol compatibility must not break
SPI extension mechanism
Migration Status
Classes already moved to protocol modules
o.a.d.protocol.mysql.MysqlCapabilityo.a.d.mysql.MysqlCapabilityo.a.d.protocol.mysql.MysqlCommando.a.d.mysql.MysqlCommando.a.d.protocol.mysql.MysqlServerStatusFlago.a.d.mysql.MysqlServerStatusFlago.a.d.protocol.mysql.MysqlColTypeo.a.d.catalog.MysqlColTypeo.a.d.protocol.mysql.MysqlPacketo.a.d.mysql.MysqlPacketo.a.d.protocol.mysql.MysqlHandshakePacketo.a.d.mysql.MysqlHandshakePacketo.a.d.protocol.mysql.MysqlAuthPacketo.a.d.mysql.MysqlAuthPacketo.a.d.protocol.mysql.MysqlAuthSwitchPacketo.a.d.mysql.MysqlAuthSwitchPacketo.a.d.protocol.mysql.MysqlOkPacketo.a.d.mysql.MysqlOkPacketo.a.d.protocol.mysql.MysqlErrPacketo.a.d.mysql.MysqlErrPacketo.a.d.protocol.mysql.MysqlEofPacketo.a.d.mysql.MysqlEofPacketo.a.d.protocol.mysql.MysqlClearTextPacketo.a.d.mysql.MysqlClearTextPacketo.a.d.protocol.mysql.MysqlSslPacketo.a.d.mysql.MysqlSslPacketo.a.d.protocol.mysql.MysqlColDefo.a.d.mysql.MysqlColDefo.a.d.protocol.mysql.FieldInfoo.a.d.mysql.FieldInfoo.a.d.protocol.mysql.MysqlSerializero.a.d.mysql.MysqlSerializero.a.d.protocol.mysql.MysqlProtoo.a.d.mysql.MysqlProtoo.a.d.protocol.mysql.MysqlPasswordo.a.d.mysql.MysqlPasswordo.a.d.protocol.mysql.BytesChannelo.a.d.mysql.BytesChannelo.a.d.protocol.mysql.SslEngineHelpero.a.d.mysql.SslEngineHelperClasses still in fe-core (kernel dependencies)
These remain in fe-core due to heavy coupling with kernel classes (Config,
ConnectContext, QueryState, Auth, etc):
MysqlChannelMysqlSslContextMysqlProto.negotiate()MysqlSerializer.writeField()ReadListenerProxyProtocolHandlerauthenticate/privilege/Why full decoupling is still hard
ConnectContextowns session state, variables, transaction state.Env.getAuth()directly.ConnectProcessordrives parsing, planning, execution.MysqlSerializer.writeField()maps kernelTypeto MySQL types.Current Decoupling Strategy
Module Layout
Module Dependencies
SPI Interfaces
ProtocolHandler
ProtocolContext
Kernel Usage Example
QeService loads protocol handlers via SPI and registers acceptors:
Add a New Protocol
ProtocolHandler:META-INF/services/org.apache.doris.protocol.ProtocolHandlerAdd module pom and dependency on
fe-protocol-api.Add dependency in
fe-coreto load the new protocol.Arrow Flight: Current Coupling
Arrow Flight SQL is still tightly coupled with
fe-core:FlightTokenManagerImpl,DorisFlightSqlProducer,FlightBearerTokenAuthenticator) and injects theminto
ProtocolConfig, which mixes protocol-specific runtime objects into thekernel config path.
DorisFlightSqlServiceis still launched by QeService when SPI handler is notpresent (legacy fallback).
FlightSqlConnectProcessorandFlightSqlConnectContextstill depend onConnectContext,ConnectScheduler,Auth, and execution pipeline classes.ConnectSchedulerownsFlightSqlConnectPoolMgr, used by session/token logicand by connection limit enforcement.
Backward Compatibility
MySQL Protocol Compatibility
Migration Strategy
org.apache.doris.mysql.*package as-isConfiguration Parameters
query_portarrow_flight_sql_portenable_sslmax_connection_scheduler_threads_numReferences
TODO / Next Steps
The current protocol split is incomplete. Coupling remains high in user/session
management, configuration wiring, and connection pool management. The following
items are the prioritized next steps:
Separate user/session management from protocol handlers
AuthenticationService/SessionServiceSPI soprotocol modules do not call
Env.getAuth()or access user limits directly.neutral service. Protocols should only pass credentials and connection info.
Decouple configuration and parameter wiring
Config/FrontendOptionsreads insideQeServicewith adedicated
ProtocolConfigFactorythat builds protocol-scoped configs.executors) into
ProtocolConfig. Instead, let protocol modules create andown these objects behind SPI boundaries, or supply them via dedicated SPI
providers.
Extract connection pool management
ConnectPoolMgrandFlightSqlConnectPoolMgrbehind a unifiedConnectionPoolServiceinfe-core.service rather than reaching into
ConnectSchedulerdirectly.Define connection lifecycle SPI
onConnect,onAuthenticate,onQuery,onClosehooks soMySQL and Arrow Flight share a consistent lifecycle, and kernel code owns
the execution pipeline.
Finish Arrow Flight migration
DorisFlightSqlServicestartup and token/session management intofe-protocol-arrowflight.QeServiceafter migration.Reduce kernel type leakage
on
Typein serializers.Add tests for SPI wiring
each protocol module.