ss77892 commented on code in PR #11080:
URL: https://github.com/apache/ozone/pull/11080#discussion_r4169720064
##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/container/common/transport/server/GrpcXceiverService.java:
##########
@@ -99,22 +119,63 @@ public StreamObserver<ContainerCommandRequestProto> send(
return new StreamObserver<ContainerCommandRequestProto>() {
private final AtomicBoolean isClosed = new AtomicBoolean(false);
private final RandomAccessFileChannel blockFile = new
RandomAccessFileChannel();
+ // Held while a request is served, so the idle closer never closes the
file under an in-flight read.
+ private final ReentrantLock requestLock = new ReentrantLock();
+ private volatile long lastRequestNanos;
+ private volatile ScheduledFuture<?> idleFileCheck;
boolean close() {
if (isClosed.compareAndSet(false, true)) {
+ final ScheduledFuture<?> check = idleFileCheck;
+ if (check != null) {
+ check.cancel(false);
+ }
blockFile.close();
return true;
}
return false;
}
+ private void scheduleIdleFileCheck(long delayNanos) {
+ try {
+ idleFileCheck = idleFileCloser.schedule(this::closeFileIfIdle,
delayNanos, TimeUnit.NANOSECONDS);
+ } catch (RejectedExecutionException e) {
+ // Server is shutting down; the file is closed when the stream ends.
+ LOG.debug("Idle file closer is shut down, not scheduling check", e);
+ }
+ }
+
+ private void closeFileIfIdle() {
Review Comment:
An open handle never kept reads of deleted data working: each request first
looks up the container (CONTAINER_NOT_FOUND after delete or move) and the block
metadata (NO_SUCH_BLOCK after block deletion), whether or not the file is open.
The reopen isn't new either, because before this patch every stream was
recreated every 30s by the deadline. A missing file comes back as a
StorageContainerException, and the client retries it on another replica, which
is correct when the replica is gone. rejectReadBlock would end the whole stream
with a bare gRPC status, which is worse for the client.
--
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]