You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by "Xushaohong (via GitHub)" <gi...@apache.org> on 2023/02/28 04:55:27 UTC
[GitHub] [ozone] Xushaohong commented on a diff in pull request #4319: HDDS-8036. Unprotected flush in SCMHADBTransactionBuffer
Xushaohong commented on code in PR #4319:
URL: https://github.com/apache/ozone/pull/4319#discussion_r1119574074
##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHADBTransactionBufferImpl.java:
##########
@@ -56,13 +58,23 @@ private BatchOperation getCurrentBatchOperation() {
@Override
public <KEY, VALUE> void addToBuffer(
Table<KEY, VALUE> table, KEY key, VALUE value) throws IOException {
- table.putWithBatch(getCurrentBatchOperation(), key, value);
+ rwLock.readLock().lock();
Review Comment:
@szetszwo I checked and found as below:
https://github.com/facebook/rocksdb/blob/b7e73501d82661455755b532dff8557e82cb1165/include/rocksdb/write_batch.h#L20-L23
From what I understand, the const method is the method that does not change a member variable of the class. This is exactly the case here we meet, the `flush` will change the `currentBatchOperation` while the `add/remove` will not, so I think the read lock is fine and it is good for performance.
--
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: issues-unsubscribe@ozone.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org