fix: refresh subscription history snapshots on MySQL and MariaDB - #888
Merged
x0sina merged 1 commit intoSep 9, 2026
Merged
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
11 tasks
x0sina
added a commit
that referenced
this pull request
Sep 12, 2026
) * feat(user): enhance user inbound tag retrieval and subscription update handling - Improved the `inbounds` method in the User model to efficiently gather inbound tags from enabled groups. - Updated user subscription update logic to queue updates for background processing, enhancing performance. - Refactored user status change notifications to streamline the process and ensure accurate user state management. - Introduced caching for usage coefficients to optimize node user statistics collection. - Enhanced subscription generation with caching mechanisms for improved performance. * fix: discard stale subscription updates and align FinalMask test (#886) * fix: read flushed subscription updates from a fresh snapshot (#888) * perf(nats): optimize user sync and bound queue processing (#892) Reuse live key indexes, replay snapshots in bounded batches, and clear queues from cached keys and recent revisions. Bound bulk operations, safely compact old deletion markers, and preserve claim recovery across delayed notifications and reconnects. Add concurrency, recovery, compaction, and idle-traffic regression coverage. * test(hosts): match FinalMask noise fixture to Xray array packet Keep the #889 payload ([1, 2, 255], no rand) so it agrees with the merged assertions after pref-boost picked up both that change and the older #886 sample. * fix(cleanup): add timeout handling for node-sync key compaction and improve logging - Introduced asyncio timeout for the compaction process to prevent indefinite blocking. - Added a warning log for timeout occurrences to ensure visibility of potential issues. - Updated Cache-Control header in subscription responses to "no-store" for better caching behavior. - Refactored subscription update buffer to use a drain lock for concurrent flush operations, improving reliability and performance. --------- Co-authored-by: DrSaeedHub <122322581+DrSaeedHub@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
After a subscription request queues an update, MySQL and MariaDB subscription history endpoints can return an empty list even though the buffer has been flushed successfully. Authorization/user lookup has already established the request transaction's REPEATABLE READ snapshot, so it cannot see the flush committed by another session.
Read subscription history, agent counts, and chart statistics through a fresh session after flushing. This preserves the caller's transaction and pending changes, keeps pagination/count queries together, and also handles updates flushed before the read helper is called.
Follow-up to #886; fixes the two remaining failures in https://github.com/PasarGuard/panel/actions/runs/34364940294.
Type of change
Checklist
Testing
alembic checkpassed on MySQL and MariaDB.git diff --checkpassed.The six regression cases cover history, agent counts, and time-bucketed stats with pending and already-flushed updates. They also verify that the caller's pending changes remain uncommitted.
Screenshots
Not applicable.
Notes for reviewers
Targets
pref-boost. No changes to the global isolation level, schema, API response shape, or subscription write buffering. Subscription analytics use a separate database session for committed data; the request's original transaction remains untouched.