VGalaxies commented on code in PR #17926:
URL: https://github.com/apache/iotdb/pull/17926#discussion_r3411878458
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/SubscriptionPrefetchingQueue.java:
##########
@@ -731,6 +710,43 @@ protected boolean onEvent() {
return batches.onEvent(this::prefetchEvent);
}
+ private synchronized boolean tryCommitCurrentTerminateEventIfPresent() {
+ if (Objects.isNull(currentTerminateEvent)) {
+ return false;
+ }
+ tryCommitCurrentTerminateEvent();
+ return true;
+ }
+
+ private synchronized boolean tryCommitCurrentTerminateEvent() {
Review Comment:
Addressed by splitting the check from the action:
`hasCurrentTerminateEvent()` now owns the existence check, and
`tryCommitCurrentTerminateEventIfPresent()` performs the commit without
returning an ignored boolean.
##########
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/subscription/broker/SubscriptionPrefetchingQueue.java:
##########
@@ -731,6 +710,43 @@ protected boolean onEvent() {
return batches.onEvent(this::prefetchEvent);
}
+ private synchronized boolean tryCommitCurrentTerminateEventIfPresent() {
+ if (Objects.isNull(currentTerminateEvent)) {
+ return false;
+ }
+ tryCommitCurrentTerminateEvent();
+ return true;
+ }
+
+ private synchronized boolean tryCommitCurrentTerminateEvent() {
+ try {
+ batches.emitAll(this::prefetchEvent);
+ } catch (final Exception e) {
+ LOGGER.warn(
+ "Subscription: SubscriptionPrefetchingQueue {} failed to emit
remaining events before "
+ + "committing PipeTerminateEvent {}.",
+ this,
+ currentTerminateEvent,
+ e);
+ return false;
+ }
+
+ if (!prefetchingQueue.isEmpty() || !inFlightEvents.isEmpty()) {
+ return false;
+ }
+
+ // Add mark completed hook only when all subscription events have been
consumed.
+ currentTerminateEvent.addOnCommittedHook(this::markCompleted);
+ currentTerminateEvent.decreaseReferenceCount(
+ SubscriptionPrefetchingQueue.class.getName(), true);
+ LOGGER.info(
+ "Subscription: SubscriptionPrefetchingQueue {} commit
PipeTerminateEvent {}",
+ this,
+ currentTerminateEvent);
Review Comment:
Addressed by moving these terminate-event log messages into
`DataNodeMiscMessages` for both en and zh locales.
--
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]