Skip to content

Commit 4f4dd79

Browse files
authored
Optimized the config execution & query failure logs
1 parent 54a6d81 commit 4f4dd79

File tree

6 files changed

+250
-318
lines changed

6 files changed

+250
-318
lines changed

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/consensus/request/write/template/CreateSchemaTemplatePlan.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public CreateSchemaTemplatePlan() {
3838
super(ConfigPhysicalPlanType.CreateSchemaTemplate);
3939
}
4040

41-
public CreateSchemaTemplatePlan(byte[] templateData) {
41+
public CreateSchemaTemplatePlan(final byte[] templateData) {
4242
this();
4343
this.templateData = templateData;
4444
}
@@ -48,33 +48,33 @@ public byte[] getTemplateData() {
4848
}
4949

5050
public Template getTemplate() {
51-
Template template = new Template();
51+
final Template template = new Template();
5252
template.deserialize(ByteBuffer.wrap(templateData));
5353
return template;
5454
}
5555

5656
@Override
57-
protected void serializeImpl(DataOutputStream stream) throws IOException {
57+
protected void serializeImpl(final DataOutputStream stream) throws IOException {
5858
stream.writeShort(getType().getPlanType());
5959
stream.writeInt(templateData.length);
6060
stream.write(templateData);
6161
}
6262

6363
@Override
64-
protected void deserializeImpl(ByteBuffer buffer) throws IOException {
65-
int length = ReadWriteIOUtils.readInt(buffer);
64+
protected void deserializeImpl(final ByteBuffer buffer) throws IOException {
65+
final int length = ReadWriteIOUtils.readInt(buffer);
6666
this.templateData = ReadWriteIOUtils.readBytes(buffer, length);
6767
}
6868

6969
@Override
70-
public boolean equals(Object o) {
70+
public boolean equals(final Object o) {
7171
if (this == o) {
7272
return true;
7373
}
7474
if (o == null || getClass() != o.getClass()) {
7575
return false;
7676
}
77-
CreateSchemaTemplatePlan that = (CreateSchemaTemplatePlan) o;
77+
final CreateSchemaTemplatePlan that = (CreateSchemaTemplatePlan) o;
7878
return Arrays.equals(that.templateData, templateData);
7979
}
8080

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/ClusterSchemaInfo.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -734,9 +734,9 @@ public Pair<Set<TSchemaNode>, Set<PartialPath>> getChildNodePathInNextLevel(
734734
return matchedPathsInNextLevel;
735735
}
736736

737-
public TSStatus createSchemaTemplate(CreateSchemaTemplatePlan createSchemaTemplatePlan) {
737+
public TSStatus createSchemaTemplate(final CreateSchemaTemplatePlan createSchemaTemplatePlan) {
738738
try {
739-
Template template = createSchemaTemplatePlan.getTemplate();
739+
final Template template = createSchemaTemplatePlan.getTemplate();
740740
templateTable.createTemplate(template);
741741
return new TSStatus(TSStatusCode.SUCCESS_STATUS.getStatusCode());
742742
} catch (MetadataException e) {

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/TemplateTable.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ public List<Template> getAllTemplate() {
107107
}
108108
}
109109

110-
public void createTemplate(Template template) throws MetadataException {
110+
public void createTemplate(final Template template) throws MetadataException {
111111
templateReadWriteLock.writeLock().lock();
112112
try {
113-
Template temp = this.templateMap.get(template.getName());
113+
final Template temp = this.templateMap.get(template.getName());
114114
if (temp != null) {
115115
LOGGER.error(
116116
"Failed to create template, because template name {} exists", template.getName());

iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/execution/config/ConfigExecution.java

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@
4747

4848
import java.io.IOException;
4949
import java.nio.ByteBuffer;
50+
import java.util.Arrays;
51+
import java.util.Collections;
52+
import java.util.HashSet;
53+
import java.util.Objects;
5054
import java.util.Optional;
55+
import java.util.Set;
5156
import java.util.concurrent.ExecutionException;
5257
import java.util.concurrent.ExecutorService;
5358

@@ -56,6 +61,38 @@ public class ConfigExecution implements IQueryExecution {
5661
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigExecution.class);
5762

5863
private static final TsBlockSerde serde = new TsBlockSerde();
64+
private static final Set<Integer> userExceptionCodes =
65+
Collections.unmodifiableSet(
66+
new HashSet<>(
67+
Arrays.asList(
68+
TSStatusCode.DATABASE_NOT_EXIST.getStatusCode(),
69+
TSStatusCode.DATABASE_ALREADY_EXISTS.getStatusCode(),
70+
TSStatusCode.DATABASE_CONFLICT.getStatusCode(),
71+
TSStatusCode.DATABASE_CONFIG_ERROR.getStatusCode(),
72+
TSStatusCode.PATH_NOT_EXIST.getStatusCode(),
73+
TSStatusCode.MEASUREMENT_ALREADY_EXISTS_IN_TEMPLATE.getStatusCode(),
74+
TSStatusCode.SCHEMA_QUOTA_EXCEEDED.getStatusCode(),
75+
TSStatusCode.TABLE_ALREADY_EXISTS.getStatusCode(),
76+
TSStatusCode.TABLE_NOT_EXISTS.getStatusCode(),
77+
TSStatusCode.COLUMN_ALREADY_EXISTS.getStatusCode(),
78+
TSStatusCode.COLUMN_NOT_EXISTS.getStatusCode(),
79+
TSStatusCode.COLUMN_CATEGORY_MISMATCH.getStatusCode(),
80+
TSStatusCode.DATABASE_MODEL.getStatusCode(),
81+
TSStatusCode.DATABASE_CONFLICT.getStatusCode(),
82+
TSStatusCode.TEMPLATE_IS_IN_USE.getStatusCode(),
83+
TSStatusCode.TEMPLATE_NOT_SET.getStatusCode(),
84+
TSStatusCode.TEMPLATE_INCOMPATIBLE.getStatusCode(),
85+
TSStatusCode.UNDEFINED_TEMPLATE.getStatusCode(),
86+
TSStatusCode.TEMPLATE_NOT_ACTIVATED.getStatusCode(),
87+
TSStatusCode.USER_ALREADY_EXIST.getStatusCode(),
88+
TSStatusCode.USER_NOT_EXIST.getStatusCode(),
89+
TSStatusCode.NO_PERMISSION.getStatusCode(),
90+
TSStatusCode.NOT_HAS_PRIVILEGE.getStatusCode(),
91+
TSStatusCode.ROLE_ALREADY_EXIST.getStatusCode(),
92+
TSStatusCode.ROLE_NOT_EXIST.getStatusCode(),
93+
TSStatusCode.USER_ALREADY_HAS_ROLE.getStatusCode(),
94+
TSStatusCode.USER_NOT_HAS_ROLE.getStatusCode(),
95+
TSStatusCode.NOT_HAS_PRIVILEGE_GRANTOPT.getStatusCode())));
5996

6097
private final MPPQueryContext context;
6198
private final ExecutorService executor;
@@ -118,8 +155,20 @@ public void onFailure(@NotNull Throwable throwable) {
118155
}
119156
}
120157

121-
private void fail(Throwable cause) {
122-
LOGGER.warn("Failures happened during running ConfigExecution.", cause);
158+
private void fail(final Throwable cause) {
159+
if (!(cause instanceof IoTDBException)
160+
|| !userExceptionCodes.contains(((IoTDBException) cause).getErrorCode())) {
161+
LOGGER.warn(
162+
"Failures happened during running ConfigExecution when executing {}.",
163+
Objects.nonNull(task) ? task.getClass().getSimpleName() : null,
164+
cause);
165+
} else {
166+
LOGGER.info(
167+
"Failures happened during running ConfigExecution when executing {}, message: {}, status: {}",
168+
Objects.nonNull(task) ? task.getClass().getSimpleName() : null,
169+
cause.getMessage(),
170+
((IoTDBException) cause).getErrorCode());
171+
}
123172
stateMachine.transitionToFailed(cause);
124173
ConfigTaskResult result;
125174
if (cause instanceof IoTDBException) {

0 commit comments

Comments
 (0)