You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@texera.apache.org by "eugenegujing (via GitHub)" <gi...@apache.org> on 2026/07/21 22:07:15 UTC
[PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
eugenegujing opened a new pull request, #6724:
URL: https://github.com/apache/texera/pull/6724
### What changes were proposed in this PR?
In the Python worker, pause and backpressure work by disabling the data sub-queues of `InternalQueue`. However, `disable_data` only disables the sub-queues that exist when it is called, while sub-queues are created lazily on a channel's first `put` and start enabled. A data channel whose first message arrives during a pause or backpressure window therefore comes up enabled and is not covered by the disable at all.
This is a bug because the worker can then keep processing data while reporting PAUSED, and if the leaked `DataElement` is dequeued inside the pause wait-loop in `main_loop.py`, the control-only pampy `match` raises an uncaught `MatchError` that silently kills the DP thread while the heartbeat thread stays alive, so the execution hangs forever with no error reported. Under backpressure, the leaked channel keeps feeding the congested downstream, defeating flow control.
This PR fixes `InternalQueue.put`: when it registers a new data channel while `_queue_state` is non-empty, the new sub-queue now starts disabled. The registration is done under the same lock used by `disable_data`/`enable_data` (with a double-check to avoid duplicate registration), and the sub-queue is disabled before its first element is enqueued, so the element never becomes dequeuable during the disable window. Control channels are never disabled, and `enable_data` needs no change because it iterates the channel set at release time, which by then includes channels registered mid-pause.
Cleanup in the same method: the unreachable `InternalMarker` entry in the isinstance tuple is removed (`InternalMarker` does not subclass `InternalQueueElement`, so it can never reach that branch), and the two identical dispatch branches are merged.
### Any related issues, documentation, discussions?
Fixes #6723. The regression tests extend the `InternalQueue` spec added by #6444.
### How was this PR tested?
Added 8 regression tests to `amber/src/test/python/core/models/test_internal_queue.py`: the late-channel leak (fails without the fix), release via `enable_data`, stacked pause+backpressure disables, control channels staying unblocked mid-pause, pre-registered and normally-registered baselines, and two threaded stress tests that race first-time registrations against disable/enable toggles and assert exact element counts. The whole file passes with 25 passed and 1 xfailed.
The full existing Python unit-test tree under `amber/src/test/python/core` was also run before and after the change, and the pass/fail sets are identical apart from the new tests, so no existing behavior changed.
### Was this PR authored or co-authored using generative AI tooling?
Co-authored by: Claude Code (Claude Fable 5)
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "eugenegujing (via GitHub)" <gi...@apache.org>.
eugenegujing commented on code in PR #6724:
URL: https://github.com/apache/texera/pull/6724#discussion_r3801284924
##########
amber/src/test/python/core/models/test_internal_queue.py:
##########
@@ -364,3 +383,536 @@ def test_it_can_disable_and_enable_a_single_data_channel(
queue.enable(data_channel)
assert queue.get() is blocked
assert queue.is_empty()
+
+ # Regression tests below: a data channel whose sub-queue is created lazily
+ # (on the channel's first put) while disable_data is in effect comes up
+ # ENABLED, because ECMs ride data channels and an ECM landing first on
+ # such a channel must still be delivered. DataElements are instead
+ # withheld on the way out of get(): the channel is closed and the element
+ # is pushed back to the head of its own sub-queue, so a paused or
+ # backpressured worker never consumes data, nothing is lost or reordered,
+ # and is_data_enabled() stays False for the whole disabled period.
+
+ @pytest.mark.timeout(2)
+ @pytest.mark.parametrize(
+ "disable_type",
+ [
+ InternalQueue.DisableType.DISABLE_BY_PAUSE,
+ InternalQueue.DisableType.DISABLE_BY_BACKPRESSURE,
+ ],
+ )
+ def test_ecm_first_on_a_channel_registered_mid_disable_is_delivered(
+ self, queue, data_channel, disable_type
+ ):
+ # The must-fix: ECMs travel on data channels, so a reconfiguration ECM
+ # that is the FIRST-EVER message of a channel registered mid-pause has
+ # to come out; otherwise it is never acked and the coordinator's await
+ # expires. The timeout turns a regression into a failure, not a hang.
+ queue.disable_data(disable_type)
+ ecm = self.ecm_element(data_channel)
+ queue.put(ecm)
+ assert queue.get() is ecm
+
+ @pytest.mark.timeout(10)
+ @pytest.mark.parametrize(
+ "first_element_kind, expected_delivered",
+ [
+ ("data", False),
+ ("ecm", True),
+ ("dcm", True),
+ ],
+ )
+ def test_first_element_kind_decides_delivery_mid_disable(
+ self,
+ queue,
+ data_channel,
+ first_element_kind,
+ expected_delivered,
+ ):
+ # The matrix dimension that matters is the ELEMENT kind, not just the
+ # channel kind: on a data channel registered mid-disable, only a
+ # DataElement is withheld; control-carrying elements flow. The dcm case
+ # is a type gate rather than a real message shape, since a DCMElement
+ # is never tagged with a data channel in production.
+ first = {
+ "data": self.data_element,
+ "ecm": self.ecm_element,
+ "dcm": self.dcm_element,
+ }[first_element_kind](data_channel)
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ queue.put(first) # the channel's first-ever message, mid-disable
+
+ consumer, taken = self.start_consumer(queue)
+ consumer.join(1)
+ if expected_delivered:
+ assert not consumer.is_alive()
+ assert taken[0] is first
+ else:
+ # withheld: nothing is handed out, and the channel is closed
+ assert consumer.is_alive()
+ assert taken == []
+ assert not queue._queue.is_enabled(data_channel)
+ assert queue.size_data() == 1
+ # released only on resume
+ assert queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ consumer.join(5)
+ assert not consumer.is_alive()
+ assert taken[0] is first
+
+ @pytest.mark.timeout(10)
+ def test_data_first_on_a_channel_registered_mid_disable_is_withheld(
+ self, queue, control_channel, data_channel
+ ):
+ # A DataElement handed to get() while data is disabled must be put
+ # back, not consumed: the channel closes, the element stays queued and
+ # keeps its place, and everything queued behind it follows in FIFO
+ # order once data is re-enabled.
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ data_elements = [self.data_element(data_channel) for _ in range(3)]
+ dcm = self.dcm_element(control_channel)
+ queue.put(data_elements[0])
+ queue.put(dcm)
+ in_mem_size_before = queue.in_mem_size()
+
+ # only the control traffic is handed out; this get() is already where
+ # the data element is withheld, closing its channel and leaving it
+ # queued in place before the DCM is returned
+ assert queue.get() is dcm
+ # so a consumer coming back for more now gets nothing
+ consumer, taken = self.start_consumer(queue)
+ consumer.join(1)
+ assert consumer.is_alive()
+ assert taken == []
+ assert not queue._queue.is_enabled(data_channel)
+ assert not queue.is_data_enabled()
+ assert queue.size_data() == 1
+ assert queue.in_mem_size() == in_mem_size_before
+
+ # more data arrives on the now-closed channel and queues up behind it
+ queue.put(data_elements[1])
+ queue.put(data_elements[2])
+ assert queue.size_data() == 3
+ assert consumer.is_alive()
+
+ assert queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ assert queue.is_data_enabled()
+ consumer.join(5)
+ assert not consumer.is_alive()
+ # FIFO is preserved across the withhold: the released element is the
+ # one that was put back, and the later ones follow it
+ results = taken + [queue.get() for _ in range(2)]
+ assert all(got is put for got, put in zip(results, data_elements))
+ assert queue.is_empty()
+ assert queue.in_mem_size() == 0
+
+ @pytest.mark.timeout(2)
+ def test_an_ecm_queued_behind_withheld_data_is_delayed_until_resume(
+ self, queue, control_channel, data_channel
+ ):
+ # KNOWN, PRE-EXISTING LIMITATION, asserted so nobody "fixes" it
+ # silently: withholding a DataElement closes its channel, which also
+ # holds back an ECM queued behind it on that SAME channel. Per-channel
+ # FIFO, "no data while paused" and "deliver ECMs immediately" cannot
+ # all hold once data comes first, short of unbounded buffering that
+ # would defeat backpressure. main behaves the same way for a channel
+ # already disabled by disable_data.
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ data = self.data_element(data_channel)
+ ecm = self.ecm_element(data_channel)
+ dcm = self.dcm_element(control_channel)
+ queue.put(data)
+ queue.put(ecm)
+ queue.put(dcm)
+ assert queue.get() is dcm
+ # the ECM does not overtake the withheld data element in front of it
+ consumer, taken = self.start_consumer(queue)
+ consumer.join(1)
+ assert consumer.is_alive()
+ assert taken == []
+ assert not queue._queue.is_enabled(data_channel)
+ assert queue.size_data() == 2
+ # both are released, in order, on resume
+ assert queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ consumer.join(5)
+ assert not consumer.is_alive()
+ assert taken[0] is data
+ assert queue.get() is ecm
+
+ @pytest.mark.timeout(2)
+ def test_is_data_enabled_stays_false_while_a_disable_reason_is_active(
+ self, queue, data_channel, second_data_channel
+ ):
+ # main_loop's pause wait-loop spins while `not is_control_empty() or
+ # not is_data_enabled()`, so a channel registering mid-pause must not
+ # make is_data_enabled() flip back to True and let the loop exit.
+ queue.put(self.data_element(data_channel))
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ assert not queue.is_data_enabled()
+ # a brand-new channel's first-ever message arrives mid-pause
+ queue.put(self.data_element(second_data_channel))
+ assert not queue.is_data_enabled()
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_BACKPRESSURE)
+ # one reason cleared, one still active
+ assert not queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ assert not queue.is_data_enabled()
+ assert queue.enable_data(InternalQueue.DisableType.DISABLE_BY_BACKPRESSURE)
+ assert queue.is_data_enabled()
+
+ @pytest.mark.timeout(5)
+ def test_a_resume_racing_a_withhold_does_not_strand_the_channel(
+ self, queue, data_channel
+ ):
+ # An element taken while data is disabled, with the last disable
+ # reason cleared before the withhold takes effect, must still be
+ # handed out. Closing the channel at that point would leave it closed
+ # with no reason left for enable_data to clear, stranding that channel
+ # for good. The patched get() places the resume exactly in the window
Review Comment:
Resolved in 87939215dd06e6b6710791c1691a0a74b17f901c
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #6724:
URL: https://github.com/apache/texera/pull/6724#issuecomment-5123472278
<!-- backport-auto-label-report -->
### Backport auto-label report
This `fix:` PR was checked against each actively-supported release branch. `release/*` labels drive the post-merge backport, so add or remove one to change where this fix lands.
| Release branch | Analysis |
| --- | --- |
| ✅ `release/v1.2` | Change detected on this branch — label added; this fix is queued to backport here. Requested review from @xuang7. |
_[Auto-label run](https://github.com/apache/texera/actions/runs/30491860817)._
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "eugenegujing (via GitHub)" <gi...@apache.org>.
eugenegujing commented on code in PR #6724:
URL: https://github.com/apache/texera/pull/6724#discussion_r3779953039
##########
amber/src/test/python/core/models/test_internal_queue.py:
##########
@@ -364,3 +365,297 @@ def test_it_can_disable_and_enable_a_single_data_channel(
queue.enable(data_channel)
assert queue.get() is blocked
assert queue.is_empty()
+
+ # Regression tests below: data channels whose sub-queue is created lazily
+ # (on the channel's first put) AFTER disable_data has been called must
+ # come up disabled — a paused or backpressured worker must not be able to
+ # dequeue data from them, and is_data_enabled() must not flip back to
+ # True just because a new channel delivered its first message.
+
+ def test_channel_registered_after_disable_comes_up_disabled(
+ self, queue, data_channel
+ ):
+ # the main regression: disable first, then the channel's FIRST put
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ queue.put(self.data_element(data_channel))
+ assert not queue.is_data_enabled()
+ # the element stays queued but must not be dequeuable
+ assert queue.size_data() == 1
+ assert queue._queue.peek() is None
+
+ @pytest.mark.timeout(2)
+ def test_enable_data_releases_a_channel_registered_mid_disable(
+ self, queue, data_channel
+ ):
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ data = self.data_element(data_channel)
+ queue.put(data)
+ assert queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ assert queue.is_data_enabled()
+ assert queue._queue.peek() is data
+ assert queue.get() is data
+ assert queue.is_empty()
+
+ @pytest.mark.timeout(2)
+ def test_channel_registered_under_stacked_disables_stays_disabled(
+ self, queue, data_channel
+ ):
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_BACKPRESSURE)
+ data = self.data_element(data_channel)
+ queue.put(data)
+ # releasing only one of the two reasons must not open the channel
+ assert not queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ assert not queue.is_data_enabled()
+ assert queue._queue.peek() is None
+ # releasing the remaining reason makes the element dequeuable
+ assert queue.enable_data(InternalQueue.DisableType.DISABLE_BY_BACKPRESSURE)
+ assert queue.is_data_enabled()
+ assert queue.get() is data
+
+ @pytest.mark.timeout(2)
+ def test_control_channel_registered_mid_disable_is_never_blocked(
Review Comment:
Added in 1a65167ba49f280df7cfeaf195adb6c87a3689b7. The matrix now enumerates a channel's first element by kind (`DataElement` / `ECMElement` / `DCMElement`), plus dedicated ECM-first tests for both PAUSE and BACKPRESSURE carrying a 2s timeout, so a regression surfaces as a timeout rather than a hang. Reinstating the born-disabled gate turns them red.
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on PR #6724:
URL: https://github.com/apache/texera/pull/6724#issuecomment-5291371369
Retracting the must-fix I posted in round 3 (https://github.com/apache/texera/pull/6724#discussion_r3764810946). It was wrong, and it sent you through a full redesign for the wrong reason. That is on us, not on anything in your implementation.
**What I got wrong.** I read `ReconfigurationIntegrationSpec`'s 30s timeout as an engine deadlock and concluded that a born-disabled channel makes a reconfiguration ECM *undeliverable*. It does not. `enable_data()` re-enables every non-control channel in `_queue_ids`, including one that registered mid-pause, so the ECM was **delayed until resume, never lost**. What actually timed out was the test harness, and it was waiting for something production never waits for.
**The engine's semantics is "no ECM while paused."** It is stated outright at `ExecutionReconfigurationService.scala:56-57`:
> reconfigurations can only come when the workflow is paused, they are not actually performed until the workflow is resumed
and the production path is built to match. `ExecutionReconfigurationService.scala:109-111` is `protected def dispatch(request: WorkflowReconfigureRequest): Unit = { client.coordinatorInterface.reconfigureWorkflow(request, ()) }` — the Future is discarded and the method returns `Unit` — and `ExecutionRuntimeService` sends `resumeWorkflow` immediately afterwards. Nothing in production blocks on the reconfigure Future while paused.
`TestUtils.scala:375-383` does precisely that: `Await.result(reconfigureWorkflow(...), commandTimeout)` **while still paused**, and only then `resumeWorkflow`. That await is a harness-only contract, and it is what born-disabled violated — not the engine's.
**The JVM worker cannot satisfy that contract either.** With `isPaused` true, `DPThread.scala:167-181` has exactly one branch — `tryPickControlChannel`, otherwise `waitingForInput = true` — and that selector filters on `cid.isControl` (`NetworkInputGateway.scala:42`). An ECM sitting in a *data* channel's queue is structurally invisible to a paused Scala worker, and there is no bypass. The pure-Scala `ReconfigurationSpec` stays green only because `mediumCsvScanOpDesc -> keywordSearch` yields a singleton MCS and takes `ReconfigurationHandler.scala:66`'s `scope.size == 1` branch, a direct DCM on the control channel, so it never exercises the ECM branch at all.
The contrast inside this very spec makes the point sharper. "modify two python UDFs" builds `source -> udf1 -> udf2` with `targetOps = Seq(udf1, udf2)`, so the Fries component has `scope.size == 2`, takes the ECM branch, and seeds only `sources = {udf1}`. For that test to pass while paused, udf2 must consume an ECM off the udf1->udf2 *data* channel — which `DPThread` would never permit a Scala worker to do. The behavior I asked you to preserve is one no JVM worker has ever had.
**Where that leaves the current approach.** The withhold path releases an ECM only when it happens to be a channel's *first* element; when data lands first, the ECM waits for resume anyway — the limitation you documented and pinned with a test. The spec is green because the slow source's first tuple arrives after the pause. Speeding the source up turns the same test red with no code change. So the guarantee ends up timing-dependent rather than structural, and the `put_first`/`enqueue_first` addition to `LinkedBlockingMultiQueue` is what is paying for it.
**Suggested direction.** Return to the born-disabled gate from the original revision — it is smaller, leaves `LinkedBlockingMultiQueue` untouched, and matches `DPThread`'s pause semantics — and fix the harness instead: have `TestUtils.shouldReconfigure` follow the production order, dispatching the reconfiguration without awaiting it, then resuming, then awaiting completion. That also removes the timing dependence from the spec.
If you see a reason the Python worker *should* diverge from `DPThread` here, push back and I will dig further; I have already been wrong once on this. The round-4 review I posted a few minutes ago stands on its other points (the title, the `put_first` tests, the two comment fixes), but treat anything in it that endorses the withhold design as superseded by this comment.
Apologies for the round trip — you implemented exactly what I asked for, and the ask was mine to get right.
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "eugenegujing (via GitHub)" <gi...@apache.org>.
eugenegujing commented on PR #6724:
URL: https://github.com/apache/texera/pull/6724#issuecomment-5249685042
@Yicong-Huang Hi Yicong, I think we need a second look on the CI read: the `ReconfigurationIntegrationSpec` failures appear to be caused by this PR. The job failed on both runners on every push of this branch across three main bases, while main/merge-queue runs are green (42/42), and I reproduced it locally with tracing.
The tests pause before the slow source's first tuple, so the Fries reconfiguration ECM is the first-ever message on the source→udf data channel, which now registers born-disabled and swallows the marker. `updateExecutor` is never acked and `reconfigureWorkflow` times out at 30s (on main this only works *because of* the leak this PR fixes).
The `PAUSED→COMPLETED` tracebacks are secondary fallout from two pre-existing potential bugs (`_check_and_process_control` processes ECMs under a stale `current_input_channel_id`, and `PauseManager.resume` re-enables ECM_PAUSE channels before checking `_global_pauses`). So this PR might need more work. I'd either move the leak fix to the dequeue side (stash a leaked DataElement, retro-disable its channel, re-inject on resume) or settle the "markers depend on the leak" question at the design level first. What do you think?
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "eugenegujing (via GitHub)" <gi...@apache.org>.
eugenegujing commented on code in PR #6724:
URL: https://github.com/apache/texera/pull/6724#discussion_r3779941581
##########
amber/src/main/python/core/models/internal_queue.py:
##########
@@ -77,11 +76,19 @@ def get(self) -> T:
def put(self, item: T) -> None:
if isinstance(item, InternalQueueElement):
if item.tag not in self._queue_ids:
- self._queue.add_sub_queue(item.tag, 1 if item.tag.is_control else 2)
- self._queue_ids.add(item.tag)
- if isinstance(item, (DataElement, InternalMarker, ECMElement)):
- self._queue.put(item.tag, item)
- elif isinstance(item, DCMElement):
+ # registration must not interleave with disable_data/enable_data
+ with self._lock:
+ if item.tag not in self._queue_ids:
+ self._queue.add_sub_queue(
+ item.tag, 1 if item.tag.is_control else 2
+ )
+ # while data is disabled, a new data sub-queue must
+ # start disabled too (before its first element is
+ # enqueued), or it would leak data during pause/backpressure
+ if not item.tag.is_control and self._queue_state:
Review Comment:
Reworked to the dequeue-side option in 1a65167ba49f280df7cfeaf195adb6c87a3689b7
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "eugenegujing (via GitHub)" <gi...@apache.org>.
eugenegujing commented on PR #6724:
URL: https://github.com/apache/texera/pull/6724#issuecomment-5290036312
@Yicong-Huang PTAL!
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #6724:
URL: https://github.com/apache/texera/pull/6724#issuecomment-5039558843
<!-- texera-benchmarks-comment -->
## ⚠️ Benchmark changes need a look
🟢 0 better · 🔴 5 worse · ⚪ 10 noise (<±5%) · 0 without baseline
> Compared against main `0467c76` benchmarked on **this same runner**, so the delta is largely free of cross-runner hardware noise. The "7d avg" column still reflects the gh-pages dashboard. Treat <±5% as noise unless repeated.
[Dashboard](https://apache.github.io/texera/dev/bench/) · [Run](https://github.com/apache/texera/actions/runs/29872604345)
| | config | throughput | MB/s | latency | max Δ latest / 7d |
|---|---|---:|---:|---:|---:|
| 🔴 | bs=10 sw=10 sl=64 | 408 | 0.249 | 22,926/33,519/33,519 us | 🔴 -13.5% / 🔴 +112.0% |
| ⚪ | bs=100 sw=10 sl=64 | 924 | 0.564 | 107,563/129,503/129,503 us | ⚪ within ±5% / 🔴 +23.3% |
| ⚪ | bs=1000 sw=10 sl=64 | 1,099 | 0.671 | 908,928/956,748/956,748 us | ⚪ within ±5% / 🟢 -8.1% |
<details><summary>Baseline details</summary>
Latest main `0467c76` from same runner
| config | metric | PR | latest main | 7d avg | Δ latest | Δ 7d |
|---|---|---:|---:|---:|---:|---:|
| bs=10 sw=10 sl=64 | throughput | 408 tuples/sec | 471 tuples/sec | 769.76 tuples/sec | -13.4% | -47.0% |
| bs=10 sw=10 sl=64 | MB/s | 0.249 MB/s | 0.288 MB/s | 0.47 MB/s | -13.5% | -47.0% |
| bs=10 sw=10 sl=64 | p50 | 22,926 us | 20,456 us | 12,663 us | +12.1% | +81.1% |
| bs=10 sw=10 sl=64 | p95 | 33,519 us | 30,388 us | 15,813 us | +10.3% | +112.0% |
| bs=10 sw=10 sl=64 | p99 | 33,519 us | 30,388 us | 19,001 us | +10.3% | +76.4% |
| bs=100 sw=10 sl=64 | throughput | 924 tuples/sec | 969 tuples/sec | 1,009 tuples/sec | -4.6% | -8.5% |
| bs=100 sw=10 sl=64 | MB/s | 0.564 MB/s | 0.591 MB/s | 0.616 MB/s | -4.6% | -8.5% |
| bs=100 sw=10 sl=64 | p50 | 107,563 us | 104,483 us | 99,444 us | +2.9% | +8.2% |
| bs=100 sw=10 sl=64 | p95 | 129,503 us | 124,799 us | 105,012 us | +3.8% | +23.3% |
| bs=100 sw=10 sl=64 | p99 | 129,503 us | 124,799 us | 116,467 us | +3.8% | +11.2% |
| bs=1000 sw=10 sl=64 | throughput | 1,099 tuples/sec | 1,067 tuples/sec | 1,044 tuples/sec | +3.0% | +5.2% |
| bs=1000 sw=10 sl=64 | MB/s | 0.671 MB/s | 0.651 MB/s | 0.637 MB/s | +3.1% | +5.3% |
| bs=1000 sw=10 sl=64 | p50 | 908,928 us | 939,646 us | 964,034 us | -3.3% | -5.7% |
| bs=1000 sw=10 sl=64 | p95 | 956,748 us | 972,712 us | 1,007,497 us | -1.6% | -5.0% |
| bs=1000 sw=10 sl=64 | p99 | 956,748 us | 972,712 us | 1,040,936 us | -1.6% | -8.1% |
</details>
<details><summary>Raw CSV</summary>
```csv
config_idx,batch_size,schema_width,string_len,num_batches,total_ms,total_tuples,total_bytes,tuples_per_sec,mb_per_sec,lat_p50_us,lat_p95_us,lat_p99_us
0,10,10,64,20,490.36,200,128000,408,0.249,22925.90,33518.56,33518.56
1,100,10,64,20,2165.15,2000,1280000,924,0.564,107562.95,129503.18,129503.18
2,1000,10,64,20,18198.71,20000,12800000,1099,0.671,908927.61,956747.93,956747.93
```
</details>
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang merged PR #6724:
URL: https://github.com/apache/texera/pull/6724
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "eugenegujing (via GitHub)" <gi...@apache.org>.
eugenegujing commented on code in PR #6724:
URL: https://github.com/apache/texera/pull/6724#discussion_r3634756751
##########
amber/src/main/python/core/models/internal_queue.py:
##########
@@ -77,11 +76,19 @@ def get(self) -> T:
def put(self, item: T) -> None:
if isinstance(item, InternalQueueElement):
if item.tag not in self._queue_ids:
- self._queue.add_sub_queue(item.tag, 1 if item.tag.is_control else 2)
- self._queue_ids.add(item.tag)
- if isinstance(item, (DataElement, InternalMarker, ECMElement)):
- self._queue.put(item.tag, item)
- elif isinstance(item, DCMElement):
+ # registration must not interleave with disable_data/enable_data
+ with self._lock:
Review Comment:
I think the lock might not quite be on the hot path as it's only reachable on a channel's first put. I instrumented it to verify: for 100k puts across 10 channels acquire the lock exactly 10 times. Also, I think the layer below already locks on every element: SubQueue.put takes put_lock and get takes take_lock on each call. I did try a lock-free version (publish the channel id first, then re-check _queue_state), but there's a window where the element lands in the still-enabled sub-queue before disable_data gets to it, which reopens the same leak this PR fixes. The lock-free issues could probably be worked around by creating the sub-queue disabled and only enabling it after rechecking the state, switching _queue_ids to copy-on-write, but that version might be overcomplicated. This lock might feel like the simpler safe choice. Happy to discuss!
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #6724:
URL: https://github.com/apache/texera/pull/6724#discussion_r3782142166
##########
amber/src/main/python/core/models/internal_queue.py:
##########
@@ -72,16 +71,54 @@ def is_empty(self, key=None) -> bool:
return self._queue.is_empty(key)
def get(self) -> T:
- return self._queue.get()
+ """Blocking get of the next available element.
+
+ Data channels register enabled even during a disable window, because
+ ECMs ride data channels and one swallowed by a channel that came up
+ disabled would never be acked. A DataElement arriving here during
+ such a window is withheld instead: its channel is closed and the
+ element goes back to its sub-queue's head, for enable_data() to
+ release. An ECM queued behind it on the same channel is therefore
+ delayed until resume, which is unavoidable without unbounded
+ buffering, and is what main does for channels disable_data() closed.
Review Comment:
`main` is the branch this docstring is about to become part of, so once merged the sentence compares the code to itself. The behavior it points at is real: a channel `disable_data()` already closed does hold its ECM until resume. Naming that instead of the branch keeps the rationale and survives the merge.
```suggestion
buffering, and already happens for channels disable_data() has closed.
```
Same wording at `test_internal_queue.py:517`.
##########
amber/src/main/python/core/util/customized_queue/linked_blocking_multi_queue.py:
##########
@@ -149,6 +157,26 @@ def put(self, obj: T) -> None:
if old_size == 0:
self.owner._signal_not_empty()
+ def put_first(self, obj: T) -> None:
Review Comment:
`put_first`/`enqueue_first` get no tests in this file's own suite. It is otherwise thorough about exactly this: `remove()` — the method `put_first` mirrors and whose locking it cites — has six, covering first/middle/last/only-item and the disabled-sub-queue accounting. `put` has a `None`-guard test.
The gap matters because `InternalQueue.get()` always disables the sub-queue first. So this method's `if self.enabled` branch, its `old_size == 0` wake-up, and its `None` guard are executed by nothing. A pair of tests mirroring `test_remove_*` would close it.
##########
amber/src/test/python/core/models/test_internal_queue.py:
##########
@@ -364,3 +383,536 @@ def test_it_can_disable_and_enable_a_single_data_channel(
queue.enable(data_channel)
assert queue.get() is blocked
assert queue.is_empty()
+
+ # Regression tests below: a data channel whose sub-queue is created lazily
+ # (on the channel's first put) while disable_data is in effect comes up
+ # ENABLED, because ECMs ride data channels and an ECM landing first on
+ # such a channel must still be delivered. DataElements are instead
+ # withheld on the way out of get(): the channel is closed and the element
+ # is pushed back to the head of its own sub-queue, so a paused or
+ # backpressured worker never consumes data, nothing is lost or reordered,
+ # and is_data_enabled() stays False for the whole disabled period.
+
+ @pytest.mark.timeout(2)
+ @pytest.mark.parametrize(
+ "disable_type",
+ [
+ InternalQueue.DisableType.DISABLE_BY_PAUSE,
+ InternalQueue.DisableType.DISABLE_BY_BACKPRESSURE,
+ ],
+ )
+ def test_ecm_first_on_a_channel_registered_mid_disable_is_delivered(
+ self, queue, data_channel, disable_type
+ ):
+ # The must-fix: ECMs travel on data channels, so a reconfiguration ECM
+ # that is the FIRST-EVER message of a channel registered mid-pause has
+ # to come out; otherwise it is never acked and the coordinator's await
+ # expires. The timeout turns a regression into a failure, not a hang.
+ queue.disable_data(disable_type)
+ ecm = self.ecm_element(data_channel)
+ queue.put(ecm)
+ assert queue.get() is ecm
+
+ @pytest.mark.timeout(10)
+ @pytest.mark.parametrize(
+ "first_element_kind, expected_delivered",
+ [
+ ("data", False),
+ ("ecm", True),
+ ("dcm", True),
+ ],
+ )
+ def test_first_element_kind_decides_delivery_mid_disable(
+ self,
+ queue,
+ data_channel,
+ first_element_kind,
+ expected_delivered,
+ ):
+ # The matrix dimension that matters is the ELEMENT kind, not just the
+ # channel kind: on a data channel registered mid-disable, only a
+ # DataElement is withheld; control-carrying elements flow. The dcm case
+ # is a type gate rather than a real message shape, since a DCMElement
+ # is never tagged with a data channel in production.
+ first = {
+ "data": self.data_element,
+ "ecm": self.ecm_element,
+ "dcm": self.dcm_element,
+ }[first_element_kind](data_channel)
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ queue.put(first) # the channel's first-ever message, mid-disable
+
+ consumer, taken = self.start_consumer(queue)
+ consumer.join(1)
+ if expected_delivered:
+ assert not consumer.is_alive()
+ assert taken[0] is first
+ else:
+ # withheld: nothing is handed out, and the channel is closed
+ assert consumer.is_alive()
+ assert taken == []
+ assert not queue._queue.is_enabled(data_channel)
+ assert queue.size_data() == 1
+ # released only on resume
+ assert queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ consumer.join(5)
+ assert not consumer.is_alive()
+ assert taken[0] is first
+
+ @pytest.mark.timeout(10)
+ def test_data_first_on_a_channel_registered_mid_disable_is_withheld(
+ self, queue, control_channel, data_channel
+ ):
+ # A DataElement handed to get() while data is disabled must be put
+ # back, not consumed: the channel closes, the element stays queued and
+ # keeps its place, and everything queued behind it follows in FIFO
+ # order once data is re-enabled.
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ data_elements = [self.data_element(data_channel) for _ in range(3)]
+ dcm = self.dcm_element(control_channel)
+ queue.put(data_elements[0])
+ queue.put(dcm)
+ in_mem_size_before = queue.in_mem_size()
+
+ # only the control traffic is handed out; this get() is already where
+ # the data element is withheld, closing its channel and leaving it
+ # queued in place before the DCM is returned
+ assert queue.get() is dcm
+ # so a consumer coming back for more now gets nothing
+ consumer, taken = self.start_consumer(queue)
+ consumer.join(1)
+ assert consumer.is_alive()
+ assert taken == []
+ assert not queue._queue.is_enabled(data_channel)
+ assert not queue.is_data_enabled()
+ assert queue.size_data() == 1
+ assert queue.in_mem_size() == in_mem_size_before
+
+ # more data arrives on the now-closed channel and queues up behind it
+ queue.put(data_elements[1])
+ queue.put(data_elements[2])
+ assert queue.size_data() == 3
+ assert consumer.is_alive()
+
+ assert queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ assert queue.is_data_enabled()
+ consumer.join(5)
+ assert not consumer.is_alive()
+ # FIFO is preserved across the withhold: the released element is the
+ # one that was put back, and the later ones follow it
+ results = taken + [queue.get() for _ in range(2)]
+ assert all(got is put for got, put in zip(results, data_elements))
+ assert queue.is_empty()
+ assert queue.in_mem_size() == 0
+
+ @pytest.mark.timeout(2)
+ def test_an_ecm_queued_behind_withheld_data_is_delayed_until_resume(
+ self, queue, control_channel, data_channel
+ ):
+ # KNOWN, PRE-EXISTING LIMITATION, asserted so nobody "fixes" it
+ # silently: withholding a DataElement closes its channel, which also
+ # holds back an ECM queued behind it on that SAME channel. Per-channel
+ # FIFO, "no data while paused" and "deliver ECMs immediately" cannot
+ # all hold once data comes first, short of unbounded buffering that
+ # would defeat backpressure. main behaves the same way for a channel
+ # already disabled by disable_data.
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ data = self.data_element(data_channel)
+ ecm = self.ecm_element(data_channel)
+ dcm = self.dcm_element(control_channel)
+ queue.put(data)
+ queue.put(ecm)
+ queue.put(dcm)
+ assert queue.get() is dcm
+ # the ECM does not overtake the withheld data element in front of it
+ consumer, taken = self.start_consumer(queue)
+ consumer.join(1)
+ assert consumer.is_alive()
+ assert taken == []
+ assert not queue._queue.is_enabled(data_channel)
+ assert queue.size_data() == 2
+ # both are released, in order, on resume
+ assert queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ consumer.join(5)
+ assert not consumer.is_alive()
+ assert taken[0] is data
+ assert queue.get() is ecm
+
+ @pytest.mark.timeout(2)
+ def test_is_data_enabled_stays_false_while_a_disable_reason_is_active(
+ self, queue, data_channel, second_data_channel
+ ):
+ # main_loop's pause wait-loop spins while `not is_control_empty() or
+ # not is_data_enabled()`, so a channel registering mid-pause must not
+ # make is_data_enabled() flip back to True and let the loop exit.
+ queue.put(self.data_element(data_channel))
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ assert not queue.is_data_enabled()
+ # a brand-new channel's first-ever message arrives mid-pause
+ queue.put(self.data_element(second_data_channel))
+ assert not queue.is_data_enabled()
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_BACKPRESSURE)
+ # one reason cleared, one still active
+ assert not queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ assert not queue.is_data_enabled()
+ assert queue.enable_data(InternalQueue.DisableType.DISABLE_BY_BACKPRESSURE)
+ assert queue.is_data_enabled()
+
+ @pytest.mark.timeout(5)
+ def test_a_resume_racing_a_withhold_does_not_strand_the_channel(
+ self, queue, data_channel
+ ):
+ # An element taken while data is disabled, with the last disable
+ # reason cleared before the withhold takes effect, must still be
+ # handed out. Closing the channel at that point would leave it closed
+ # with no reason left for enable_data to clear, stranding that channel
+ # for good. The patched get() places the resume exactly in the window
Review Comment:
Nothing patches `get()` — line 583 swaps `queue._lock` for the `ResumingLock` defined just below, which is what lands the resume inside the withhold's lock acquisition. Worth correcting because this comment is the only explanation of how the test reaches a window too narrow to race.
```suggestion
# for good. The patched lock places the resume exactly in the window
```
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "eugenegujing (via GitHub)" <gi...@apache.org>.
eugenegujing commented on code in PR #6724:
URL: https://github.com/apache/texera/pull/6724#discussion_r3801283969
##########
amber/src/main/python/core/models/internal_queue.py:
##########
@@ -72,16 +71,54 @@ def is_empty(self, key=None) -> bool:
return self._queue.is_empty(key)
def get(self) -> T:
- return self._queue.get()
+ """Blocking get of the next available element.
+
+ Data channels register enabled even during a disable window, because
+ ECMs ride data channels and one swallowed by a channel that came up
+ disabled would never be acked. A DataElement arriving here during
+ such a window is withheld instead: its channel is closed and the
+ element goes back to its sub-queue's head, for enable_data() to
+ release. An ECM queued behind it on the same channel is therefore
+ delayed until resume, which is unavoidable without unbounded
+ buffering, and is what main does for channels disable_data() closed.
Review Comment:
Resolved in 87939215dd06e6b6710791c1691a0a74b17f901c
##########
amber/src/main/python/core/util/customized_queue/linked_blocking_multi_queue.py:
##########
@@ -149,6 +157,26 @@ def put(self, obj: T) -> None:
if old_size == 0:
self.owner._signal_not_empty()
+ def put_first(self, obj: T) -> None:
Review Comment:
Resolved in 87939215dd06e6b6710791c1691a0a74b17f901c
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "eugenegujing (via GitHub)" <gi...@apache.org>.
eugenegujing commented on PR #6724:
URL: https://github.com/apache/texera/pull/6724#issuecomment-5324159294
@Yicong-Huang PTAL!
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #6724:
URL: https://github.com/apache/texera/pull/6724#issuecomment-5460723025
Backport PR opened: draft #8093 (https://github.com/apache/texera/pull/8093) to `release/v1.2`, assigned to @eugenegujing — needs manual work because the cherry-pick conflicts.
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "aglinxinyuan (via GitHub)" <gi...@apache.org>.
aglinxinyuan commented on PR #6724:
URL: https://github.com/apache/texera/pull/6724#issuecomment-5040463094
Can you provide a real workflow that can reproduce this bug?
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #6724:
URL: https://github.com/apache/texera/pull/6724#discussion_r3626619661
##########
amber/src/main/python/core/models/internal_queue.py:
##########
@@ -77,11 +76,19 @@ def get(self) -> T:
def put(self, item: T) -> None:
if isinstance(item, InternalQueueElement):
if item.tag not in self._queue_ids:
- self._queue.add_sub_queue(item.tag, 1 if item.tag.is_control else 2)
- self._queue_ids.add(item.tag)
- if isinstance(item, (DataElement, InternalMarker, ECMElement)):
- self._queue.put(item.tag, item)
- elif isinstance(item, DCMElement):
+ # registration must not interleave with disable_data/enable_data
+ with self._lock:
Review Comment:
can we avoid locking? the whole design is to use a lock free data structure in the hot path (e.g., put and get)
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "eugenegujing (via GitHub)" <gi...@apache.org>.
eugenegujing commented on PR #6724:
URL: https://github.com/apache/texera/pull/6724#issuecomment-5052724109
> Can you provide a real workflow that can reproduce this bug?
Here's a real repro on main (screenshot). The workflow is scan → sort → Python UDF. Sort is blocking, so the UDF runs in a second region and reads its input from storage through the materialization reader threads. I clicked pause right when the second region started, before the readers sent anything. Their channel was registered after disable_data, so it came up enabled, and the paused worker went on to consume the whole input and call complete(), which threw InvalidTransitionException: Cannot transit from PAUSED to COMPLETED and killed the DP thread. The heartbeat thread is still alive, so resume never gets processed and the execution stays stuck in "Resuming" with no error shown anywhere. With the fix, the channel starts disabled and the same run finishes normally after resume.
<img width="1157" height="807" alt="Screenshot 2026-07-22 at 4 08 24 PM" src="https://github.com/user-attachments/assets/0c74d841-970b-408b-812d-239e7f18958e" />
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "eugenegujing (via GitHub)" <gi...@apache.org>.
eugenegujing commented on code in PR #6724:
URL: https://github.com/apache/texera/pull/6724#discussion_r3762623052
##########
amber/src/main/python/core/models/internal_queue.py:
##########
@@ -149,13 +158,13 @@ def disable_data(self, disable_type: DisableType) -> None:
def in_mem_size(self) -> int:
return sum(
self._queue.in_mem_size(queue_id)
- for queue_id in self._queue_ids
+ for queue_id in tuple(self._queue_ids)
Review Comment:
Applied in 92f4dc3e6202653043c8f51e5ed3aa738ef18aa6
##########
amber/src/test/python/core/models/test_internal_queue.py:
##########
@@ -364,3 +365,297 @@ def test_it_can_disable_and_enable_a_single_data_channel(
queue.enable(data_channel)
assert queue.get() is blocked
assert queue.is_empty()
+
+ # Regression tests below: data channels whose sub-queue is created lazily
+ # (on the channel's first put) AFTER disable_data has been called must
+ # come up disabled — a paused or backpressured worker must not be able to
+ # dequeue data from them, and is_data_enabled() must not flip back to
+ # True just because a new channel delivered its first message.
+
+ def test_channel_registered_after_disable_comes_up_disabled(
+ self, queue, data_channel
+ ):
+ # the main regression: disable first, then the channel's FIRST put
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ queue.put(self.data_element(data_channel))
+ assert not queue.is_data_enabled()
+ # the element stays queued but must not be dequeuable
+ assert queue.size_data() == 1
+ assert queue._queue.peek() is None
+
+ @pytest.mark.timeout(2)
+ def test_enable_data_releases_a_channel_registered_mid_disable(
+ self, queue, data_channel
+ ):
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ data = self.data_element(data_channel)
+ queue.put(data)
+ assert queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ assert queue.is_data_enabled()
+ assert queue._queue.peek() is data
+ assert queue.get() is data
+ assert queue.is_empty()
+
+ @pytest.mark.timeout(2)
+ def test_channel_registered_under_stacked_disables_stays_disabled(
+ self, queue, data_channel
+ ):
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_BACKPRESSURE)
+ data = self.data_element(data_channel)
+ queue.put(data)
+ # releasing only one of the two reasons must not open the channel
+ assert not queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ assert not queue.is_data_enabled()
+ assert queue._queue.peek() is None
+ # releasing the remaining reason makes the element dequeuable
+ assert queue.enable_data(InternalQueue.DisableType.DISABLE_BY_BACKPRESSURE)
+ assert queue.is_data_enabled()
+ assert queue.get() is data
+
+ @pytest.mark.timeout(2)
+ def test_control_channel_registered_mid_disable_is_never_blocked(
+ self, queue, control_channel, data_channel
+ ):
+ # register a data channel first so is_data_enabled() is meaningful
+ queue.put(self.data_element(data_channel))
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ # the control channel's FIRST put happens while data is disabled
+ dcm = self.dcm_element(control_channel)
+ queue.put(dcm)
+ # control must flow immediately, and data must stay disabled
+ assert queue._queue.peek() is dcm
+ assert queue.get() is dcm
+ assert not queue.is_data_enabled()
+ assert queue.size_data() == 1
+
+ @pytest.mark.timeout(2)
+ def test_channel_registered_before_disable_is_disabled_and_reenabled(
+ self, queue, data_channel
+ ):
+ # baseline: the pre-existing behavior for eagerly-registered channels
+ data = self.data_element(data_channel)
+ queue.put(data)
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ assert not queue.is_data_enabled()
+ assert queue._queue.peek() is None
+ assert queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ assert queue.is_data_enabled()
+ assert queue.get() is data
+
+ @pytest.mark.timeout(2)
+ def test_channel_registered_while_enabled_behaves_normally(
+ self, queue, second_data_channel
+ ):
+ data = self.data_element(second_data_channel)
+ queue.put(data)
+ assert queue.is_data_enabled()
+ assert queue._queue.peek() is data
+ assert queue.get() is data
+ assert queue.is_empty()
+
+ @pytest.mark.timeout(10)
+ def test_concurrent_first_time_puts_while_toggling_disable(self, queue):
+ # concurrency smoke test: receiver threads register brand-new data
+ # channels while the DP thread toggles disable_data/enable_data;
+ # only the final state is asserted, deterministically.
+ n_threads = 8
+ elements_per_thread = 25
+ start_barrier = threading.Barrier(n_threads + 1)
+ errors = []
+
+ def producer(thread_index):
+ channel = ChannelIdentity(
+ ActorVirtualIdentity(f"upstream_{thread_index}"),
+ ActorVirtualIdentity("dummy_worker_id"),
+ False,
+ )
+ try:
+ start_barrier.wait()
+ for _ in range(elements_per_thread):
+ queue.put(self.data_element(channel))
+ except Exception as exc: # pragma: no cover - failure path
+ errors.append(exc)
+
+ threads = [
+ threading.Thread(target=producer, args=(i,)) for i in range(n_threads)
+ ]
+ for thread in threads:
+ thread.start()
+ start_barrier.wait()
+ for _ in range(5):
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ for thread in threads:
+ thread.join()
+ # one last full cycle after all puts settled: every channel must be
+ # disabled, then re-enabled with its count added back exactly once
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ assert not queue.is_data_enabled()
+ assert queue._queue.peek() is None
+ assert queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+
+ assert not errors
+ total = n_threads * elements_per_thread
+ assert queue.is_data_enabled()
+ assert queue.size_data() == total
+ # size() is the getable total_count: a mismatch with size_data()
+ # means an element was double-counted or lost by a toggle race
+ assert queue.size() == total
+ drained = 0
+ while queue._queue.peek() is not None:
+ queue.get()
+ drained += 1
+ assert drained == total
+ assert queue.is_empty()
+
+ @pytest.mark.timeout(30)
+ def test_concurrent_first_time_puts_racing_disable_enable_toggles(self):
+ # Receiver threads deliver first-ever messages on distinct new data
+ # channels while the DP-thread side toggles pause on and off. Only
+ # the final state is asserted (deterministic): with the queue left
+ # disabled, nothing is dequeuable; after the final enable_data every
+ # element is dequeuable exactly once, so total_count stayed exact.
+ threads, channels_per_thread, toggles = 4, 10, 10
+ for _ in range(5):
+ queue = InternalQueue()
+ errors = []
+ start = threading.Barrier(threads + 1)
+
+ def producer(thread_id):
+ try:
+ start.wait()
+ for i in range(channels_per_thread):
+ channel = ChannelIdentity(
+ ActorVirtualIdentity(f"upstream-{thread_id}-{i}"),
+ ActorVirtualIdentity("dummy_worker_id"),
+ False,
+ )
+ queue.put(self.data_element(channel))
+ except Exception as exc: # pragma: no cover - failure path
+ errors.append(exc)
+
+ producers = [
+ threading.Thread(target=producer, args=(t,)) for t in range(threads)
+ ]
+ for producer_thread in producers:
+ producer_thread.start()
+ start.wait()
+ for _ in range(toggles):
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ for producer_thread in producers:
+ producer_thread.join()
+
+ assert errors == []
+ total = threads * channels_per_thread
+ assert queue.size_data() == total
+ assert queue._queue.peek() is None
+ assert not queue.is_data_enabled()
+ assert queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ dequeued = 0
+ while queue._queue.peek() is not None:
+ queue.get()
+ dequeued += 1
+ assert dequeued == total
+
+ # Regression tests below: the per-category query methods iterate
+ # _queue_ids, which put() grows on a channel's first message. Iterating
+ # the live set while another thread grows it raises RuntimeError
+ # ("Set changed size during iteration"), killing the calling thread —
+ # e.g. the DP thread polling is_data_enabled() in the main loop — so the
+ # queries must iterate a snapshot of the set instead.
+
+ @pytest.mark.parametrize(
+ "query, expected",
+ [
+ ("is_control_empty", True),
+ ("is_data_empty", True),
+ ("size_control", 0),
+ ("size_data", 0),
+ ("in_mem_size", 0),
+ ("is_data_enabled", False),
+ ],
+ )
+ def test_queries_survive_a_channel_registration_mid_iteration(
+ self, query, expected
+ ):
+ # A key whose is_control access (evaluated inside the query's
Review Comment:
Applied in 92f4dc3e6202653043c8f51e5ed3aa738ef18aa6
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #6724:
URL: https://github.com/apache/texera/pull/6724#discussion_r3626619661
##########
amber/src/main/python/core/models/internal_queue.py:
##########
@@ -77,11 +76,19 @@ def get(self) -> T:
def put(self, item: T) -> None:
if isinstance(item, InternalQueueElement):
if item.tag not in self._queue_ids:
- self._queue.add_sub_queue(item.tag, 1 if item.tag.is_control else 2)
- self._queue_ids.add(item.tag)
- if isinstance(item, (DataElement, InternalMarker, ECMElement)):
- self._queue.put(item.tag, item)
- elif isinstance(item, DCMElement):
+ # registration must not interleave with disable_data/enable_data
+ with self._lock:
Review Comment:
can we avoid locking? the whole design is to use a lock free data structure.
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #6724:
URL: https://github.com/apache/texera/pull/6724#discussion_r3739000232
##########
amber/src/main/python/core/models/internal_queue.py:
##########
@@ -77,11 +76,19 @@ def get(self) -> T:
def put(self, item: T) -> None:
if isinstance(item, InternalQueueElement):
if item.tag not in self._queue_ids:
- self._queue.add_sub_queue(item.tag, 1 if item.tag.is_control else 2)
- self._queue_ids.add(item.tag)
- if isinstance(item, (DataElement, InternalMarker, ECMElement)):
- self._queue.put(item.tag, item)
- elif isinstance(item, DCMElement):
+ # registration must not interleave with disable_data/enable_data
+ with self._lock:
+ if item.tag not in self._queue_ids:
+ self._queue.add_sub_queue(
+ item.tag, 1 if item.tag.is_control else 2
+ )
+ # while data is disabled, a new data sub-queue must
+ # start disabled too (before its first element is
+ # enqueued), or it would leak data during the pause
+ if not item.tag.is_control and self._queue_state:
+ self._queue.disable(item.tag)
+ self._queue_ids.add(item.tag)
Review Comment:
Only half of `_queue_ids`'s accessors take the new guard. `is_control_empty`, `is_data_empty`, `size_data`, `in_mem_size` and `is_data_enabled` still iterate it unlocked.
They do race this `add`: `main_loop.py:171` calls `is_data_enabled()` on the main-loop thread while a Flight thread runs `put`. CPython then raises `RuntimeError: Set changed size during iteration` (reproduced), killing the main-loop thread while the heartbeat survives — the same silent hang this PR fixes.
Pre-existing, so not a blocker; closing it needs no lock, just `tuple(self._queue_ids)` in those five methods.
##########
amber/src/main/python/core/models/internal_queue.py:
##########
@@ -77,11 +76,19 @@ def get(self) -> T:
def put(self, item: T) -> None:
if isinstance(item, InternalQueueElement):
if item.tag not in self._queue_ids:
- self._queue.add_sub_queue(item.tag, 1 if item.tag.is_control else 2)
- self._queue_ids.add(item.tag)
- if isinstance(item, (DataElement, InternalMarker, ECMElement)):
- self._queue.put(item.tag, item)
- elif isinstance(item, DCMElement):
+ # registration must not interleave with disable_data/enable_data
+ with self._lock:
+ if item.tag not in self._queue_ids:
+ self._queue.add_sub_queue(
+ item.tag, 1 if item.tag.is_control else 2
+ )
+ # while data is disabled, a new data sub-queue must
+ # start disabled too (before its first element is
+ # enqueued), or it would leak data during the pause
Review Comment:
The guard reads `_queue_state`, which `disable_data` also fills for `DISABLE_BY_BACKPRESSURE` (backpressure_handler.py:43), so this branch fires outside pauses too.
```suggestion
# enqueued), or it would leak data during pause/backpressure
```
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #6724:
URL: https://github.com/apache/texera/pull/6724#discussion_r3754448723
##########
amber/src/main/python/core/models/internal_queue.py:
##########
@@ -149,13 +158,13 @@ def disable_data(self, disable_type: DisableType) -> None:
def in_mem_size(self) -> int:
return sum(
self._queue.in_mem_size(queue_id)
- for queue_id in self._queue_ids
+ for queue_id in tuple(self._queue_ids)
Review Comment:
Six copies of the snapshot now, and the comment explaining why it has to be one sits only above `is_control_empty`, 55 lines up. The change itself is right — this is about the next edit: nothing stops a seventh query over `_queue_ids` from iterating it directly and reintroducing the `RuntimeError` you just closed. Extracting `_data_queue_ids()` / `_control_queue_ids()` would put the snapshot in the API instead of leaving it a convention each method has to remember. Optional.
##########
amber/src/test/python/core/models/test_internal_queue.py:
##########
@@ -364,3 +365,297 @@ def test_it_can_disable_and_enable_a_single_data_channel(
queue.enable(data_channel)
assert queue.get() is blocked
assert queue.is_empty()
+
+ # Regression tests below: data channels whose sub-queue is created lazily
+ # (on the channel's first put) AFTER disable_data has been called must
+ # come up disabled — a paused or backpressured worker must not be able to
+ # dequeue data from them, and is_data_enabled() must not flip back to
+ # True just because a new channel delivered its first message.
+
+ def test_channel_registered_after_disable_comes_up_disabled(
+ self, queue, data_channel
+ ):
+ # the main regression: disable first, then the channel's FIRST put
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ queue.put(self.data_element(data_channel))
+ assert not queue.is_data_enabled()
+ # the element stays queued but must not be dequeuable
+ assert queue.size_data() == 1
+ assert queue._queue.peek() is None
+
+ @pytest.mark.timeout(2)
+ def test_enable_data_releases_a_channel_registered_mid_disable(
+ self, queue, data_channel
+ ):
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ data = self.data_element(data_channel)
+ queue.put(data)
+ assert queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ assert queue.is_data_enabled()
+ assert queue._queue.peek() is data
+ assert queue.get() is data
+ assert queue.is_empty()
+
+ @pytest.mark.timeout(2)
+ def test_channel_registered_under_stacked_disables_stays_disabled(
+ self, queue, data_channel
+ ):
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_BACKPRESSURE)
+ data = self.data_element(data_channel)
+ queue.put(data)
+ # releasing only one of the two reasons must not open the channel
+ assert not queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ assert not queue.is_data_enabled()
+ assert queue._queue.peek() is None
+ # releasing the remaining reason makes the element dequeuable
+ assert queue.enable_data(InternalQueue.DisableType.DISABLE_BY_BACKPRESSURE)
+ assert queue.is_data_enabled()
+ assert queue.get() is data
+
+ @pytest.mark.timeout(2)
+ def test_control_channel_registered_mid_disable_is_never_blocked(
+ self, queue, control_channel, data_channel
+ ):
+ # register a data channel first so is_data_enabled() is meaningful
+ queue.put(self.data_element(data_channel))
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ # the control channel's FIRST put happens while data is disabled
+ dcm = self.dcm_element(control_channel)
+ queue.put(dcm)
+ # control must flow immediately, and data must stay disabled
+ assert queue._queue.peek() is dcm
+ assert queue.get() is dcm
+ assert not queue.is_data_enabled()
+ assert queue.size_data() == 1
+
+ @pytest.mark.timeout(2)
+ def test_channel_registered_before_disable_is_disabled_and_reenabled(
+ self, queue, data_channel
+ ):
+ # baseline: the pre-existing behavior for eagerly-registered channels
+ data = self.data_element(data_channel)
+ queue.put(data)
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ assert not queue.is_data_enabled()
+ assert queue._queue.peek() is None
+ assert queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ assert queue.is_data_enabled()
+ assert queue.get() is data
+
+ @pytest.mark.timeout(2)
+ def test_channel_registered_while_enabled_behaves_normally(
+ self, queue, second_data_channel
+ ):
+ data = self.data_element(second_data_channel)
+ queue.put(data)
+ assert queue.is_data_enabled()
+ assert queue._queue.peek() is data
+ assert queue.get() is data
+ assert queue.is_empty()
+
+ @pytest.mark.timeout(10)
+ def test_concurrent_first_time_puts_while_toggling_disable(self, queue):
+ # concurrency smoke test: receiver threads register brand-new data
+ # channels while the DP thread toggles disable_data/enable_data;
+ # only the final state is asserted, deterministically.
+ n_threads = 8
+ elements_per_thread = 25
+ start_barrier = threading.Barrier(n_threads + 1)
+ errors = []
+
+ def producer(thread_index):
+ channel = ChannelIdentity(
+ ActorVirtualIdentity(f"upstream_{thread_index}"),
+ ActorVirtualIdentity("dummy_worker_id"),
+ False,
+ )
+ try:
+ start_barrier.wait()
+ for _ in range(elements_per_thread):
+ queue.put(self.data_element(channel))
+ except Exception as exc: # pragma: no cover - failure path
+ errors.append(exc)
+
+ threads = [
+ threading.Thread(target=producer, args=(i,)) for i in range(n_threads)
+ ]
+ for thread in threads:
+ thread.start()
+ start_barrier.wait()
+ for _ in range(5):
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ for thread in threads:
+ thread.join()
+ # one last full cycle after all puts settled: every channel must be
+ # disabled, then re-enabled with its count added back exactly once
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ assert not queue.is_data_enabled()
+ assert queue._queue.peek() is None
+ assert queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+
+ assert not errors
+ total = n_threads * elements_per_thread
+ assert queue.is_data_enabled()
+ assert queue.size_data() == total
+ # size() is the getable total_count: a mismatch with size_data()
+ # means an element was double-counted or lost by a toggle race
+ assert queue.size() == total
+ drained = 0
+ while queue._queue.peek() is not None:
+ queue.get()
+ drained += 1
+ assert drained == total
+ assert queue.is_empty()
+
+ @pytest.mark.timeout(30)
+ def test_concurrent_first_time_puts_racing_disable_enable_toggles(self):
+ # Receiver threads deliver first-ever messages on distinct new data
+ # channels while the DP-thread side toggles pause on and off. Only
+ # the final state is asserted (deterministic): with the queue left
+ # disabled, nothing is dequeuable; after the final enable_data every
+ # element is dequeuable exactly once, so total_count stayed exact.
+ threads, channels_per_thread, toggles = 4, 10, 10
+ for _ in range(5):
+ queue = InternalQueue()
+ errors = []
+ start = threading.Barrier(threads + 1)
+
+ def producer(thread_id):
+ try:
+ start.wait()
+ for i in range(channels_per_thread):
+ channel = ChannelIdentity(
+ ActorVirtualIdentity(f"upstream-{thread_id}-{i}"),
+ ActorVirtualIdentity("dummy_worker_id"),
+ False,
+ )
+ queue.put(self.data_element(channel))
+ except Exception as exc: # pragma: no cover - failure path
+ errors.append(exc)
+
+ producers = [
+ threading.Thread(target=producer, args=(t,)) for t in range(threads)
+ ]
+ for producer_thread in producers:
+ producer_thread.start()
+ start.wait()
+ for _ in range(toggles):
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ for producer_thread in producers:
+ producer_thread.join()
+
+ assert errors == []
+ total = threads * channels_per_thread
+ assert queue.size_data() == total
+ assert queue._queue.peek() is None
+ assert not queue.is_data_enabled()
+ assert queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ dequeued = 0
+ while queue._queue.peek() is not None:
+ queue.get()
+ dequeued += 1
+ assert dequeued == total
+
+ # Regression tests below: the per-category query methods iterate
+ # _queue_ids, which put() grows on a channel's first message. Iterating
+ # the live set while another thread grows it raises RuntimeError
+ # ("Set changed size during iteration"), killing the calling thread —
+ # e.g. the DP thread polling is_data_enabled() in the main loop — so the
+ # queries must iterate a snapshot of the set instead.
+
+ @pytest.mark.parametrize(
+ "query, expected",
+ [
+ ("is_control_empty", True),
+ ("is_data_empty", True),
+ ("size_control", 0),
+ ("size_data", 0),
+ ("in_mem_size", 0),
+ ("is_data_enabled", False),
+ ],
+ )
+ def test_queries_survive_a_channel_registration_mid_iteration(
+ self, query, expected
+ ):
+ # A key whose is_control access (evaluated inside the query's
Review Comment:
`A key whose is_control access ... delivers ...` leaves "A key" without a predicate, so it reads as a claim about the key rather than as a description of the setup below it.
```suggestion
# Registers a key whose is_control access (evaluated inside the query's
```
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on code in PR #6724:
URL: https://github.com/apache/texera/pull/6724#discussion_r3764810946
##########
amber/src/main/python/core/models/internal_queue.py:
##########
@@ -77,11 +76,19 @@ def get(self) -> T:
def put(self, item: T) -> None:
if isinstance(item, InternalQueueElement):
if item.tag not in self._queue_ids:
- self._queue.add_sub_queue(item.tag, 1 if item.tag.is_control else 2)
- self._queue_ids.add(item.tag)
- if isinstance(item, (DataElement, InternalMarker, ECMElement)):
- self._queue.put(item.tag, item)
- elif isinstance(item, DCMElement):
+ # registration must not interleave with disable_data/enable_data
+ with self._lock:
+ if item.tag not in self._queue_ids:
+ self._queue.add_sub_queue(
+ item.tag, 1 if item.tag.is_control else 2
+ )
+ # while data is disabled, a new data sub-queue must
+ # start disabled too (before its first element is
+ # enqueued), or it would leak data during pause/backpressure
+ if not item.tag.is_control and self._queue_state:
Review Comment:
ECMs ride data channels: `network_receiver.py:110` tags them with the data channel, and `_send_ecm_to_data_channels` sends only to `not is_control`. So this gate makes an ECM that is a channel's first message undeliverable rather than delayed — `LinkedBlockingMultiQueue` serves only sub-queues where `child.enabled` (`linked_blocking_multi_queue.py:223`). A paused worker's reconfiguration command then never arrives and never acks, and the coordinator's 30s `reconfigureWorkflow` await expires.
You were right and my round-2 CI read was wrong — I retract it. The Iceberg `CatalogCommitConflicts` lines are WARN retries. The failing suite is `ReconfigurationIntegrationSpec`, 3 tests on both runners, while main's last 10 runs of this workflow are green.
Of your two options I'd take the dequeue-side one. Register enabled as on main, then refuse to hand out a `DataElement` while `_queue_state` is non-empty, disabling that channel and stashing the element there. ECM delivery stays identical to main, so reconfiguration is untouched. Confirmed too: `pause_manager.py:70-79` does re-enable `ECM_PAUSE` channels before it checks `_global_pauses`.
##########
amber/src/test/python/core/models/test_internal_queue.py:
##########
@@ -364,3 +365,297 @@ def test_it_can_disable_and_enable_a_single_data_channel(
queue.enable(data_channel)
assert queue.get() is blocked
assert queue.is_empty()
+
+ # Regression tests below: data channels whose sub-queue is created lazily
+ # (on the channel's first put) AFTER disable_data has been called must
+ # come up disabled — a paused or backpressured worker must not be able to
+ # dequeue data from them, and is_data_enabled() must not flip back to
+ # True just because a new channel delivered its first message.
+
+ def test_channel_registered_after_disable_comes_up_disabled(
+ self, queue, data_channel
+ ):
+ # the main regression: disable first, then the channel's FIRST put
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ queue.put(self.data_element(data_channel))
+ assert not queue.is_data_enabled()
+ # the element stays queued but must not be dequeuable
+ assert queue.size_data() == 1
+ assert queue._queue.peek() is None
+
+ @pytest.mark.timeout(2)
+ def test_enable_data_releases_a_channel_registered_mid_disable(
+ self, queue, data_channel
+ ):
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ data = self.data_element(data_channel)
+ queue.put(data)
+ assert queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ assert queue.is_data_enabled()
+ assert queue._queue.peek() is data
+ assert queue.get() is data
+ assert queue.is_empty()
+
+ @pytest.mark.timeout(2)
+ def test_channel_registered_under_stacked_disables_stays_disabled(
+ self, queue, data_channel
+ ):
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ queue.disable_data(InternalQueue.DisableType.DISABLE_BY_BACKPRESSURE)
+ data = self.data_element(data_channel)
+ queue.put(data)
+ # releasing only one of the two reasons must not open the channel
+ assert not queue.enable_data(InternalQueue.DisableType.DISABLE_BY_PAUSE)
+ assert not queue.is_data_enabled()
+ assert queue._queue.peek() is None
+ # releasing the remaining reason makes the element dequeuable
+ assert queue.enable_data(InternalQueue.DisableType.DISABLE_BY_BACKPRESSURE)
+ assert queue.is_data_enabled()
+ assert queue.get() is data
+
+ @pytest.mark.timeout(2)
+ def test_control_channel_registered_mid_disable_is_never_blocked(
Review Comment:
This is the neighbouring case that would have caught it. The matrix enumerates registration by *channel* kind — a data channel first carrying a `DataElement`, a control channel mid-pause — but never by *element* kind. So a data channel whose first element is an `ECMElement` goes untested, and that is the cell CI fails on. The `ecm_element` helper is already there at line 89.
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "Yicong-Huang (via GitHub)" <gi...@apache.org>.
Yicong-Huang commented on PR #6724:
URL: https://github.com/apache/texera/pull/6724#issuecomment-5209880177
Thanks, I will check tonight
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "eugenegujing (via GitHub)" <gi...@apache.org>.
eugenegujing commented on code in PR #6724:
URL: https://github.com/apache/texera/pull/6724#discussion_r3754054635
##########
amber/src/main/python/core/models/internal_queue.py:
##########
@@ -77,11 +76,19 @@ def get(self) -> T:
def put(self, item: T) -> None:
if isinstance(item, InternalQueueElement):
if item.tag not in self._queue_ids:
- self._queue.add_sub_queue(item.tag, 1 if item.tag.is_control else 2)
- self._queue_ids.add(item.tag)
- if isinstance(item, (DataElement, InternalMarker, ECMElement)):
- self._queue.put(item.tag, item)
- elif isinstance(item, DCMElement):
+ # registration must not interleave with disable_data/enable_data
+ with self._lock:
+ if item.tag not in self._queue_ids:
+ self._queue.add_sub_queue(
+ item.tag, 1 if item.tag.is_control else 2
+ )
+ # while data is disabled, a new data sub-queue must
+ # start disabled too (before its first element is
+ # enqueued), or it would leak data during the pause
+ if not item.tag.is_control and self._queue_state:
+ self._queue.disable(item.tag)
+ self._queue_ids.add(item.tag)
Review Comment:
Fixed in 9dbbec219ea59a650aed63da74507aa4615c0ded. Function size_control has the identical unlocked iteration, so I included it as well
##########
amber/src/main/python/core/models/internal_queue.py:
##########
@@ -77,11 +76,19 @@ def get(self) -> T:
def put(self, item: T) -> None:
if isinstance(item, InternalQueueElement):
if item.tag not in self._queue_ids:
- self._queue.add_sub_queue(item.tag, 1 if item.tag.is_control else 2)
- self._queue_ids.add(item.tag)
- if isinstance(item, (DataElement, InternalMarker, ECMElement)):
- self._queue.put(item.tag, item)
- elif isinstance(item, DCMElement):
+ # registration must not interleave with disable_data/enable_data
+ with self._lock:
+ if item.tag not in self._queue_ids:
+ self._queue.add_sub_queue(
+ item.tag, 1 if item.tag.is_control else 2
+ )
+ # while data is disabled, a new data sub-queue must
+ # start disabled too (before its first element is
+ # enqueued), or it would leak data during the pause
Review Comment:
Applied in 9dbbec219ea59a650aed63da74507aa4615c0ded.
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #6724:
URL: https://github.com/apache/texera/pull/6724#issuecomment-5039518679
<!-- texera-reviewer-suggestion -->
### Automated Reviewer Suggestions
Based on the `git blame` history of the changed files, we recommend the following reviewers:
- **Contributors with relevant context:** `@Yicong-Huang`
You can notify them by mentioning `@Yicong-Huang` in a comment.
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "codecov-commenter (via GitHub)" <gi...@apache.org>.
codecov-commenter commented on PR #6724:
URL: https://github.com/apache/texera/pull/6724#issuecomment-5039965466
## [Codecov](https://app.codecov.io/gh/apache/texera/pull/6724?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:white_check_mark: All modified and coverable lines are covered by tests.
:white_check_mark: Project coverage is 74.53%. Comparing base ([`42027e8`](https://app.codecov.io/gh/apache/texera/commit/42027e8c38d248a60cab32871887bc754ef311b5?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`c918d2c`](https://app.codecov.io/gh/apache/texera/commit/c918d2cc67c3aee57fc66c157ab8f7ab0707afc5?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
:warning: Report is 23 commits behind head on main.
:white_check_mark: All tests successful. No failed tests found.
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## main #6724 +/- ##
============================================
+ Coverage 74.46% 74.53% +0.06%
Complexity 3441 3441
============================================
Files 1157 1157
Lines 45621 45622 +1
Branches 5031 5031
============================================
+ Hits 33972 34003 +31
+ Misses 9994 9964 -30
Partials 1655 1655
```
| [Flag](https://app.codecov.io/gh/apache/texera/pull/6724/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Δ | | *Carryforward flag |
|---|---|---|---|
| [access-control-service](https://app.codecov.io/gh/apache/texera/pull/6724/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `70.00% <ø> (ø)` | | Carriedforward from [79f4f06](https://app.codecov.io/gh/apache/texera/commit/79f4f06e3999b91d5fba0ddc3e674f7d3ad4bdb4?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [agent-service](https://app.codecov.io/gh/apache/texera/pull/6724/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `76.76% <ø> (ø)` | | Carriedforward from [79f4f06](https://app.codecov.io/gh/apache/texera/commit/79f4f06e3999b91d5fba0ddc3e674f7d3ad4bdb4?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [amber](https://app.codecov.io/gh/apache/texera/pull/6724/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `66.84% <ø> (ø)` | | Carriedforward from [79f4f06](https://app.codecov.io/gh/apache/texera/commit/79f4f06e3999b91d5fba0ddc3e674f7d3ad4bdb4?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [computing-unit-managing-service](https://app.codecov.io/gh/apache/texera/pull/6724/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `17.72% <ø> (ø)` | | Carriedforward from [79f4f06](https://app.codecov.io/gh/apache/texera/commit/79f4f06e3999b91d5fba0ddc3e674f7d3ad4bdb4?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [config-service](https://app.codecov.io/gh/apache/texera/pull/6724/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `66.66% <ø> (ø)` | | Carriedforward from [79f4f06](https://app.codecov.io/gh/apache/texera/commit/79f4f06e3999b91d5fba0ddc3e674f7d3ad4bdb4?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [file-service](https://app.codecov.io/gh/apache/texera/pull/6724/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `66.80% <ø> (ø)` | | Carriedforward from [79f4f06](https://app.codecov.io/gh/apache/texera/commit/79f4f06e3999b91d5fba0ddc3e674f7d3ad4bdb4?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [frontend](https://app.codecov.io/gh/apache/texera/pull/6724/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `78.18% <ø> (ø)` | | Carriedforward from [79f4f06](https://app.codecov.io/gh/apache/texera/commit/79f4f06e3999b91d5fba0ddc3e674f7d3ad4bdb4?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [notebook-migration-service](https://app.codecov.io/gh/apache/texera/pull/6724/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `78.94% <ø> (ø)` | | Carriedforward from [79f4f06](https://app.codecov.io/gh/apache/texera/commit/79f4f06e3999b91d5fba0ddc3e674f7d3ad4bdb4?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [pyamber](https://app.codecov.io/gh/apache/texera/pull/6724/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `92.47% <100.00%> (+0.68%)` | :arrow_up: | |
| [workflow-compiling-service](https://app.codecov.io/gh/apache/texera/pull/6724/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `55.14% <ø> (ø)` | | Carriedforward from [79f4f06](https://app.codecov.io/gh/apache/texera/commit/79f4f06e3999b91d5fba0ddc3e674f7d3ad4bdb4?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
*This pull request uses carry forward flags. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) to find out more.
</details>
[:umbrella: View full report in Codecov by Harness](https://app.codecov.io/gh/apache/texera/pull/6724?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] fix(pyamber): disable data sub-queues registered after disable_data [texera]
Posted by "eugenegujing (via GitHub)" <gi...@apache.org>.
eugenegujing commented on PR #6724:
URL: https://github.com/apache/texera/pull/6724#issuecomment-5402891420
@Yicong-Huang Do I need to change anything else to merge this?
--
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: notifications-unsubscribe@texera.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org