Skip to content

dynamic-window: fix reusing window segments when client exits early#937

Merged
bazsi merged 6 commits intoaxoflow:mainfrom
MrAnno:dynamic-window-fc-disconnect-rebalance
Feb 4, 2026
Merged

dynamic-window: fix reusing window segments when client exits early#937
bazsi merged 6 commits intoaxoflow:mainfrom
MrAnno:dynamic-window-fc-disconnect-rebalance

Conversation

@MrAnno
Copy link
Contributor

@MrAnno MrAnno commented Jan 30, 2026

There is a mechanism that releases the dynamic window for dead sources,
but it works on an "all-or-nothing" basis: the dynamic window is only
released when the source refcount reaches zero (when all messages have
been acked).

This is insufficient, because dead sources can retain unused dynamic window
capacity for a long time if there is at least one in-flight message in
the system.

MrAnno added a commit to MrAnno/axosyslog that referenced this pull request Jan 30, 2026
Signed-off-by: László Várady <[email protected]>
@MrAnno MrAnno force-pushed the dynamic-window-fc-disconnect-rebalance branch from 65987be to 17c6bb4 Compare January 30, 2026 11:52
@MrAnno
Copy link
Contributor Author

MrAnno commented Jan 30, 2026

@mitzkia FYI

MrAnno added a commit to MrAnno/axosyslog that referenced this pull request Jan 30, 2026
Signed-off-by: László Várady <[email protected]>
@MrAnno MrAnno force-pushed the dynamic-window-fc-disconnect-rebalance branch from 17c6bb4 to 1465476 Compare January 30, 2026 16:34
@mitzkia
Copy link
Contributor

mitzkia commented Jan 30, 2026

Thanks for the fixes.
Tested locally with manual and light testcases.
I can not reproduce original issues with this branch. Verified from testing side.

bazsi
bazsi previously approved these changes Jan 31, 2026
Copy link
Member

@bazsi bazsi left a comment

Choose a reason for hiding this comment

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

Approved. Great to see the additional notes/asserts on proper threading constraints.

Just one nit: maybe we could check if we still have an outstanding dynamic window request at log_source_free(), because we most probably returned the dynamic window when the connection closes (if the empty window allowed that).

With that the latency associated with main_loop_call() will not affect the destination, unless really necessary.

@MrAnno
Copy link
Contributor Author

MrAnno commented Jan 31, 2026

Thanks! I will check what I can do about this. Dynamic-pool-related stuffs are not thread safe, and there is a race between the destination thread (acks, free) and main loop actions (realloc, deinit)

@bazsi
Copy link
Member

bazsi commented Feb 2, 2026

Thanks! I will check what I can do about this. Dynamic-pool-related stuffs are not thread safe, and there is a race between the destination thread (acks, free) and main loop actions (realloc, deinit)

I would assume that a check against 0 should be safe. If it was 0 because of the early release at deinit time, it won't increase back again. But if it's too complex, don't bother.

There is a mechanism that releases the dynamic window for dead sources,
but it works on an "all-or-nothing" basis: the dynamic window is only
released when the source refcount reaches zero (when all messages have
been acked).

This is insufficient, because dead sources can retain unused dynamic window
capacity for a long time if there is at least one in-flight message in
the system.

Signed-off-by: László Várady <[email protected]>
Signed-off-by: László Várady <[email protected]>
@MrAnno MrAnno force-pushed the dynamic-window-fc-disconnect-rebalance branch from 1465476 to 3d9db43 Compare February 4, 2026 11:42
@MrAnno
Copy link
Contributor Author

MrAnno commented Feb 4, 2026

full_window_size is not atomic, so I can't do that 0-check in a non-main thread.

I added a refactor though, but I didn't add the 0-check unless you want me to make this atomic.

@bazsi
Copy link
Member

bazsi commented Feb 4, 2026

full_window_size is not atomic, so I can't do that 0-check in a non-main thread.

I added a refactor though, but I didn't add the 0-check unless you want me to make this atomic.

it's fine this way, approving...

@bazsi bazsi merged commit c1342b6 into axoflow:main Feb 4, 2026
22 checks passed
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.

3 participants