Skip to content

Fix - remove BIG Sync handles on BigSync.terminate to prevent resync failures - #994

Open
markusjellitsch wants to merge 4 commits into
google:mainfrom
markusjellitsch:fix/big-terminate
Open

markusjellitsch wants to merge 4 commits into
google:mainfrom
markusjellitsch:fix/big-terminate

Conversation

@markusjellitsch

@markusjellitsch markusjellitsch commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

The Issue

BigSync.terminate() sent the terminate command and set the sync
state, but never removed the sync's handle from the device's big_syncs dict nor its BIS link
handles from bis_links. Only the on_big_sync_lost callback did that cleanup.
Because the stale entries were never removed,
re-syncing the same BIG repeatedly leaked entries until the 240th re-sync (0x00-0xF0 valid range) failed.

How to reproduce

The following test with transmitter (creating a big) and receiver (syncing to the big, then terminating) demonstrates the issue:

 File "/home/maxl/dev-projects/rootcanal/examples/python/broadcast_stress_test.py", line 406, in main
    raise RuntimeError("Stress test failures:\n" + "\n".join(failures))
RuntimeError: Stress test failures:
session 240 (unencrypted): RuntimeError("session 240 failed during create BIG sync: OutOfResourcesError('All valid BIG handles already in use')")

The Fix

This PR fixes the above described issue by adding a helper method _remove_big_sync that pops the big/bis handles once the BIG sync was terminated. this method is also used in on_big_sync_lost().
In addition , test_big_sync_and_terminate_255_times was added,, which creates and terminates a BIG sync 255
times and asserts no stale entries accumulate across the full handle wrap-around.

@zxzxwu zxzxwu left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix! Left a couple of small comments.

Comment thread bumble/device.py Outdated
Comment thread tests/device_test.py Outdated

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants