Skip to content
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

[fix](group_commit) group_commit is not support on table with property light_schema_change=false #29244

Merged
merged 2 commits into from
Dec 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions be/src/olap/wal_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,12 +377,10 @@ Status WalManager::replay() {
std::lock_guard<std::shared_mutex> wrlock(_lock);
auto it = _table_map.begin();
while (it != _table_map.end()) {
if (it->second->size() == 0) {
it = _table_map.erase(it);
} else {
if (it->second->size() > 0) {
replay_tables.push_back(it->first);
it++;
}
it++;
}
}
for (const auto& table_id : replay_tables) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,12 @@ public RedirectStatus getRedirectStatus() {
}
}

public void analyzeGroupCommit(Analyzer analyzer) {
public void analyzeGroupCommit(Analyzer analyzer) throws AnalysisException {
if (isGroupCommitStreamLoadSql && (targetTable instanceof OlapTable)
&& !((OlapTable) targetTable).getTableProperty().getUseSchemaLightChange()) {
throw new AnalysisException(
"table light_schema_change is false, can't do http_stream with group commit mode");
}
if (isGroupCommit) {
return;
}
Expand All @@ -1123,6 +1128,7 @@ public void analyzeGroupCommit(Analyzer analyzer) {
if (!partialUpdate && ConnectContext.get().getSessionVariable().isEnableInsertGroupCommit()
&& ConnectContext.get().getSessionVariable().getSqlMode() != SqlModeHelper.MODE_NO_BACKSLASH_ESCAPES
&& targetTable instanceof OlapTable
&& ((OlapTable) targetTable).getTableProperty().getUseSchemaLightChange()
&& !ConnectContext.get().isTxnModel()
&& getQueryStmt() instanceof SelectStmt
&& ((SelectStmt) getQueryStmt()).getTableRefs().isEmpty() && targetPartitionNames == null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ private boolean analyzeGroupCommit(ConnectContext ctx, DataSink sink,
return ConnectContext.get().getSessionVariable().getSqlMode() != SqlModeHelper.MODE_NO_BACKSLASH_ESCAPES
&& physicalOlapTableSink.getTargetTable() instanceof OlapTable && !ConnectContext.get().isTxnModel()
&& sink.getFragment().getPlanRoot() instanceof UnionNode && physicalOlapTableSink.getPartitionIds()
.isEmpty();
.isEmpty() && physicalOlapTableSink.getTargetTable().getTableProperty().getUseSchemaLightChange();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2001,6 +2001,10 @@ private TExecPlanFragmentParams streamLoadPutImpl(TStreamLoadPutRequest request,
}
long timeoutMs = request.isSetThriftRpcTimeoutMs() ? request.getThriftRpcTimeoutMs() : 5000;
Table table = db.getTableOrMetaException(request.getTbl(), TableType.OLAP);
if (!((OlapTable) table).getTableProperty().getUseSchemaLightChange() && (request.getGroupCommitMode() != null
&& !request.getGroupCommitMode().equals("off_mode"))) {
throw new UserException("table light_schema_change is false, can't do stream load with group commit mode");
}
result.setDbId(db.getId());
result.setTableId(table.getId());
result.setBaseSchemaVersion(((OlapTable) table).getBaseSchemaVersion());
Expand Down Expand Up @@ -2062,6 +2066,10 @@ private TPipelineFragmentParams pipelineStreamLoadPutImpl(TStreamLoadPutRequest
}
long timeoutMs = request.isSetThriftRpcTimeoutMs() ? request.getThriftRpcTimeoutMs() : 5000;
Table table = db.getTableOrMetaException(request.getTbl(), TableType.OLAP);
if (!((OlapTable) table).getTableProperty().getUseSchemaLightChange() && (request.getGroupCommitMode() != null
&& !request.getGroupCommitMode().equals("off_mode"))) {
throw new UserException("table light_schema_change is false, can't do stream load with group commit mode");
}
return this.generatePipelineStreamLoadPut(request, db, fullDbName, (OlapTable) table, timeoutMs,
1, false);
}
Expand Down