ndimiduk commented on a change in pull request #2034:
URL: https://github.com/apache/hbase/pull/2034#discussion_r452529869
##########
File path:
hbase-asyncfs/src/main/java/org/apache/hadoop/hbase/io/asyncfs/WrapperAsyncFSOutput.java
##########
@@ -91,7 +93,11 @@ private void flush0(CompletableFuture<Long> future,
ByteArrayOutputStream buffer
out.hflush();
}
}
- future.complete(out.getPos());
+ long pos = out.getPos();
+ if(pos > this.syncedLength) {
Review comment:
I had asked in #1970 if this can be implemented with an `AtomicLong`
instead. @Apache9 responded with an analysis and alternative suggestion.
Following his suggestion, it would be nice to add a comment on
`WrapperAsyncFSOutput` stating that we expect an instance to be used only from
a single thread, foregoing synchronization for the sake of performance.
##########
File path:
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/AsyncProtobufLogWriter.java
##########
@@ -231,4 +231,9 @@ protected long writeWALTrailerAndMagic(WALTrailer trailer,
byte[] magic) throws
protected OutputStream getOutputStreamForCellEncoder() {
return asyncOutputWrapper;
}
+
+ @Override
+ public long getSyncedLength() {
+ return this.output.getSyncedLength();
Review comment:
nit: `this` is unnecessary.
##########
File path:
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/wal/ProtobufLogWriter.java
##########
@@ -85,6 +90,12 @@ public void sync(boolean forceSync) throws IOException {
} else {
fsdos.hflush();
}
+ AtomicUtils.updateMax(this.syncedLength, fsdos.getPos());
Review comment:
I believe I mentioned elsewhere that I think `AtomicUtils.updateMax` can
be replaced with
[`AtomicLong.getAndAccumulate`](https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/atomic/AtomicLong.html#getAndAccumulate-long-java.util.function.LongBinaryOperator-),
something like
```
syncedLength.getAndAccumulate(fsdos.getPos(), Math::max)
```
----------------------------------------------------------------
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:
[email protected]