OneSizeFitsQuorum commented on code in PR #16869:
URL: https://github.com/apache/iotdb/pull/16869#discussion_r2615976214
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/allocation/AbstractNodeAllocationStrategy.java:
##########
@@ -57,8 +58,16 @@ protected AbstractNodeAllocationStrategy() {
protected IWALNode createWALNode(String identifier) {
try {
- return folderManager.getNextWithRetry(
- folder -> new WALNode(identifier, folder + File.separator +
identifier));
+ // already in lock, so no need to synchronized
+ if (folderManager.get() == null) {
+ folderManager.set(
+ new FolderManager(
+ Arrays.asList(commonConfig.getWalDirs()),
DirectoryStrategyType.SEQUENCE_STRATEGY));
Review Comment:
use synchronized instead as it only has a few overhead
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/allocation/AbstractNodeAllocationStrategy.java:
##########
@@ -57,8 +58,16 @@ protected AbstractNodeAllocationStrategy() {
protected IWALNode createWALNode(String identifier) {
try {
- return folderManager.getNextWithRetry(
- folder -> new WALNode(identifier, folder + File.separator +
identifier));
+ // already in lock, so no need to synchronized
+ if (folderManager.get() == null) {
+ folderManager.set(
+ new FolderManager(
+ Arrays.asList(commonConfig.getWalDirs()),
DirectoryStrategyType.SEQUENCE_STRATEGY));
+ }
+ return folderManager
+ .get()
+ .getNextWithRetry(
+ folder -> new WALNode(identifier, folder + File.separator +
identifier));
Review Comment:
Fixed
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/storageengine/dataregion/wal/allocation/AbstractNodeAllocationStrategy.java:
##########
@@ -57,8 +58,16 @@ protected AbstractNodeAllocationStrategy() {
protected IWALNode createWALNode(String identifier) {
try {
- return folderManager.getNextWithRetry(
- folder -> new WALNode(identifier, folder + File.separator +
identifier));
+ // already in lock, so no need to synchronized
+ if (folderManager.get() == null) {
+ folderManager.set(
+ new FolderManager(
+ Arrays.asList(commonConfig.getWalDirs()),
DirectoryStrategyType.SEQUENCE_STRATEGY));
+ }
Review Comment:
Added
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]