Skip to content

Commit

Permalink
Filestore: readahead cache invalidation should not evict all nodes
Browse files Browse the repository at this point in the history
  • Loading branch information
Maxim Deb Natkh committed Jan 7, 2025
1 parent c397ea2 commit 8b57e0d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion cloud/filestore/libs/storage/tablet/model/read_ahead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ TMaybe<TByteRange> TReadAheadCache::RegisterDescribe(

void TReadAheadCache::InvalidateCache(ui64 nodeId)
{
NodeStates.clear(nodeId);
NodeStates.erase(nodeId);
}

void TReadAheadCache::OnDestroyHandle(ui64 nodeId, ui64 handle)
Expand Down
23 changes: 23 additions & 0 deletions cloud/filestore/libs/storage/tablet/model/read_ahead_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,29 @@ Y_UNIT_TEST_SUITE(TReadAheadTest)
blobPieces[0].GetRanges(0).GetBlobOffset());
}
}

Y_UNIT_TEST(ShouldInvalidateNodes)
{
TDefaultCache cache;

RegisterResult(cache, 111, 0, 1_MB);
RegisterResult(cache, 111, 1_MB, 1_MB);
RegisterResult(cache, 111, 2_MB, 1_MB);
RegisterResult(cache, 222, 100_MB, 1_MB);
RegisterResult(cache, 222, 105_MB, 1_MB);

// both nodes should be present in cache
UNIT_ASSERT_VALUES_EQUAL(
Expected(111, 0, 128_KB, 0),
FillResult(cache, 111, 0, 128_KB));

cache.InvalidateCache(111);

// the first node should be evicted, the second should be present
UNIT_ASSERT_VALUES_EQUAL(
Expected(222, 100_MB, 128_KB, 0),
FillResult(cache, 222, 100_MB, 128_KB));
}
}

} // namespace NCloud::NFileStore::NStorage

0 comments on commit 8b57e0d

Please sign in to comment.