You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2020/03/23 03:04:56 UTC
[GitHub] [rocketmq] Crearns commented on issue #1876: Broker flush when
END_OF_FILE
Crearns commented on issue #1876: Broker flush when END_OF_FILE
URL: https://github.com/apache/rocketmq/issues/1876#issuecomment-602360807
Thanks for your reply, but sorry i am newbie, I can not understand it, I retell my understanding.
when ```(msgLen + END_FILE_MIN_BLANK_LENGTH) > maxBlank```
it will mark some data to mark the blank and return an END_OF_FILE result
```java
if ((msgLen + END_FILE_MIN_BLANK_LENGTH) > maxBlank) {
this.resetByteBuffer(this.msgStoreItemMemory, maxBlank);
// 1 TOTALSIZE
this.msgStoreItemMemory.putInt(maxBlank);
// 2 MAGICCODE
this.msgStoreItemMemory.putInt(CommitLog.BLANK_MAGIC_CODE);
// 3 The remaining space may be any value
// Here the length of the specially set maxBlank
final long beginTimeMills = CommitLog.this.defaultMessageStore.now();
byteBuffer.put(this.msgStoreItemMemory.array(), 0, maxBlank);
return new AppendMessageResult(AppendMessageStatus.END_OF_FILE, wroteOffset, maxBlank, msgId, msgInner.getStoreTimestamp(),
queueOffset, CommitLog.this.defaultMessageStore.now() - beginTimeMills);
}
```
and in the switch statement
```java
case END_OF_FILE:
unlockMappedFile = mappedFile;
// Create a new file, re-write the message
mappedFile = this.mappedFileQueue.getLastMappedFile(0);
if (null == mappedFile) {
// XXX: warn and notify me
log.error("create mapped file2 error, topic: " + msg.getTopic() + " clientAddr: " + msg.getBornHostString());
beginTimeInLock = 0;
return new PutMessageResult(PutMessageStatus.CREATE_MAPEDFILE_FAILED, result);
}
result = mappedFile.appendMessage(msg, this.appendMessageCallback);
break;
```
when the result is END_OF_FILE, it will call ```result = mappedFile.appendMessage(msg, this.appendMessageCallback);``` to put the message to a new file, it will return a new result and break.Still in memory so far, and it will call ```handleDiskFlush(result, putMessageResult, msg);``` to flush, but it only flush the new file data, the old data that mark the blank can not flush
Don't know if i'm right
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services