Skip to content

Commit

Permalink
fix catalog and clientIp
Browse files Browse the repository at this point in the history
Signed-off-by: Murphy <mofei@starrocks.com>
  • Loading branch information
murphyatwork committed May 25, 2024
1 parent be3d62e commit 3b2deb5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,8 @@ protected void handleQuery() {
ctx.getAuditEventBuilder().reset();
ctx.getAuditEventBuilder()
.setTimestamp(System.currentTimeMillis())
.setClientIp(ctx.getMysqlChannel().getRemoteHostPortString())
.setClientIp(StringUtils.defaultIfEmpty(
ctx.getMysqlChannel().getRemoteHostPortString(), "127.0.0.1:000"))
.setUser(ctx.getQualifiedUser())
.setAuthorizedUser(
ctx.getCurrentUserIdentity() == null ? "null" : ctx.getCurrentUserIdentity().toString())
Expand Down
25 changes: 8 additions & 17 deletions fe/fe-core/src/main/java/com/starrocks/scheduler/TaskBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.google.common.collect.Maps;
import com.starrocks.alter.OptimizeTask;
import com.starrocks.analysis.IntLiteral;
import com.starrocks.catalog.InternalCatalog;
import com.starrocks.catalog.MaterializedView;
import com.starrocks.common.Config;
import com.starrocks.common.DdlException;
Expand Down Expand Up @@ -48,6 +49,7 @@ public static Task buildPipeTask(PipeTaskDesc desc) {
Task task = new Task(desc.getUniqueTaskName());
task.setSource(Constants.TaskSource.PIPE);
task.setCreateTime(System.currentTimeMillis());
task.setCatalogName(InternalCatalog.DEFAULT_INTERNAL_CATALOG_NAME);
task.setDbName(desc.getDbName());
task.setDefinition(desc.getSqlTask());
task.setProperties(desc.getVariables());
Expand Down Expand Up @@ -130,6 +132,7 @@ public static String getAnalyzeMVStmt(String tableName) {
public static OptimizeTask buildOptimizeTask(String name, Map<String, String> properties, String sql, String dbName) {
OptimizeTask task = new OptimizeTask(name);
task.setSource(Constants.TaskSource.INSERT);
task.setCatalogName(InternalCatalog.DEFAULT_INTERNAL_CATALOG_NAME);
task.setDbName(dbName);
task.setProperties(properties);
task.setDefinition(sql);
Expand All @@ -139,36 +142,24 @@ public static OptimizeTask buildOptimizeTask(String name, Map<String, String> pr
}

public static Task buildMvTask(MaterializedView materializedView, String dbName) {
Task task = new Task(getMvTaskName(materializedView.getId()));
task.setSource(Constants.TaskSource.MV);
task.setDbName(dbName);
Map<String, String> taskProperties = Maps.newHashMap();
taskProperties.put(PartitionBasedMvRefreshProcessor.MV_ID,
String.valueOf(materializedView.getId()));
taskProperties.putAll(materializedView.getProperties());
task.setProperties(taskProperties);
task.setDefinition(materializedView.getTaskDefinition());
task.setPostRun(getAnalyzeMVStmt(materializedView.getName()));
task.setExpireTime(0L);
if (ConnectContext.get() != null) {
task.setCreateUser(ConnectContext.get().getCurrentUserIdentity().getUser());
}
handleSpecialTaskProperties(task);
return task;
return rebuildMvTask(materializedView, dbName, materializedView.getProperties());
}

public static Task rebuildMvTask(MaterializedView materializedView, String dbName,
Map<String, String> previousTaskProperties) {
Task task = new Task(getMvTaskName(materializedView.getId()));
task.setSource(Constants.TaskSource.MV);
task.setCatalogName(InternalCatalog.DEFAULT_INTERNAL_CATALOG_NAME);
task.setDbName(dbName);
String mvId = String.valueOf(materializedView.getId());
previousTaskProperties.put(PartitionBasedMvRefreshProcessor.MV_ID, mvId);
task.setProperties(previousTaskProperties);
task.setDefinition(materializedView.getTaskDefinition());
task.setPostRun(getAnalyzeMVStmt(materializedView.getName()));
task.setExpireTime(0L);
task.setCreateUser(ConnectContext.get().getCurrentUserIdentity().getUser());
if (ConnectContext.get() != null) {
task.setCreateUser(ConnectContext.get().getCurrentUserIdentity().getUser());
}
handleSpecialTaskProperties(task);
return task;
}
Expand Down

0 comments on commit 3b2deb5

Please sign in to comment.