Skip to content

Commit

Permalink
improve sync
Browse files Browse the repository at this point in the history
  • Loading branch information
TangSiyang2001 committed Jun 27, 2023
1 parent 01db8cd commit 352cd17
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ public void analyze(Analyzer analyzer) throws UserException {

@Override
public RedirectStatus getRedirectStatus() {
return RedirectStatus.FORWARD_WITH_SYNC;
return RedirectStatus.NO_FORWARD;
}
}
2 changes: 0 additions & 2 deletions fe/fe-core/src/main/java/org/apache/doris/qe/DdlExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,6 @@ public static void execute(Env env, DdlStmt ddlStmt) throws Exception {
env.getBackupHandler().createRepository((CreateRepositoryStmt) ddlStmt);
} else if (ddlStmt instanceof DropRepositoryStmt) {
env.getBackupHandler().dropRepository((DropRepositoryStmt) ddlStmt);
} else if (ddlStmt instanceof SyncStmt) {
return;
} else if (ddlStmt instanceof TruncateTableStmt) {
env.truncateTable((TruncateTableStmt) ddlStmt);
} else if (ddlStmt instanceof AdminRepairTableStmt) {
Expand Down
18 changes: 15 additions & 3 deletions fe/fe-core/src/main/java/org/apache/doris/qe/StmtExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
import org.apache.doris.analysis.StmtRewriter;
import org.apache.doris.analysis.StringLiteral;
import org.apache.doris.analysis.SwitchStmt;
import org.apache.doris.analysis.SyncStmt;
import org.apache.doris.analysis.TableName;
import org.apache.doris.analysis.TransactionBeginStmt;
import org.apache.doris.analysis.TransactionCommitStmt;
Expand Down Expand Up @@ -724,6 +725,8 @@ public void executeByLegacy(TUniqueId queryId) throws Exception {
handleLoadStmt();
} else if (parsedStmt instanceof UpdateStmt) {
handleUpdateStmt();
} else if (parsedStmt instanceof SyncStmt) {
syncJournal();
} else if (parsedStmt instanceof DdlStmt) {
if (parsedStmt instanceof DeleteStmt && ((DeleteStmt) parsedStmt).getFromClause() != null) {
handleDeleteStmt();
Expand Down Expand Up @@ -787,12 +790,21 @@ public void executeByLegacy(TUniqueId queryId) throws Exception {
}

private void syncJournalIfNeeded() throws Exception {
final Env env = context.getEnv();
if (!context.getSessionVariable().enableStrongConsistencyRead
|| !Config.enable_strong_consistency_read || env.isMaster()) {
|| !Config.enable_strong_consistency_read) {
return;
}
syncJournal();
}

/**
* fetch master's max journal id and wait for edit log replaying
*/
private void syncJournal() throws Exception {
final Env env = context.getEnv();
if (env.isMaster()) {
return;
}
// fetch master's max journal id and wait for replay
String masterHost = env.getMasterHost();
int masterRpcPort = env.getMasterRpcPort();
TNetworkAddress thriftAddress = new TNetworkAddress(masterHost, masterRpcPort);
Expand Down

0 comments on commit 352cd17

Please sign in to comment.