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

Filestore: readahead cache invalidation should not evict all nodes #2805

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading