hello-stephen commented on code in PR #70910:
URL: https://github.com/apache/doris/pull/70910#discussion_r4697999995
##########
be/src/service/http/action/stream_load.cpp:
##########
@@ -458,6 +461,27 @@ void
StreamLoadAction::free_handler_ctx(std::shared_ptr<void> param) {
streaming_load_current_processing->increment(-1);
}
+#ifndef BE_TEST
+static TNetworkAddress select_group_commit_planner(ExecEnv* env, const
TNetworkAddress& master) {
+ const auto& mode = config::group_commit_stream_load_plan_mode;
Review Comment:
[P2] Snapshot the mutable planner mode under its config mutex
This is a reference to a DEFINE_mString value, which /api/update_config can
modify while another HTTP worker plans a load. set_config() assigns the same
std::string under mutable_string_config_lock, but these comparisons take no
matching lock. Switching between round_robin/master and non_master_round_robin
can race with the string buffer and length reads, causing undefined behavior in
the BE. Copy the value while holding get_mutable_string_config_lock(), then
compare that snapshot after releasing the lock, following the existing
HttpClient mutable-string read pattern.
##########
be/src/service/http/action/stream_load.cpp:
##########
@@ -822,13 +846,30 @@ Status StreamLoadAction::_process_put(HttpRequest*
http_req,
#ifndef BE_TEST
// plan this load
- TNetworkAddress master_addr = _exec_env->cluster_info()->master_fe_addr;
int64_t stream_load_put_start_time = MonotonicNanos();
- RETURN_IF_ERROR(ThriftRpcHelper::rpc<FrontendServiceClient>(
- master_addr.hostname, master_addr.port,
- [&request, ctx](FrontendServiceConnection& client) {
- client->streamLoadPut(ctx->put_result, request);
- }));
+ auto put = [&request, ctx](FrontendServiceConnection& client) {
+ client->streamLoadPut(ctx->put_result, request);
+ };
+ const auto master = _exec_env->cluster_info()->master_fe_addr;
+ auto planner = ctx->group_commit ? select_group_commit_planner(_exec_env,
master) : master;
+ auto st = ThriftRpcHelper::rpc<FrontendServiceClient>(planner.hostname,
planner.port, put);
+ const bool retry_on_master =
+ planner != master &&
+ (!st.ok() || ctx->put_result.status.status_code ==
TStatusCode::NOT_FOUND ||
+ ctx->put_result.status.status_code ==
TStatusCode::GROUP_COMMIT_SCHEMA_MISMATCH);
Review Comment:
[P2] Retry master planning when follower metadata validation is unavailable
If the selected follower cannot borrow or use its connection to the master
while the BE can still reach the master,
MasterOpExecutor.checkGroupCommitSchemaChange wraps that internal RPC failure
in UserException. streamLoadPut consequently returns ANALYSIS_ERROR over a
successful outer Thrift call. None of the retry conditions here match, so the
valid load aborts even though direct master planning would succeed. A follower
becoming unready after the last heartbeat takes the same path. Preserve a
distinguishable retriable status for validation transport/readiness failures
and include it in the master fallback, while keeping actual user/DDL errors
terminal.
##########
fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java:
##########
@@ -97,6 +100,41 @@ private static String
getForwardResultErrorMessage(TMasterOpResult result) {
return "failed to select backend for group commit, status code: " +
result.getStatusCode();
}
+ public static final class GroupCommitSchemaMismatchException extends
UserException {
+ private GroupCommitSchemaMismatchException(String message) {
+ super(message);
+ }
+ }
+
+ public void checkGroupCommitSchemaChange(String db, TGroupCommitInfo info,
int timeoutMs)
+ throws UserException {
+ String table = info.getSchemaChangeTableName();
+ // Pre-upgrade masters ignore schemaChangeTableName. Use their
existing no-op shortcut
+ // so forward() never executes the placeholder SQL. The returned
journal ID is unused.
+ TMasterOpRequest params =
getMasterOpRequestForGroupCommit(info).setDb(db).setSyncJournalOnly(true);
+ if (timeoutMs <= 0) {
+ throw new LoadException("Timed out checking Group Commit planning
metadata");
+ }
+ thriftTimeoutMs = timeoutMs;
+ TMasterOpResult response;
+ try {
+ response = forward(params);
+ } catch (Exception e) {
+ throw new UserException("Failed to check Group Commit metadata for
" + db + "." + table, e);
+ }
+ int status = response.getStatusCode();
Review Comment:
[P2] Require acknowledgement that the master validated the schema
During a rolling upgrade, a new BE can select an upgraded follower whose
master is still old. That master ignores the new fields and handles
syncJournalOnly as a no-op, returning an unset statusCode that reads as zero
here; its journal ID is also ignored. If a light ADD COLUMN has completed on
the master but is not replayed on the follower, this therefore accepts the
stale schema and returns an OK parser plan. An active group-commit queue using
the newer master schema then rejects it with DataQualityError, after the BE
planning fallback has finished. Require an explicit validation acknowledgement
and trigger master replanning when it is absent, rather than accepting the
legacy no-op as validation success.
##########
fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java:
##########
@@ -1248,6 +1247,44 @@ private TMasterOpResult
handleForwardShortcut(TMasterOpRequest params) throws TE
return handleForwardCancel(params);
}
+ private TMasterOpResult checkGroupCommitSchemaChange(TMasterOpRequest
params) throws TException {
+ Env env = Env.getCurrentEnv();
+ if (!env.isMaster()) {
+ throw new TException("Group Commit schema change check requires
the current master");
+ }
+ TMasterOpResult result = createForwardResultWithoutJournalSync();
+ try {
+ Database db =
env.getInternalCatalog().getDbOrMetaException(params.getDb());
+ TGroupCommitInfo info = params.getGroupCommitInfo();
+ OlapTable table = (OlapTable)
db.getTableOrMetaException(info.getSchemaChangeTableName(), TableType.OLAP);
+ if (!table.readLockIfExist()) {
+ throw new MetaNotFoundException("Group Commit table was
dropped: " + table.getName());
+ }
+ try {
+ if (env.getGroupCommitManager().isBlock(table.getId())) {
+
result.setStatusCode(TStatusCode.ANALYSIS_ERROR.getValue());
+ result.setErrMessage("insert table " + table.getId() +
GroupCommitPlanner.SCHEMA_CHANGE);
+ return result;
+ }
+ if
(DebugPointUtil.isEnable("FrontendServiceImpl.groupCommitPlan.extraIndex")) {
+ info.putToIndexSchemaVersions(-1L, 0);
+ }
+ if (table.getId() != info.getTableId()
+ ||
!StreamLoadHandler.getIndexSchemaVersions(table).equals(info.getIndexSchemaVersions()))
{
Review Comment:
[P1] Validate partition freshness before accepting a follower plan
After a completed ADD PARTITION on a manually partitioned table, a lagging
follower still has the same table ID and index schema versions, so this
comparison accepts its old partition ranges. For example, add [10,20) to an
existing [0,10) table and load rows 1 and 11 through that follower:
GroupCommitBlockSinkOperatorX filters row 11 before queueing because its
first-stage plan lacks the new range. With max_filter_ratio=0.5 the load
succeeds with that valid row omitted; with the default ratio it fails. The
downstream queue only checks base schema version/index count and cannot recover
the filtered row. Validate the relevant partition metadata or synchronize a
journal boundary, and retry on the master when it differs.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]