924060929 commented on code in PR #70910:
URL: https://github.com/apache/doris/pull/70910#discussion_r4737550810
##########
fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java:
##########
@@ -81,20 +85,49 @@ public void syncJournal() throws Exception {
public long getGroupCommitLoadBeId(long tableId, String cluster) throws
Exception {
result = forward(buildGetGroupCommitLoadBeIdParmas(tableId, cluster));
- if (result.isSetStatusCode() && result.getStatusCode() != 0) {
- throw new LoadException(getForwardResultErrorMessage(result));
- }
- if (result.isSetErrMessage()) {
- throw new LoadException(result.getErrMessage());
- }
+ checkGroupCommitResult(result, "failed to select backend for group
commit");
return result.groupCommitLoadBeId;
}
- private static String getForwardResultErrorMessage(TMasterOpResult result)
{
- if (result.isSetErrMessage() && result.getErrMessage() != null &&
!result.getErrMessage().isEmpty()) {
- return result.getErrMessage();
+ public static void checkGroupCommitResult(TMasterOpResult result, String
operation) throws LoadException {
+ if (result.getStatusCode() != TStatusCode.OK.getValue() ||
result.isSetErrMessage()) {
+ String message = result.getErrMessage();
+ throw new LoadException(message == null || message.isEmpty()
+ ? operation + ", status code: " + result.getStatusCode() :
message);
+ }
+ }
+
+ public TMasterOpResult syncJournalAndGetGroupCommitTableStatus(String db,
String table, int timeoutMs)
+ throws UserException {
+ if (timeoutMs <= 0) {
+ throw new LoadException("Timed out checking Group Commit planning
metadata");
+ }
+ TMasterOpRequest params = buildSyncJournalParams().setDb(db)
+ .setGroupCommitInfo(new
TGroupCommitInfo().setTableName(table).setCheckTableBlocked(true));
+ long start = System.nanoTime();
+ thriftTimeoutMs = timeoutMs;
+ TMasterOpResult response;
+ try {
+ response = forward(params);
+ } catch (Exception e) {
+ throw new LoadException(
+ "Failed to check Group Commit metadata for " + db + "." +
table + ": " + e.getMessage(), e);
+ }
+ // Older masters only acknowledge journal sync and leave statusCode
unset.
+ if (!response.isSetStatusCode()) {
+ throw new LoadException("Master did not acknowledge Group Commit
plan validation");
Review Comment:
During a standard BE-first rolling upgrade with
`group_commit_stream_load_plan_mode=round_robin` as default:
1. Upgraded BE -> old Follower/Observer: the old FE has neither the journal
replay barrier nor the master `isBlock` check (and `blockedTableIds` only lives
on Master), so schema-change blocking is bypassed and stale metadata can be
used for planning.
2. Upgraded BE -> upgraded Follower/Observer -> old Master: this check fails
the load directly without falling back to Master.
Consider gating direct planning on an FE capability flag advertised in
heartbeat (or keeping the default mode as `master` until mixed-version
compatibility is handled).
##########
fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java:
##########
@@ -81,20 +85,49 @@ public void syncJournal() throws Exception {
public long getGroupCommitLoadBeId(long tableId, String cluster) throws
Exception {
result = forward(buildGetGroupCommitLoadBeIdParmas(tableId, cluster));
- if (result.isSetStatusCode() && result.getStatusCode() != 0) {
- throw new LoadException(getForwardResultErrorMessage(result));
- }
- if (result.isSetErrMessage()) {
- throw new LoadException(result.getErrMessage());
- }
+ checkGroupCommitResult(result, "failed to select backend for group
commit");
return result.groupCommitLoadBeId;
}
- private static String getForwardResultErrorMessage(TMasterOpResult result)
{
- if (result.isSetErrMessage() && result.getErrMessage() != null &&
!result.getErrMessage().isEmpty()) {
- return result.getErrMessage();
+ public static void checkGroupCommitResult(TMasterOpResult result, String
operation) throws LoadException {
+ if (result.getStatusCode() != TStatusCode.OK.getValue() ||
result.isSetErrMessage()) {
+ String message = result.getErrMessage();
+ throw new LoadException(message == null || message.isEmpty()
+ ? operation + ", status code: " + result.getStatusCode() :
message);
+ }
+ }
+
+ public TMasterOpResult syncJournalAndGetGroupCommitTableStatus(String db,
String table, int timeoutMs)
+ throws UserException {
+ if (timeoutMs <= 0) {
+ throw new LoadException("Timed out checking Group Commit planning
metadata");
+ }
+ TMasterOpRequest params = buildSyncJournalParams().setDb(db)
+ .setGroupCommitInfo(new
TGroupCommitInfo().setTableName(table).setCheckTableBlocked(true));
+ long start = System.nanoTime();
+ thriftTimeoutMs = timeoutMs;
+ TMasterOpResult response;
+ try {
+ response = forward(params);
+ } catch (Exception e) {
Review Comment:
`FEOpExecutor.forward()` unconditionally logs `LOG.info("forward to master
FE ...")` on every call (and `JournalObservable.waitOn()` also logs at `INFO`
when catching up). Under high-QPS Group Commit Stream Load with `round_robin`
enabled by default, this will flood `fe.log` and add noticeable logging I/O
overhead. Consider downgrading the forward log to `DEBUG` for `syncJournalOnly`
/ `checkTableBlocked` requests.
##########
fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java:
##########
@@ -3026,86 +3064,43 @@ private void recordFinishedLoadJobRequestImpl(String
label, long txnId, String d
EtlJobType.INSERT, createTime, failMsg, trackingUrl,
firstErrorMsg, userIdentity, -1);
}
- private static int nextGroupCommitFollowerIndex(int followerCount) {
- return Math.floorMod(GROUP_COMMIT_FOLLOWER_INDEX.getAndIncrement(),
followerCount);
- }
-
- private void checkGroupCommitStreamLoadAuth(TStreamLoadPutRequest request)
throws AuthenticationException {
- // Explicit group commit skips loadTxnBegin, so authenticate and
authorize the standard Stream Load
- // request here before it can be forwarded or planned. Requests with
load_sql use the separate HTTP
- // Stream path, whose planner performs its own authorization and whose
internal caller uses a token.
+ private void validateGroupCommitStreamLoad(TStreamLoadPutRequest request)
throws UserException {
+ // Explicit Group Commit skips loadTxnBegin. The separate load_sql
planner handles its own authorization.
if (!Strings.isNullOrEmpty(request.getLoadSql()) ||
!request.isSetGroupCommitMode()
|| request.getGroupCommitMode().equalsIgnoreCase("off_mode")) {
return;
}
- if (Strings.isNullOrEmpty(request.getToken())) {
- checkSingleTablePasswordAndPrivs(request.getUser(),
request.getPasswd(), request.getDb(),
- request.getTbl(), request.getUserIp(), PrivPredicate.LOAD,
- toForwardedCertificateInfo(request.getCertBasedAuth()));
- } else {
+ boolean hasToken = !Strings.isNullOrEmpty(request.getToken());
+ if (hasToken) {
checkTokenOrThrow(request.getToken());
}
- }
- private TStreamLoadPutResult
forwardGroupCommitStreamLoad(TStreamLoadPutRequest request) {
- HostInfo selfNode = Env.getCurrentEnv().getSelfNode();
- List<Frontend> followers =
Env.getCurrentEnv().getFrontends(FrontendNodeType.FOLLOWER).stream()
- .filter(fe -> fe.isAlive() &&
!(fe.getHost().equals(selfNode.getHost())
- && fe.getEditLogPort() == selfNode.getPort())).collect(
- Collectors.toList());
- if (CollectionUtils.isEmpty(followers)) {
- return null;
+ TMasterOpResult validation = null;
+ Env env = Env.getCurrentEnv();
+ if (!env.isMaster()) {
+ ConnectContext ctx = new ConnectContext();
+ ctx.setEnv(env);
+
ctx.setCurrentUserIdentity(UserIdentity.createAnalyzedUserIdentWithIp(request.getUser(),
"%"));
+ int timeoutMs = request.isSetThriftRpcTimeoutMs() ?
Ints.saturatedCast(request.getThriftRpcTimeoutMs())
+ : 5000;
+ validation = new MasterOpExecutor(ctx)
+ .syncJournalAndGetGroupCommitTableStatus(request.getDb(),
request.getTbl(), timeoutMs);
Review Comment:
For password/cert-based requests (`!hasToken`), calling
`syncJournalAndGetGroupCommitTableStatus` before authentication means any
unauthenticated or wrong-password request triggers an RPC to the Master and may
block in `JournalObservable.waitOn()` before being rejected. Consider checking
local auth first (and only syncing/retrying on auth failure if needed), or
explicitly noting this trade-off.
##########
fe/fe-common/src/main/java/org/apache/doris/common/Config.java:
##########
@@ -628,11 +628,6 @@ public class Config extends ConfigBase {
+ "in stream load")
public static boolean stream_load_default_memtable_on_sink_node = false;
- @ConfField(mutable = true, masterOnly = true, description = "Whether to
enable forwarding group commit stream "
- + "load to follower nodes. If true, stream load with "
- + "group commit mode will be forwarded to a follower FE " + "round
robin.")
- public static boolean enable_forward_group_commit_stream_load_to_follower
= false;
Review Comment:
`enable_forward_group_commit_stream_load_to_follower` was introduced in
#63594. If it has been shipped in a release branch, deleting it outright will
break existing `ADMIN SET FRONTEND CONFIG` automation — consider keeping it as
`@Deprecated` instead.
##########
fe/fe-core/src/main/java/org/apache/doris/qe/MasterOpExecutor.java:
##########
@@ -81,20 +85,49 @@ public void syncJournal() throws Exception {
public long getGroupCommitLoadBeId(long tableId, String cluster) throws
Exception {
result = forward(buildGetGroupCommitLoadBeIdParmas(tableId, cluster));
- if (result.isSetStatusCode() && result.getStatusCode() != 0) {
- throw new LoadException(getForwardResultErrorMessage(result));
- }
- if (result.isSetErrMessage()) {
- throw new LoadException(result.getErrMessage());
- }
+ checkGroupCommitResult(result, "failed to select backend for group
commit");
return result.groupCommitLoadBeId;
}
- private static String getForwardResultErrorMessage(TMasterOpResult result)
{
- if (result.isSetErrMessage() && result.getErrMessage() != null &&
!result.getErrMessage().isEmpty()) {
- return result.getErrMessage();
+ public static void checkGroupCommitResult(TMasterOpResult result, String
operation) throws LoadException {
+ if (result.getStatusCode() != TStatusCode.OK.getValue() ||
result.isSetErrMessage()) {
+ String message = result.getErrMessage();
Review Comment:
Minor: `handleGroupCommitLoadBeId` sets raw `statusCode = 1` on error,
whereas `checkGroupCommitTable` sets `TStatusCode.*.getValue()`. Sharing
`checkGroupCommitResult` mixes two different status code domains — consider
aligning `handleGroupCommitLoadBeId` to `TStatusCode` as well.
--
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]