Skip to content

Commit b6fea63

Browse files
CRZbulabulaCopilot
andauthored
Add some supplementary logs during partition allocation (#15234)
* finished * add database not exists exception * Update iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent 1697f54 commit b6fea63

2 files changed

Lines changed: 60 additions & 11 deletions

File tree

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/partition/PartitionManager.java

Lines changed: 57 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,12 @@
110110
import java.util.Optional;
111111
import java.util.Queue;
112112
import java.util.Set;
113+
import java.util.StringJoiner;
113114
import java.util.concurrent.ConcurrentHashMap;
114115
import java.util.concurrent.Future;
115116
import java.util.concurrent.ScheduledExecutorService;
116117
import java.util.concurrent.TimeUnit;
118+
import java.util.concurrent.atomic.AtomicBoolean;
117119
import java.util.concurrent.atomic.AtomicInteger;
118120
import java.util.stream.Collectors;
119121

@@ -248,6 +250,21 @@ public SchemaPartitionResp getOrCreateSchemaPartition(final GetOrCreateSchemaPar
248250
return resp;
249251
}
250252

253+
// Here we check if the related Databases exist again,
254+
// due to we don't have a transaction mechanism.
255+
for (final String database : req.getPartitionSlotsMap().keySet()) {
256+
if (!isDatabaseExist(database)) {
257+
return new SchemaPartitionResp(
258+
new TSStatus(TSStatusCode.DATABASE_NOT_EXIST.getStatusCode())
259+
.setMessage(
260+
String.format(
261+
"Create SchemaPartition failed because the database: %s does not exist",
262+
database)),
263+
false,
264+
null);
265+
}
266+
}
267+
251268
// Filter unassigned SchemaPartitionSlots
252269
final Map<String, List<TSeriesPartitionSlot>> unassignedSchemaPartitionSlotsMap =
253270
partitionInfo.filterUnassignedSchemaPartitionSlots(req.getPartitionSlotsMap());
@@ -311,14 +328,19 @@ public SchemaPartitionResp getOrCreateSchemaPartition(final GetOrCreateSchemaPar
311328
final AtomicInteger unassignedSlotNum = new AtomicInteger();
312329
final Map<String, List<TSeriesPartitionSlot>> unassignedSchemaPartitionSlotsMap =
313330
partitionInfo.filterUnassignedSchemaPartitionSlots(req.getPartitionSlotsMap());
331+
StringJoiner errDatabases = new StringJoiner(", ", "[", "]");
314332
unassignedSchemaPartitionSlotsMap.forEach(
315-
(database, unassignedSchemaPartitionSlots) ->
316-
unassignedSlotNum.addAndGet(unassignedSchemaPartitionSlots.size()));
333+
(database, unassignedSchemaPartitionSlots) -> {
334+
if (!unassignedSchemaPartitionSlots.isEmpty()) {
335+
errDatabases.add(database);
336+
unassignedSlotNum.addAndGet(unassignedSchemaPartitionSlots.size());
337+
}
338+
});
317339

318340
final String errMsg =
319341
String.format(
320-
"Lacked %d/%d SchemaPartition allocation result in the response of getOrCreateSchemaPartition method",
321-
unassignedSlotNum.get(), totalSlotNum.get());
342+
"Lacked %d/%d SchemaPartition allocation result when get or create schema partitions for databases: %s",
343+
unassignedSlotNum.get(), totalSlotNum.get(), errDatabases);
322344
LOGGER.error(errMsg);
323345
resp.setStatus(
324346
new TSStatus(TSStatusCode.LACK_PARTITION_ALLOCATION.getStatusCode()).setMessage(errMsg));
@@ -373,6 +395,21 @@ public DataPartitionResp getOrCreateDataPartition(final GetOrCreateDataPartition
373395
return resp;
374396
}
375397

398+
// Here we check if the related Databases exist again,
399+
// due to we don't have a transaction mechanism.
400+
for (final String database : req.getPartitionSlotsMap().keySet()) {
401+
if (!isDatabaseExist(database)) {
402+
return new DataPartitionResp(
403+
new TSStatus(TSStatusCode.DATABASE_NOT_EXIST.getStatusCode())
404+
.setMessage(
405+
String.format(
406+
"Create DataPartition failed because the database: %s does not exist",
407+
database)),
408+
false,
409+
null);
410+
}
411+
}
412+
376413
// Filter unassigned DataPartitionSlots
377414
Map<String, Map<TSeriesPartitionSlot, TTimeSlotList>> unassignedDataPartitionSlotsMap =
378415
partitionInfo.filterUnassignedDataPartitionSlots(req.getPartitionSlotsMap());
@@ -446,16 +483,26 @@ public DataPartitionResp getOrCreateDataPartition(final GetOrCreateDataPartition
446483
AtomicInteger unassignedSlotNum = new AtomicInteger();
447484
Map<String, Map<TSeriesPartitionSlot, TTimeSlotList>> unassignedDataPartitionSlotsMap =
448485
partitionInfo.filterUnassignedDataPartitionSlots(req.getPartitionSlotsMap());
486+
StringJoiner errDatabases = new StringJoiner(", ", "[", "]");
449487
unassignedDataPartitionSlotsMap.forEach(
450-
(database, unassignedDataPartitionSlots) ->
451-
unassignedDataPartitionSlots.forEach(
452-
(seriesPartitionSlot, timeSlotList) ->
453-
unassignedSlotNum.addAndGet(timeSlotList.getTimePartitionSlots().size())));
488+
(database, unassignedDataPartitionSlots) -> {
489+
AtomicBoolean hasUnassignedSlot = new AtomicBoolean(false);
490+
unassignedDataPartitionSlots.forEach(
491+
(seriesPartitionSlot, timeSlotList) -> {
492+
if (!timeSlotList.getTimePartitionSlots().isEmpty()) {
493+
hasUnassignedSlot.set(true);
494+
unassignedSlotNum.addAndGet(timeSlotList.getTimePartitionSlots().size());
495+
}
496+
});
497+
if (hasUnassignedSlot.get()) {
498+
errDatabases.add(database);
499+
}
500+
});
454501

455502
String errMsg =
456503
String.format(
457-
"Lacked %d/%d DataPartition allocation result in the response of getOrCreateDataPartition method",
458-
unassignedSlotNum.get(), totalSlotNum.get());
504+
"Lacked %d/%d DataPartition allocation result when get or create data partitions for databases: %s",
505+
unassignedSlotNum.get(), totalSlotNum.get(), errDatabases);
459506
LOGGER.error(errMsg);
460507
resp.setStatus(
461508
new TSStatus(TSStatusCode.LACK_PARTITION_ALLOCATION.getStatusCode()).setMessage(errMsg));

iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/procedure/impl/schema/DeleteDatabaseProcedure.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,9 @@ protected Flow executeFromState(
197197
env.getConfigManager()
198198
.getLoadManager()
199199
.clearDataPartitionPolicyTable(deleteDatabaseSchema.getName());
200-
LOG.info("data partition policy table cleared.");
200+
LOG.info(
201+
"[DeleteDatabaseProcedure] The data partition policy table of database: {} is cleared.",
202+
deleteDatabaseSchema.getName());
201203

202204
// Delete Database metrics
203205
PartitionMetrics.unbindDatabaseRelatedMetricsWhenUpdate(

0 commit comments

Comments
 (0)