Ma77Ball commented on code in PR #9656:
URL: https://github.com/apache/texera/pull/9656#discussion_r4674632704


##########
amber/src/main/python/core/storage/runnables/input_port_materialization_reader_runnable.py:
##########
@@ -110,11 +110,21 @@ def __init__(
         }
         the_partitioning: Partitioning = get_one_of(partitioning)
         partitioner = self._partitioning_to_partitioner[type(the_partitioning)]
-        self.partitioner: Partitioner = (
-            partitioner(the_partitioning)
-            if partitioner != OneToOnePartitioner
-            else partitioner(the_partitioning, self.worker_actor_id)
-        )
+        if partitioner == OneToOnePartitioner:
+            # OneToOnePartitioner picks its receiver from the channel whose
+            # sender is the given worker. This reader stands in for the sender
+            # of the channel that ends at this worker, so name that sender.
+            sender = next(
+                (
+                    channel.from_worker_id.name
+                    for channel in the_partitioning.channels
+                    if channel.to_worker_id == self.worker_actor_id
+                ),
+                None,
+            )
+            self.partitioner: Partitioner = partitioner(the_partitioning, 
sender)

Review Comment:
   This sender lookup now decides whether this worker gets anything at all, but 
no unit test exercises it. `test_state_materialization_e2e.py` only checks the 
replayed StateFrames, which bypass the partitioner, and `run()` marks the 
reader finished even if `flush` yields nothing, so a wrong sender (for example 
comparing `to_worker_id` against a name instead of an identity) would pass CI 
while the worker silently gets no tuples and no EndChannel.
   
   Suggested fix: in `test_input_port_materialization_reader_runnable.py`, 
build a `OneToOnePartitioning` with one channel `producer -> me` and a small 
`batch_size`, run the reader over a few tuples, and assert the queue holds the 
tuples' DataFrames followed by the EndChannel ECM on `self.channel_id`.



##########
amber/src/main/python/core/storage/runnables/input_port_materialization_reader_runnable.py:
##########
@@ -110,11 +110,21 @@ def __init__(
         }
         the_partitioning: Partitioning = get_one_of(partitioning)
         partitioner = self._partitioning_to_partitioner[type(the_partitioning)]
-        self.partitioner: Partitioner = (
-            partitioner(the_partitioning)
-            if partitioner != OneToOnePartitioner
-            else partitioner(the_partitioning, self.worker_actor_id)
-        )
+        if partitioner == OneToOnePartitioner:
+            # OneToOnePartitioner picks its receiver from the channel whose
+            # sender is the given worker. This reader stands in for the sender
+            # of the channel that ends at this worker, so name that sender.
+            sender = next(
+                (
+                    channel.from_worker_id.name
+                    for channel in the_partitioning.channels
+                    if channel.to_worker_id == self.worker_actor_id
+                ),
+                None,
+            )

Review Comment:
   When no channel ends at this worker, `sender` is `None`, the partitioner's 
`receiver` stays `None`, and with the new `flush` guard every flush yields 
nothing. The worker then waits forever for an EndChannel that never comes, 
instead of failing outright like it effectively did before (the old code hit an 
AttributeError on `self.receiver`). A misbuilt partitioning should fail loudly 
here.
   
   Suggested fix:
   
   ```suggestion
               sender = next(
                   (
                       channel.from_worker_id.name
                       for channel in the_partitioning.channels
                       if channel.to_worker_id == self.worker_actor_id
                   ),
                   None,
               )
               if sender is None:
                   raise ValueError(
                       f"no one-to-one channel ends at 
{self.worker_actor_id.name}"
                   )
   ```



-- 
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]

Reply via email to