[IOTDB-868] fix comma bug for mlog#1721
Conversation
samperson1997
left a comment
There was a problem hiding this comment.
Hi Chao, thanks for your contribution! This is a very vital fix. From my first view, I have a few questions to discuss. Could you help and answer them?
server/src/main/java/org/apache/iotdb/db/writelog/io/LogWriter.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfigCheck.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/writelog/io/LogWriter.java
Outdated
Show resolved
Hide resolved
server/src/test/java/org/apache/iotdb/db/integration/IoTDBCreateSnapshotIT.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/sync/receiver/transfer/SyncServiceImpl.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/qp/physical/sys/StorageGroupMNodePlan.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/metadata/logfile/MLogWriter.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfigCheck.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/metadata/MManager.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/metadata/logfile/MLogWriter.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/metadata/logfile/MLogWriter.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/metadata/logfile/MLogWriter.java
Show resolved
Hide resolved
qiaojialin
left a comment
There was a problem hiding this comment.
Good work! It really a lot effort. Finding a way to replace MNodePlan by MNode is better.
server/src/main/java/org/apache/iotdb/db/metadata/logfile/MLogWriter.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/metadata/logfile/MLogWriter.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/metadata/logfile/MLogWriter.java
Outdated
Show resolved
Hide resolved
| import java.io.IOException; | ||
|
|
||
|
|
||
| public class OldMLogReader implements AutoCloseable { |
There was a problem hiding this comment.
rename to MLogTXTReader or add a javadoc : for reading mlog.txt
| try { | ||
| plan.serialize(mlogBuffer); | ||
| } catch (BufferOverflowException e) { | ||
| logger.error("MLog {} BufferOverflow !", plan.getOperatorType(), e); |
There was a problem hiding this comment.
This is not an error case, change this to debug level is better. The case is: Allocate 16MB for buffer and put log into this buffer one by one, In the end, it always trigger the BufferOverflowException, just reseting the buffer is ok.
However, if one log exceeds 16M, this will throw an exception.
| private File logFile; | ||
| private LogWriter logWriter; | ||
| private int logNum; | ||
| private ByteBuffer mlogBuffer = ByteBuffer.allocate( |
There was a problem hiding this comment.
If using a buffer like WAL, we also need a thread to sync the buffer periodically like the forceTask in MultiFileLogNodeManager. Otherwise, the last logs in the buffer will never be persisted.
One option is to sync the mlog one by one.
There was a problem hiding this comment.
yes, I think maybe we need to call the forceTask periodically. Because FileChannel.force(true) is more costful than bufferedWriter.flush, this will result in performance degradation of metadata operation.
| if (plan instanceof StorageGroupMNodePlan) { | ||
| node = StorageGroupMNode.deserializeFrom((StorageGroupMNodePlan) plan); | ||
| childrenSize = ((StorageGroupMNodePlan) plan).getChildSize(); | ||
| } else if (plan instanceof MeasurementMNodePlan) { | ||
| node = MeasurementMNode.deserializeFrom((MeasurementMNodePlan) plan); | ||
| childrenSize = ((MeasurementMNodePlan) plan).getChildSize(); | ||
| } else if (plan instanceof MNodePlan) { | ||
| node = new MNode(null, ((MNodePlan) plan).getName()); | ||
| childrenSize = ((MNodePlan) plan).getChildSize(); | ||
| } |
There was a problem hiding this comment.
The XXMNodePlan is almost the same as the XXMNode, the structure is not a problem. But creating or recovering a snapshot may be slower in this way. Better to test the performance. If the performance does not decrease a lot, this is acceptable. We could test 10M timeseries (10000 device * 1000 measurement)
There was a problem hiding this comment.
ok, I will do some tests.
There was a problem hiding this comment.
I have done some tests, 1M timeseries, the cpu cost it almost same.
| new FileWriter(SystemFileFactory.INSTANCE.getFile(snapshotPath)))) { | ||
| root.serializeTo(bw); | ||
| try (MLogWriter mLogWriter = new MLogWriter(snapshotPath)) { | ||
| root.serializeTo(mLogWriter); |
There was a problem hiding this comment.
Pay attention to force mLogWriter before close it.
c9db0fe to
72e188c
Compare
|
There are some conflicts now, please take a look and fix them. |
fix |
3fd3e5a to
5491c8c
Compare
df0282f to
7a5ad6d
Compare
samperson1997
left a comment
There was a problem hiding this comment.
Hi @mychaow , the parser is quite convenient and I really appreciate your work. Here I have some questions about the details, please have a look ; )
server/src/main/java/org/apache/iotdb/db/tools/mlog/MLogParser.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/tools/mlog/MLogParser.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/tools/mlog/MLogParser.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/tools/mlog/MLogParser.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/tools/mlog/MLogParser.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/qp/physical/sys/StorageGroupMNodePlan.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/metadata/logfile/MLogTxtReader.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfigCheck.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfigCheck.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/metadata/logfile/MLogWriter.java
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/metadata/logfile/MLogWriter.java
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/conf/IoTDBConfigCheck.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/qp/logical/Operator.java
Outdated
Show resolved
Hide resolved
| if (!properties.containsKey(IOTDB_VERSION_STRING)) { | ||
| logger.error("DO NOT UPGRADE IoTDB from v0.9 or lower version to v0.11!" | ||
| + " Please upgrade to v0.10 first"); | ||
| // check whether upgrading from v0.9 to v0.12 |
qiaojialin
left a comment
There was a problem hiding this comment.
There is not a thread to do the periodic Channel.force(true) for MLogWriter, is this meet our expectation?
| * Size of log buffer for every MetaData operation. If the size of a MetaData operation plan | ||
| * is larger than this parameter, then the MetaData operation plan will be rejected by MManager. | ||
| */ | ||
| private int mlogBufferSize = 1024 * 1024; |
There was a problem hiding this comment.
make this consistent with iotdb-engine.properties?
There was a problem hiding this comment.
There is not a thread to do the periodic Channel.force(true) for MLogWriter, is this meet our expectation?
Not,just when we use thread pool to write, and we call shutdown to interrupt the thread, see this
https://stackoverflow.com/questions/1161297/why-are-we-getting-closedbyinterruptexception-from-filechannel-map-in-java-1-6
| logFile = SystemFileFactory.INSTANCE.getFile(logFilePath); | ||
| this.forcePeriodInMs = forcePeriodInMs; | ||
|
|
||
| if (channel == null) { |
There was a problem hiding this comment.
this is always true, said by idea..
There was a problem hiding this comment.
yes, but I think add a check is not redundancy
| this.logFile = logFile; | ||
| this.forcePeriodInMs = forcePeriodInMs; | ||
|
|
||
| if (channel == null) { |
There was a problem hiding this comment.
this is always true, said by idea..
| IoTDBDescriptor.getInstance().getConfig().getMlogBufferSize()); | ||
|
|
||
| // we write log to channel every time, so we need not to call channel.force every time | ||
| private static final long DUMMY_FLUSH_TIME = 100; |
There was a problem hiding this comment.
The function of this field is the same with a boolean
| } | ||
|
|
||
| public LogWriter(File logFile) { | ||
| public LogWriter(File logFile, long forcePeriodInMs) throws FileNotFoundException { |
There was a problem hiding this comment.
The actual usage of 'forcePeriodInMs' parameter is a boolean 'forceAtEachWrite'
There was a problem hiding this comment.
Not that, wal use this to optimize the performance after hundreds of milliseconds.
server/src/main/java/org/apache/iotdb/db/metadata/logfile/MLogWriter.java
Outdated
Show resolved
Hide resolved
server/src/main/java/org/apache/iotdb/db/metadata/logfile/MLogWriter.java
Show resolved
Hide resolved
| CHANGE_TAG_OFFSET, CHANGE_ALIAS, MNODE, | ||
| MEASUREMENT_MNODE, STORAGE_GROUP_MNODE; |
There was a problem hiding this comment.
This could be removed, the operator is only generated in SQL parser.
There was a problem hiding this comment.
I use them to unify the wal and mlog, for deserializing the log.
|
Kudos, SonarCloud Quality Gate passed!
|
After we import the double-quoted path, users may have any characters in the path that includes ",".
If we still record the mlog using csv format, we could not operate correctly to paths like
root.changde.e34c49.struct@VALUE%PRESENT_ANGLE,_CUTTING_HEAD]
The mlog needs to be encoded.
https://issues.apache.org/jira/browse/IOTDB-868