Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(event cache): add a way to clear all chunks, clear a room's chunks + FFI feature flag #4396

Merged
merged 4 commits into from
Dec 10, 2024

Conversation

bnjbvr
Copy link
Member

@bnjbvr bnjbvr commented Dec 9, 2024

This adds a way to:

  • clear all the rooms' linked chunk, all at once: this will be useful when disabling the feature flag
  • clear a single room's event cache persistent storage: this should be useful for testing purposes, and in case storage is completely borked
  • enable a feature flag on an FFI ClientBuilder to enable or disable persistent storage. Note: after persistent storage has been enabled, if the embedder decides to disable it, they must explicitly set it to false the next time; otherwise the on-disk storage isn't cleared.

The last item isn't very satisfying, but I don't see how to do it otherwise without more involved refactorings. The way persistent storage works right now, is by checking the presence of an event cache store reference in the RoomEventCacheState data structure. This is filled at most once, and only once, and never cleared (it's not even clearable). As such, a restart is required for disabling the persistent storage; after restarting is the right time to clear a previous on-disk persisted storage. If we do it sooner than that, then the live RoomEventCacheState may keep on trying to store new updates…

Part of #3280.

@bnjbvr bnjbvr requested a review from a team as a code owner December 9, 2024 15:52
@bnjbvr bnjbvr requested review from Hywan and removed request for a team December 9, 2024 15:52
Copy link

codecov bot commented Dec 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 85.22%. Comparing base (72fcc50) to head (d6c8867).
Report is 30 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4396      +/-   ##
==========================================
+ Coverage   85.20%   85.22%   +0.01%     
==========================================
  Files         281      281              
  Lines       30963    30990      +27     
==========================================
+ Hits        26383    26410      +27     
  Misses       4580     4580              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@Hywan Hywan left a comment

Choose a reason for hiding this comment

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

Winter clean up.

@@ -624,6 +645,21 @@ impl ClientBuilder {

let sdk_client = inner_builder.build().await?;

if let Some(val) = builder.use_event_cache_persistent_storage {
if val {
// Enable the persistent storage \o/
Copy link
Member

Choose a reason for hiding this comment

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

\o/

…wkward

By default, the event cache store will be disabled. If disabled, it will
clean all the events in the cache store; most of the time this will do
nothing, since the store will not even be filled with any event data, so
it would be cheap to do. If some data was filled in the cache store
before, then it would be cleared after the cache store has been
disabled.

This makes a less awkward API than the previous one, where `None` and
`Some(false)` carried different semantics.
@bnjbvr bnjbvr force-pushed the bnjbvr/clear-all-chunks branch from 8b05176 to d6c8867 Compare December 10, 2024 10:47
@bnjbvr bnjbvr enabled auto-merge (rebase) December 10, 2024 10:49
@bnjbvr
Copy link
Member Author

bnjbvr commented Dec 10, 2024

As discussed in private, the last commit changes the semantics so that the feature flag is not optional, and always set to false. It makes it less awkward when used by consumers. (See commit message for details.)

@bnjbvr bnjbvr merged commit 32e2070 into main Dec 10, 2024
40 checks passed
@bnjbvr bnjbvr deleted the bnjbvr/clear-all-chunks branch December 10, 2024 11:05
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