You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by da...@apache.org on 2025/05/13 14:33:13 UTC
(doris) branch branch-3.0 updated: branch-3.0: [chore](binlog) allow reading binlogs from follower #50714 (#50844)
This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/branch-3.0 by this push:
new 60d5073f76a branch-3.0: [chore](binlog) allow reading binlogs from follower #50714 (#50844)
60d5073f76a is described below
commit 60d5073f76a09b9b3be595e66596db50353f6e58
Author: github-actions[bot] <41...@users.noreply.github.com>
AuthorDate: Tue May 13 22:33:06 2025 +0800
branch-3.0: [chore](binlog) allow reading binlogs from follower #50714 (#50844)
Cherry-picked from #50714
Co-authored-by: walter <ma...@selectdb.com>
---
.../apache/doris/service/FrontendServiceImpl.java | 52 ++++++++++++++--------
gensrc/thrift/FrontendService.thrift | 1 +
2 files changed, 34 insertions(+), 19 deletions(-)
diff --git a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
index be3ee91e0a3..80c470674c0 100644
--- a/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
+++ b/fe/fe-core/src/main/java/org/apache/doris/service/FrontendServiceImpl.java
@@ -102,6 +102,7 @@ import org.apache.doris.qe.DdlExecutor;
import org.apache.doris.qe.GlobalVariable;
import org.apache.doris.qe.HttpStreamParams;
import org.apache.doris.qe.MasterCatalogExecutor;
+import org.apache.doris.qe.MasterOpExecutor;
import org.apache.doris.qe.MysqlConnectProcessor;
import org.apache.doris.qe.QeProcessorImpl;
import org.apache.doris.qe.QueryState;
@@ -2812,15 +2813,42 @@ public class FrontendServiceImpl implements FrontendService.Iface {
TStatus status = new TStatus(TStatusCode.OK);
result.setStatus(status);
+ boolean syncJournal = false;
if (!Env.getCurrentEnv().isMaster()) {
- status.setStatusCode(TStatusCode.NOT_MASTER);
- status.addToErrorMsgs(NOT_MASTER_ERR_MSG);
- result.setMasterAddress(getMasterAddress());
- LOG.error("failed to get beginTxn: {}", NOT_MASTER_ERR_MSG);
- return result;
+ if (!request.isAllowFollowerRead()) {
+ status.setStatusCode(TStatusCode.NOT_MASTER);
+ status.addToErrorMsgs(NOT_MASTER_ERR_MSG);
+ result.setMasterAddress(getMasterAddress());
+ LOG.error("failed to get binlog: {}", NOT_MASTER_ERR_MSG);
+ return result;
+ }
+ syncJournal = true;
}
try {
+ /// Check all required arg: user, passwd, db, prev_commit_seq
+ if (!request.isSetUser()) {
+ throw new UserException("user is not set");
+ }
+ if (!request.isSetPasswd()) {
+ throw new UserException("passwd is not set");
+ }
+ if (!request.isSetDb()) {
+ throw new UserException("db is not set");
+ }
+ if (!request.isSetPrevCommitSeq()) {
+ throw new UserException("prev_commit_seq is not set");
+ }
+
+ if (syncJournal) {
+ ConnectContext ctx = new ConnectContext(null);
+ ctx.setDatabase(request.getDb());
+ ctx.setQualifiedUser(request.getUser());
+ ctx.setEnv(Env.getCurrentEnv());
+ MasterOpExecutor executor = new MasterOpExecutor(ctx);
+ executor.syncJournal();
+ }
+
result = getBinlogImpl(request, clientAddr);
} catch (UserException e) {
LOG.warn("failed to get binlog: {}", e.getMessage());
@@ -2837,20 +2865,6 @@ public class FrontendServiceImpl implements FrontendService.Iface {
}
private TGetBinlogResult getBinlogImpl(TGetBinlogRequest request, String clientIp) throws UserException {
- /// Check all required arg: user, passwd, db, prev_commit_seq
- if (!request.isSetUser()) {
- throw new UserException("user is not set");
- }
- if (!request.isSetPasswd()) {
- throw new UserException("passwd is not set");
- }
- if (!request.isSetDb()) {
- throw new UserException("db is not set");
- }
- if (!request.isSetPrevCommitSeq()) {
- throw new UserException("prev_commit_seq is not set");
- }
-
// step 1: check auth
if (Strings.isNullOrEmpty(request.getToken())) {
checkSingleTablePasswordAndPrivs(request.getUser(), request.getPasswd(), request.getDb(),
diff --git a/gensrc/thrift/FrontendService.thrift b/gensrc/thrift/FrontendService.thrift
index 3c4f6fc1e90..92205c5ae0f 100644
--- a/gensrc/thrift/FrontendService.thrift
+++ b/gensrc/thrift/FrontendService.thrift
@@ -1197,6 +1197,7 @@ struct TGetBinlogRequest {
8: optional string token
9: optional i64 prev_commit_seq
10: optional i64 num_acquired // the max num of binlogs in a batch
+ 11: optional bool allow_follower_read
}
enum TBinlogType {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org