Yicong-Huang commented on code in PR #6522:
URL: https://github.com/apache/texera/pull/6522#discussion_r3649537698
##########
amber/src/main/python/core/architecture/handlers/control/end_worker_handler.py:
##########
@@ -37,13 +37,19 @@ async def end_worker(self, req: EmptyRequest) ->
EmptyReturn:
has finished not only the data processing logic, but also the
processing
of all the control messages.
"""
- # Ensure this is really the last message.
- input_queue: IQueue = self.context.input_queue
- if not input_queue.is_empty():
+ # Ensure this is really the last message. Read the queued count once
(InternalQueue
+ # exposes size(); the base IQueue interface does not) and branch on it.
+ input_queue: InternalQueue = self.context.input_queue
+ queued_count = input_queue.size()
+ if queued_count > 0:
logger.warning(
- f"Received EndHandler before all messages are "
- f"processed. Unprocessed messages: {input_queue.get()}"
+ f"Received EndWorker before all {queued_count} queued "
+ f"message(s) were processed; failing the RPC so the
coordinator "
+ f"retries once the queue has drained."
Review Comment:
The coordinator retries on a fixed delay (`killRetryDelay`, bounded by
`maxTerminationAttempts`) — it doesn't watch the queue, so "retries once the
queue has drained" can mislead teardown triage into thinking it waits
indefinitely. The comment below uses the same phrasing.
```suggestion
f"message(s) were processed; failing the RPC so a later "
f"coordinator retry succeeds once the queue has drained."
```
##########
amber/src/test/python/core/architecture/handlers/control/test_end_worker_handler.py:
##########
@@ -0,0 +1,97 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+import asyncio
+from types import SimpleNamespace
+
+import pytest
+
+from core.architecture.handlers.control.end_worker_handler import
EndWorkerHandler
+from core.models.internal_queue import DCMElement, InternalQueue
+from proto.org.apache.texera.amber.core import ActorVirtualIdentity,
ChannelIdentity
+from proto.org.apache.texera.amber.engine.architecture.rpc import (
+ EmptyRequest,
+ EmptyReturn,
+)
+from proto.org.apache.texera.amber.engine.common import
DirectControlMessagePayloadV2
+
+
+class TestEndWorkerHandler:
+ @pytest.fixture
+ def input_queue(self):
+ return InternalQueue()
+
+ @pytest.fixture
+ def handler(self, input_queue):
+ # ControlHandler.__init__ just stashes context; bypass the protobuf
+ # base class' __init__ by constructing via __new__.
+ instance = EndWorkerHandler.__new__(EndWorkerHandler)
+ instance.context = SimpleNamespace(input_queue=input_queue)
+ return instance
Review Comment:
`ControlHandler.__init__` only stashes `context` and never calls
`super().__init__()`, so normal construction runs no protobuf-base `__init__`
either — there is nothing to bypass. `test_initialize_executor_handler.py`
builds its handler this way.
```suggestion
return EndWorkerHandler(SimpleNamespace(input_queue=input_queue))
```
--
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]