Skip to content

[IOTDB-1614] New WAL#5320

Merged
qiaojialin merged 42 commits intoapache:masterfrom
HeimingZ:new-wal
Apr 10, 2022
Merged

[IOTDB-1614] New WAL#5320
qiaojialin merged 42 commits intoapache:masterfrom
HeimingZ:new-wal

Conversation

@HeimingZ
Copy link
Contributor

@HeimingZ HeimingZ commented Mar 22, 2022

Details are on design docs.

HeimingZ added 14 commits March 20, 2022 13:34
# Conflicts:
#	node-commons/src/main/java/org/apache/iotdb/commons/conf/IoTDBConstant.java
#	server/src/main/java/org/apache/iotdb/db/engine/StorageEngine.java
#	server/src/main/java/org/apache/iotdb/db/engine/storagegroup/StorageGroupInfo.java
#	server/src/main/java/org/apache/iotdb/db/engine/storagegroup/VirtualStorageGroupProcessor.java
#	server/src/main/java/org/apache/iotdb/db/qp/physical/PhysicalPlan.java
#	server/src/main/java/org/apache/iotdb/db/qp/physical/crud/InsertRowPlan.java
#	server/src/main/java/org/apache/iotdb/db/service/metrics/MetricsService.java
#	server/src/main/java/org/apache/iotdb/db/wal/recover/file/TsFilePlanRedoer.java
#	server/src/main/java/org/apache/iotdb/db/writelog/manager/MultiFileLogNodeManager.java
#	server/src/main/java/org/apache/iotdb/db/writelog/node/ExclusiveWriteLogNode.java
#	server/src/test/java/org/apache/iotdb/db/writelog/IoTDBLogFileSizeTest.java
#	server/src/test/java/org/apache/iotdb/db/writelog/PerformanceTest.java
#	server/src/test/java/org/apache/iotdb/db/writelog/recover/DeviceStringTest.java
#	server/src/test/java/org/apache/iotdb/db/writelog/recover/LogReplayerTest.java
#	server/src/test/java/org/apache/iotdb/db/writelog/recover/RecoverResourceFromReaderTest.java
#	server/src/test/java/org/apache/iotdb/db/writelog/recover/SeqTsFileRecoverTest.java
#	server/src/test/java/org/apache/iotdb/db/writelog/recover/UnseqTsFileRecoverTest.java
Copy link
Member

@wangchao316 wangchao316 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not have permission to open the document. advised to put this doc to jira or confluence.

@HeimingZ
Copy link
Contributor Author

do not have permission to open the document. advised to put this doc to jira or confluence.

I have updated the read authority. It can be seen now. @wangchao316

# The default value 0 means the storage space will not be controlled.
# Notice: If this parameter is too small, the write performance may decline.
# Datatype: int
# wal_storage_space_in_mb=0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this default parameter is 0 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default 0 means the storage space will controlled by iotdb itself, you can see delete method of WALManager. Besides, related functions of this parameter is still under development.

private String timestampPrecision = "ms";

private boolean enableDiscardOutOfOrderData = false;
// region Write Ahead Log Configuration
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this context?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just remove it from the region of wal parameters, you can still see it in IoTDBConfig L777-L778


@Override
public int getMemTableId() {
return memTableId;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

memTableId is a fixed value, memTableIdCounter.getAndIncrement() == 0.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Each memtable has its own id, this value is initialized at AbstractMemTable L87-L88

/** help allocate node for users */
private int nodeCursor = -1;
/** each wal node has a unique long value identifier */
private long nodeIdCounter = -1;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nodeIdCounter should use AtomicLong.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nodeCursor and nodeIdCounter are both protected by the nodesLock of WALManager.


private void allocateBuffers() {
try {
workingBuffer = ByteBuffer.allocateDirect(WAL_BUFFER_SIZE / 2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can the number of ByteBuffer.allocateDirect be controlled? If the number of ByteBuffer.allocateDirect is infinite, the memory will be used up?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The memory usage is controlled by the max number of wal node (each node has a wal buffer), whose corresponding parameter is max_wal_num. You can see wal nodes are reused in WALManger.

logger.info("create folder {} for wal buffer-{}.", logDirectory, identifier);
}
currentLogWriter =
new WALWriter(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super class of WALWriter is AbstractWALBuffer, why new WALWriter in AbstractWALBuffer ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because wal segemented buffer, another type of buffer, can reuse these code. And WALSegementedBuffer is still under development.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, i misunderstand you. The super class of WALWriter is LogWriter, not AbstractWALBuffer.

buffersLock.unlock();
}
}
// endregion
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delete

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get lock at the beginning of this method, so it's unsafe to delete lock release code.

Comment on lines +298 to +312
@Override
public void serializeToWAL(IWALByteBufferView buffer) {
int type = PhysicalPlanType.MULTI_BATCH_INSERT.ordinal();
buffer.put((byte) type);
buffer.putInt(insertTabletPlanList.size());
for (InsertTabletPlan insertTabletPlan : insertTabletPlanList) {
insertTabletPlan.subSerialize(buffer);
}

buffer.putInt(parentInsertTabletPlanIndexList.size());
for (Integer index : parentInsertTabletPlanIndexList) {
buffer.putInt(index);
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any differences with serializeImpl? Add some Javadoc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code logic are same, but IWALByteBufferView encapsulates some actions to deal with BufferOverflowException.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It'll be better to add some javadoc about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is current javadoc in the IWALByteBufferView interface ok?

import java.util.Set;

public abstract class InsertPlan extends PhysicalPlan {
public abstract class InsertPlan extends PhysicalPlan implements WALEditValue {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why implements WALEditValue?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use WALEditValue to manage InsertPlan, DeletePlan and IMemTable, you can see more details in the WALEdit class.

# Conflicts:
#	node-commons/src/main/java/org/apache/iotdb/commons/conf/IoTDBConstant.java
#	server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
#	server/src/main/java/org/apache/iotdb/db/engine/StorageEngine.java
#	server/src/main/java/org/apache/iotdb/db/utils/EnvironmentUtils.java
#	server/src/main/java/org/apache/iotdb/db/writelog/recover/LogReplayer.java
#	server/src/test/java/org/apache/iotdb/db/writelog/PerformanceTest.java
#	server/src/test/java/org/apache/iotdb/db/writelog/recover/DeviceStringTest.java
#	server/src/test/java/org/apache/iotdb/db/writelog/recover/LogReplayerTest.java
#	server/src/test/java/org/apache/iotdb/db/writelog/recover/RecoverResourceFromReaderTest.java
#	server/src/test/java/org/apache/iotdb/db/writelog/recover/SeqTsFileRecoverTest.java
#	server/src/test/java/org/apache/iotdb/db/writelog/recover/UnseqTsFileRecoverTest.java
HeimingZ added 17 commits March 31, 2022 20:26
# Conflicts:
#	server/src/main/java/org/apache/iotdb/db/utils/EnvironmentUtils.java
# Conflicts:
#	library-udf/src/test/java/org/apache/iotdb/library/anomaly/AnomalyTests.java
#	server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfig.java
#	server/src/main/java/org/apache/iotdb/db/conf/IoTDBDescriptor.java
#	server/src/main/java/org/apache/iotdb/db/engine/storagegroup/TsFileProcessor.java
#	server/src/main/java/org/apache/iotdb/db/writelog/node/ExclusiveWriteLogNode.java
#	server/src/main/java/org/apache/iotdb/db/writelog/node/WriteLogNode.java
@qiaojialin qiaojialin merged commit 3c81f56 into apache:master Apr 10, 2022
xinzhongtianxia pushed a commit to xinzhongtianxia/iotdb that referenced this pull request Apr 11, 2022
…er_meta

* remotes/upstream/master:
  [IOTDB-2872] Rename vsg to dataRegion (apache#5470)
  [IOTDB-2806][InfluxDB] Compatibility of Apache IoTDB with InfluxDB - Complete UserGuide (apache#5351)
  [IOTDB-2658] Generate logical plan for query statement  —— UT & Raw Data Query & Aggregation Query (apache#5469)
  [IOTDB-1614] New WAL (apache#5320)
  Update ContributeGuide.md (apache#5463)
  user SerializeDeserializeUtil in confignode/AuthorPlan (apache#5467)
  Modify the jdbc query time column to be empty (apache#5281)
  [IOTDB-2827] Batch insert in new cluster (apache#5412)
  [IOTDB-2801] New storage engine framework (apache#5357)
  [IOTDB-2807]Speed up the cross space compaction by multi-threads (apache#5415)
  Fix coverage check
  [IOTDB-2864] Fix Read-only occurred when insert Text values to aligned timeseries (apache#5460)
  [IOTDB-2803]add AlterTimeSeriesNode and CreateAlignedTimeSeriesNode to PlanNodeType and its serialize and deserialize (apache#5444)
  [IOTDB-2841] add permission manager model (apache#5401)

# Conflicts:
#	server/src/main/java/org/apache/iotdb/db/mpp/sql/analyze/Analyzer.java
#	server/src/main/java/org/apache/iotdb/db/mpp/sql/planner/DistributionPlanner.java
#	server/src/main/java/org/apache/iotdb/db/mpp/sql/planner/LogicalPlanner.java
#	server/src/main/java/org/apache/iotdb/db/mpp/sql/planner/plan/PlanFragment.java
#	server/src/main/java/org/apache/iotdb/db/mpp/sql/planner/plan/node/PlanNodeType.java
#	server/src/main/java/org/apache/iotdb/db/mpp/sql/planner/plan/node/metedata/read/DevicesMetaScanNode.java
#	server/src/main/java/org/apache/iotdb/db/mpp/sql/planner/plan/node/source/SeriesScanNode.java
#	server/src/main/java/org/apache/iotdb/db/mpp/sql/planner/plan/node/source/SourceNode.java
#	server/src/main/java/org/apache/iotdb/db/mpp/sql/statement/StatementVisitor.java
#	server/src/test/java/org/apache/iotdb/db/mpp/sql/plan/LogicalPlannerTest.java
@HeimingZ HeimingZ deleted the new-wal branch April 22, 2022 07:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants