mirror of
https://github.com/Zygo/bees.git
synced 2025-07-02 08:42:27 +02:00
FdCache: clear cache on every new transid / crawl cycle
The periodic cache age check was not protected by a lock, so multiple threads may decide to concurrently clear the cache. This led to duplicate log messages. Fix by moving the cache expiry trigger out of FdCache and into Roots, which knows when transids change and can perform cache clears at exactly the time they are most relevant, i.e. after something that was deleted becomes permanently so. This removes the last references to BEES_COMMIT_INTERVAL, so get rid of its definition too. Signed-off-by: Zygo Blaxell <bees@furryterror.org>
This commit is contained in:
@ -335,11 +335,22 @@ BeesRoots::crawl_thread()
|
||||
|
||||
// Monitor transid_max and wake up roots when it changes
|
||||
BEESNOTE("tracking transids");
|
||||
auto last_count = m_transid_re.count();
|
||||
while (true) {
|
||||
// Make sure we have a full complement of crawlers
|
||||
// Calls transid_max() which updates m_transid_re
|
||||
insert_new_crawl();
|
||||
|
||||
// Don't hold root FDs open too long.
|
||||
// The open FDs prevent snapshots from being deleted.
|
||||
// cleaner_kthread just keeps skipping over the open dir and all its children.
|
||||
// Even open files are a problem if they're big enough.
|
||||
auto new_count = m_transid_re.count();
|
||||
if (new_count != last_count) {
|
||||
m_ctx->fd_cache()->clear();
|
||||
}
|
||||
last_count = new_count;
|
||||
|
||||
BEESNOTE("waiting for next transid " << m_transid_re);
|
||||
// We don't use wait_for here because somebody needs to
|
||||
// be updating m_transid_re from time to time.
|
||||
|
Reference in New Issue
Block a user