Repository navigation
Conversation
|
Workflow [PR], commit [19d5eac] Summary: ✅
AI ReviewSummaryThis PR replaces the old two-tier access-change notifications with batched Findings
Final Verdict
|
There was a problem hiding this comment.
Pull request overview
This pull request simplifies access-change notifications by removing the separate “batch finished” notification tier and instead delivering access-entity changes in per-batch vectors to existing subscribeForChanges handlers (by-type and by-id). It updates the access caches to coalesce expensive recomputations once per drained notification batch, while preserving retry-on-next-send behavior after exceptions.
Changes:
- Replace per-entity callbacks +
subscribeForBatchFinishedwith batchedsubscribeForChangescallbacks that receivestd::vector<AccessChangesNotifier::Change>. - Update
RowPolicyCache,SettingsProfilesCache,QuotaCache, andRoleCacheto apply per-entity bookkeeping over the batch and run a single coalesced rebuild per batch. - Extend tests (gtest + integration) to validate batching semantics, retry-after-throw, and role-cache recomputation coalescing.
Reviewed changes
Copilot reviewed 16 out of 16 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/integration/test_access_cache_recompute_coalescing/test.py | Adds an integration test to assert role-cache recomputation is coalesced to ~1 per batch on reread. |
| src/Access/tests/gtest_access_changes_notifier.cpp | Updates/extends unit tests to validate batched delivery semantics, retry-after-throw, and by-id targeting. |
| src/Access/SettingsProfilesCache.h | Removes batch-subscription member and annotates internal mutators as mutex-required. |
| src/Access/SettingsProfilesCache.cpp | Switches settings profile updates to batched notifications and runs coalesced merge per batch. |
| src/Access/RowPolicyCache.h | Removes batch-subscription member and annotates internal mutators as mutex-required. |
| src/Access/RowPolicyCache.cpp | Switches row policy updates to batched notifications and runs coalesced filter mixing per batch. |
| src/Access/RoleCache.h | Refactors role cache to a single by-type subscription and introduces referenced-role tracking. |
| src/Access/RoleCache.cpp | Implements batched role-change handling and coalesced enabled-role recomputation. |
| src/Access/QuotaCache.h | Removes batch-subscription member and annotates internal mutators as mutex-required. |
| src/Access/QuotaCache.cpp | Switches quota updates to batched notifications and runs coalesced quota selection per batch. |
| src/Access/LDAPAccessStorage.cpp | Adapts role-change subscription to batched change vectors. |
| src/Access/ContextAccess.cpp | Adapts per-user subscriptions to the new batched by-id handler signature. |
| src/Access/AccessControl.h | Drops subscribeForBatchFinished from AccessControl and reuses notifier handler type. |
| src/Access/AccessControl.cpp | Removes subscribeForBatchFinished forwarding implementation. |
| src/Access/AccessChangesNotifier.h | Redefines handler API to deliver std::vector<Change> and removes batch-finished API. |
| src/Access/AccessChangesNotifier.cpp | Implements single-pass batch draining and delivery, grouped by type and by subscribed ids. |
| else | ||
| rowPolicyRemoved(change.id); | ||
| } | ||
| if (need_mix_filters) |
There was a problem hiding this comment.
Same here, do we need the flag? (and in all other places)
Or we can simply check for changes.empty()) ?
| else | ||
| roleRemoved(change.id); | ||
| } | ||
| if (need_collect_enabled_roles) |
There was a problem hiding this comment.
I guess here we need the flag indeed
| else | ||
| profileRemoved(change.id); | ||
| } | ||
| if (need_merge_settings_and_constraints) |
d7a3206 to
2a48b86
Compare
2a48b86 to
19d5eac
Compare
LLVM Coverage Report
Changed lines: Changed C/C++ lines covered: 283/294 (96.26%) · Uncovered code |
Rebuilding filters with many policies takes seconds under the mutex that every login takes, stalling logins. Snapshot under a brief lock, rebuild and publish atomically off-lock; sendNotifications keeps a single writer per enabled set. Refs: https://pastila.nl/?000a9f0d/098eb7d78de026b75c13a2b4e16daf0c#qHx0nBBrcjF0T5OXSsDnjQ==GCM v2: add concurrent row policy CREATE/DROP rebuild test v3: fix dangling string_view key in published filters v4: scope test row policies to a dedicated user instead of TO ALL v5: rebase on top of ClickHouse#108414 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Co-Authored-By: Claude Fable 5 <[email protected]>
Rebuilding filters with many policies takes seconds under the mutex that every login takes, stalling logins. Snapshot under a brief lock, rebuild and publish atomically off-lock; sendNotifications keeps a single writer per enabled set. Refs: https://pastila.nl/?000a9f0d/098eb7d78de026b75c13a2b4e16daf0c#qHx0nBBrcjF0T5OXSsDnjQ==GCM v2: add concurrent row policy CREATE/DROP rebuild test v3: fix dangling string_view key in published filters v4: scope test row policies to a dedicated user instead of TO ALL v5: rebase on top of ClickHouse#108414 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Co-Authored-By: Claude Fable 5 <[email protected]>
…ce two-tier notifications
Backport #108414 to 26.6: Simplify access-change notifications: replace two-tier notifications
|
@al13n321 are you sure we need this backport? this looks like just a refactoring, or maybe we need it to backport some patch on top? |
…anges-notifier-batched Simplify access-change notifications: replace two-tier notifications
Rebuilding filters with many policies takes seconds under the mutex that every login takes, stalling logins. Snapshot under a brief lock, rebuild and publish atomically off-lock; sendNotifications keeps a single writer per enabled set. Refs: https://pastila.nl/?000a9f0d/098eb7d78de026b75c13a2b4e16daf0c#qHx0nBBrcjF0T5OXSsDnjQ==GCM v2: add concurrent row policy CREATE/DROP rebuild test v3: fix dangling string_view key in published filters v4: scope test row policies to a dedicated user instead of TO ALL v5: rebase on top of ClickHouse#108414 Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]> Co-Authored-By: Claude Fable 5 <[email protected]>
|
(It was a dependency for another backport, but then that backport was conflict-resolved anyway.) |
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Simplify access-change notifications: replace two-tier notifications.
PRs #107672, #108124 fixed the issue with performance but introduced a complicated system of two-tier access-change notifications. Here I simplified that system back to one tier. So instead of two tiers
subscribeForChanges&subscribeForBatchFinishednow we have onlysubscribeForChangesagain.Performance is unchanged: one rebuild per batch, not one per changed entity. The throw-retry behavior is preserved: by-type handlers fire even on an empty batch, so a rebuild that threw is retried on the next
sendNotifications(including a no-diffSYSTEM RELOAD USERS).Version info
26.7.1.409(included in26.7and later)26.6.5.35