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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]