-
Notifications
You must be signed in to change notification settings - Fork 1k
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
enhance smoosh to cleanup search indexes when ddocs change #4718
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -123,6 +123,9 @@ handle_db_event(DbName, local_updated, St) -> | |
handle_db_event(DbName, updated, St) -> | ||
enqueue(DbName), | ||
{ok, St}; | ||
handle_db_event(DbName, ddoc_updated, St) -> | ||
enqueue({?INDEX_CLEANUP, mem3:dbname(DbName)}), | ||
{ok, St}; | ||
handle_db_event(DbName, {index_commit, IdxName}, St) -> | ||
enqueue({DbName, IdxName}), | ||
{ok, St}; | ||
|
@@ -342,6 +345,8 @@ find_channel(#state{} = State, [Channel | Rest], Object) -> | |
find_channel(State, Rest, Object) | ||
end. | ||
|
||
stale_enough({?INDEX_CLEANUP, _}) -> | ||
true; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ddoc_updated events are rare, unlike database updates, so choosing not to action one would leave unreferenced indexes on disk for a long time, perhaps indefinitely. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're also triggering these during every shard compaction attempt, proportionally to the number of shards (so we'd roughly trigger once for each clustered db). That should be a low enough rate, it may be worth checking what it looks like a busy cluster. |
||
stale_enough(Object) -> | ||
LastUpdatedSec = last_updated(Object), | ||
Staleness = erlang:monotonic_time(second) - LastUpdatedSec, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These shouldn't crash if either of those are not enabled? If there is a chance we could wrap them in a
try ... catch
maybe?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clouseau_rpc:cleanup
is agen_server:cast
so that's fine even if the target node doesn't exist.all the
nouveau_api
functions have asend_if_enabled
check and return{error, nouveau_not_enabled}
when it's not enabled.in either case I ignore the function result, but perhaps I should check that it's one of the two expected results?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. The only worry was that we would throw an exception and prevent other indexes from getting cleaned up. Thanks for double-checking, I think it's fine as is, then.