This is an automated email from the ASF dual-hosted git repository.
caogaofei pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new 614d073230f Fixed the bug that some of the "lock()"s are called in
"try" block
614d073230f is described below
commit 614d073230f31440cff90ff736e930a62de3d89d
Author: Caideyipi <[email protected]>
AuthorDate: Thu Jul 4 12:12:25 2024 +0800
Fixed the bug that some of the "lock()"s are called in "try" block
---
.../load/balancer/partition/DataPartitionPolicyTable.java | 2 +-
.../confignode/manager/schema/ClusterSchemaManager.java | 2 +-
.../iotdb/confignode/persistence/schema/TemplateTable.java | 10 +++++-----
.../iotdb/consensus/iot/logdispatcher/IndexController.java | 4 ++--
.../org/apache/iotdb/db/protocol/client/ConfigNodeInfo.java | 2 +-
.../plan/analyze/cache/partition/PartitionCache.java | 12 ++++++------
6 files changed, 16 insertions(+), 16 deletions(-)
diff --git
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/partition/DataPartitionPolicyTable.java
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/partition/DataPartitionPolicyTable.java
index 4f1727d88b9..d8289c61aa2 100644
---
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/partition/DataPartitionPolicyTable.java
+++
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/load/balancer/partition/DataPartitionPolicyTable.java
@@ -138,8 +138,8 @@ public class DataPartitionPolicyTable {
// No need to re-balance when there is no DataRegionGroup
return;
}
+ dataAllotTableLock.lock();
try {
- dataAllotTableLock.lock();
int mu = SERIES_SLOT_NUM / seriesPartitionSlotCounter.size();
dataAllotMap.forEach(
(seriesPartitionSlot, regionGroupId) -> {
diff --git
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java
index aa59c8f1374..ebb7a264e04 100644
---
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java
+++
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/manager/schema/ClusterSchemaManager.java
@@ -153,8 +153,8 @@ public class ClusterSchemaManager {
"Some other task is deleting database %s",
databaseSchemaPlan.getSchema().getName()));
}
+ createDatabaseLock.lock();
try {
- createDatabaseLock.lock();
clusterSchemaInfo.isDatabaseNameValid(databaseSchemaPlan.getSchema().getName());
if
(!databaseSchemaPlan.getSchema().getName().equals(SchemaConstant.SYSTEM_DATABASE))
{
clusterSchemaInfo.checkDatabaseLimit();
diff --git
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/TemplateTable.java
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/TemplateTable.java
index 6b9c2e8217d..201e6eb4d2e 100644
---
a/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/TemplateTable.java
+++
b/iotdb-core/confignode/src/main/java/org/apache/iotdb/confignode/persistence/schema/TemplateTable.java
@@ -72,8 +72,8 @@ public class TemplateTable {
}
public Template getTemplate(String name) throws MetadataException {
+ templateReadWriteLock.readLock().lock();
try {
- templateReadWriteLock.readLock().lock();
Template template = templateMap.get(name);
if (template == null) {
throw new MetadataException(String.format("Template %s does not
exist", name));
@@ -85,8 +85,8 @@ public class TemplateTable {
}
public Template getTemplate(int templateId) throws MetadataException {
+ templateReadWriteLock.readLock().lock();
try {
- templateReadWriteLock.readLock().lock();
Template template = templateIdMap.get(templateId);
if (template == null) {
throw new MetadataException(
@@ -99,8 +99,8 @@ public class TemplateTable {
}
public List<Template> getAllTemplate() {
+ templateReadWriteLock.readLock().lock();
try {
- templateReadWriteLock.readLock().lock();
return new ArrayList<>(templateMap.values());
} finally {
templateReadWriteLock.readLock().unlock();
@@ -108,8 +108,8 @@ public class TemplateTable {
}
public void createTemplate(Template template) throws MetadataException {
+ templateReadWriteLock.writeLock().lock();
try {
- templateReadWriteLock.writeLock().lock();
Template temp = this.templateMap.get(template.getName());
if (temp != null) {
LOGGER.error(
@@ -125,8 +125,8 @@ public class TemplateTable {
}
public void dropTemplate(String templateName) throws MetadataException {
+ templateReadWriteLock.writeLock().lock();
try {
- templateReadWriteLock.writeLock().lock();
Template temp = this.templateMap.remove(templateName);
if (temp == null) {
LOGGER.error("Undefined template {}", templateName);
diff --git
a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/logdispatcher/IndexController.java
b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/logdispatcher/IndexController.java
index ddafaf2f010..f05fe99dc4a 100644
---
a/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/logdispatcher/IndexController.java
+++
b/iotdb-core/consensus/src/main/java/org/apache/iotdb/consensus/iot/logdispatcher/IndexController.java
@@ -70,8 +70,8 @@ public class IndexController {
}
public void update(long index, boolean forcePersist) {
+ lock.writeLock().lock();
try {
- lock.writeLock().lock();
long newCurrentIndex = Math.max(currentIndex, index);
logger.debug(
"update index from currentIndex {} to {} for file prefix {} in {}",
@@ -87,8 +87,8 @@ public class IndexController {
}
public long getCurrentIndex() {
+ lock.readLock().lock();
try {
- lock.readLock().lock();
return currentIndex;
} finally {
lock.readLock().unlock();
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeInfo.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeInfo.java
index 256b8a0be17..c803dd5f09e 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeInfo.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/protocol/client/ConfigNodeInfo.java
@@ -112,8 +112,8 @@ public class ConfigNodeInfo {
public void loadConfigNodeList() {
long startTime = System.currentTimeMillis();
// properties contain CONFIG_NODE_LIST only when start as Data node
+ configNodeInfoReadWriteLock.writeLock().lock();
try {
- configNodeInfoReadWriteLock.writeLock().lock();
Properties properties = systemPropertiesHandler.read();
if (properties.containsKey(CONFIG_NODE_LIST)) {
diff --git
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/cache/partition/PartitionCache.java
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/cache/partition/PartitionCache.java
index 166fca9309a..8fc726015c7 100644
---
a/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/cache/partition/PartitionCache.java
+++
b/iotdb-core/datanode/src/main/java/org/apache/iotdb/db/queryengine/plan/analyze/cache/partition/PartitionCache.java
@@ -296,8 +296,8 @@ public class PartitionCache {
*/
private void getStorageGroupMap(
StorageGroupCacheResult<?> result, List<String> devicePaths, boolean
failFast) {
+ storageGroupCacheLock.readLock().lock();
try {
- storageGroupCacheLock.readLock().lock();
// reset result before try
result.reset();
boolean status = true;
@@ -429,16 +429,16 @@ public class PartitionCache {
public TRegionReplicaSet getRegionReplicaSet(TConsensusGroupId
consensusGroupId) {
TRegionReplicaSet result;
// try to get regionReplicaSet from cache
+ regionReplicaSetLock.readLock().lock();
try {
- regionReplicaSetLock.readLock().lock();
result = groupIdToReplicaSetMap.get(consensusGroupId);
} finally {
regionReplicaSetLock.readLock().unlock();
}
if (result == null) {
// if not hit then try to get regionReplicaSet from confignode
+ regionReplicaSetLock.writeLock().lock();
try {
- regionReplicaSetLock.writeLock().lock();
// verify that there are not hit in cache
if (!groupIdToReplicaSetMap.containsKey(consensusGroupId)) {
try (ConfigNodeClient client =
@@ -472,12 +472,12 @@ public class PartitionCache {
*
* @param timestamp the timestamp of map that need to update
* @param map consensusGroupId to regionReplicaSet map
- * @return true if update successfully or false when map is not latest
+ * @return {@code true} if update successfully or false when map is not
latest
*/
public boolean updateGroupIdToReplicaSetMap(
long timestamp, Map<TConsensusGroupId, TRegionReplicaSet> map) {
+ regionReplicaSetLock.writeLock().lock();
try {
- regionReplicaSetLock.writeLock().lock();
boolean result = (timestamp ==
latestUpdateTime.accumulateAndGet(timestamp, Math::max));
// if timestamp is greater than latestUpdateTime, then update
if (result) {
@@ -492,8 +492,8 @@ public class PartitionCache {
/** invalidate replicaSetCache */
public void invalidReplicaSetCache() {
+ regionReplicaSetLock.writeLock().lock();
try {
- regionReplicaSetLock.writeLock().lock();
groupIdToReplicaSetMap.clear();
} finally {
regionReplicaSetLock.writeLock().unlock();