Skip to content

[fix][test] Fix flaky testLoadBalancerServiceUnitTableViewSyncer - #25427

Merged
merlimat merged 2 commits into
apache:masterfrom
merlimat:fix/flaky-testLoadBalancerServiceUnitTableViewSyncer
Mar 31, 2026
Merged

[fix][test] Fix flaky testLoadBalancerServiceUnitTableViewSyncer#25427
merlimat merged 2 commits into
apache:masterfrom
merlimat:fix/flaky-testLoadBalancerServiceUnitTableViewSyncer

Conversation

@merlimat

Copy link
Copy Markdown
Contributor

Motivation

Fix flaky test testLoadBalancerServiceUnitTableViewSyncer in ExtensibleLoadManagerImplTest.

Root Cause

The test calls brokerRegistry.unregister() to simulate a broker going offline, but in the test environment all brokers share the same MetadataStore. The ZK node deletion triggers an asynchronous notification that BrokerRegistryImpl.handleMetadataStoreNotification() interprets as a session-expiry event, causing it to auto-re-register the broker. This race makes the broker appear to never go offline.

Additionally, SLA namespace ownership is determined lazily via metadata cache lookups. After broker unregistration, the cached broker data must be invalidated before ownership can be reassigned. The test was making immediate assertions without waiting for this async propagation.

Modifications

  • Set registry state to Closed BEFORE deleting the ZK node to prevent the notification handler's session-expiry recovery from auto-re-registering the broker
  • Call cleanOwnerships() before unregistration (matching the production disableBroker() flow)
  • Delete the ZK node directly via metadata store instead of using unregister() which has a CAS check
  • Add Awaitility waits with .ignoreExceptions() for SLA ownership reassignment
  • Increase syncer activation/deactivation timeouts from 10s to 30s
  • Restore original lookup services in initializeState() to prevent state leakage between tests
  • Add null check for lookup in testUnloadClientReconnectionWithLookup finally block
  • Make maxParallelForks configurable via Gradle property

Documentation

  • doc-not-needed

Matching PR in forked repository

No response

@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Mar 28, 2026
@merlimat
merlimat force-pushed the fix/flaky-testLoadBalancerServiceUnitTableViewSyncer branch 2 times, most recently from 876d2df to 316ac80 Compare March 28, 2026 18:03
Root cause: The test calls brokerRegistry.unregister() to simulate a broker
going offline, but in the test environment all brokers share the same
MetadataStore. The ZK node deletion triggers an asynchronous notification
that BrokerRegistryImpl.handleMetadataStoreNotification() interprets as
a session-expiry, causing it to auto-re-register the broker. This race
makes the broker appear to never go offline.

Fix:
- Set registry state to Closed BEFORE deleting the ZK node to prevent
  the notification handler from auto-re-registering
- Call cleanOwnerships() before unregistration (matching production
  disableBroker() flow)
- Delete the ZK node directly via metadata store instead of using
  unregister() which has a CAS check
- Add Awaitility waits with ignoreExceptions() for SLA ownership
  reassignment (async metadata cache invalidation)
- Increase syncer activation/deactivation timeouts from 10s to 30s
- Restore original lookup services in initializeState() to prevent
  state leakage between tests
- Add null check for lookup in testUnloadClientReconnectionWithLookup
- Make maxParallelForks configurable in build.gradle.kts
@merlimat
merlimat force-pushed the fix/flaky-testLoadBalancerServiceUnitTableViewSyncer branch from 316ac80 to b181daf Compare March 29, 2026 03:29
@merlimat
merlimat merged commit 0c285f4 into apache:master Mar 31, 2026
42 checks passed
@merlimat
merlimat deleted the fix/flaky-testLoadBalancerServiceUnitTableViewSyncer branch March 31, 2026 01:07
lhotari pushed a commit that referenced this pull request Apr 21, 2026
lhotari pushed a commit that referenced this pull request Apr 21, 2026
lhotari pushed a commit that referenced this pull request Apr 21, 2026
srinath-ctds pushed a commit to datastax/pulsar that referenced this pull request Apr 23, 2026
nodece pushed a commit to ascentstream/pulsar that referenced this pull request May 27, 2026
@lhotari lhotari added this to the 5.0.0-M1 milestone Jun 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants