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

Merge 23-3 #2093

Merged
merged 2 commits into from
Sep 20, 2024
Merged
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
19 changes: 13 additions & 6 deletions cloud/filestore/libs/storage/tablet/tablet_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,18 @@ void TIndexTabletActor::HandleDescribeSessions(
NCloud::Reply(ctx, *ev, std::move(response));
}

TVector<ui32> TIndexTabletActor::GenerateForceDeleteZeroCompactionRanges() const
{
TVector<ui32> ranges;
const auto& zeroRanges = RangesWithEmptyCompactionScore;
ui32 i = 0;
while (i < zeroRanges.size()) {
ranges.push_back(i);
i += Config->GetMaxZeroCompactionRangesToDeletePerTx();
}
return ranges;
}

void TIndexTabletActor::HandleForcedOperation(
const TEvIndexTablet::TEvForcedOperationRequest::TPtr& ev,
const TActorContext& ctx)
Expand Down Expand Up @@ -667,12 +679,7 @@ void TIndexTabletActor::HandleForcedOperation(
if (code == S_OK) {
TVector<ui32> ranges;
if (mode == EMode::DeleteZeroCompactionRanges) {
const auto& zeroRanges = RangesWithEmptyCompactionScore;
ui32 i = 0;
while (i < zeroRanges.size()) {
ranges.push_back(i);
i += Config->GetMaxZeroCompactionRangesToDeletePerTx();
}
ranges = GenerateForceDeleteZeroCompactionRanges();
} else {
ranges = request.GetProcessAllRanges()
? GetAllCompactionRanges()
Expand Down
2 changes: 2 additions & 0 deletions cloud/filestore/libs/storage/tablet/tablet_actor.h
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,8 @@ class TIndexTabletActor final
void EnqueueForcedRangeOperationIfNeeded(const NActors::TActorContext& ctx);
void LoadNextCompactionMapChunkIfNeeded(const NActors::TActorContext& ctx);

TVector<ui32> GenerateForceDeleteZeroCompactionRanges() const;

void AddTransaction(
TRequestInfo& transaction,
TRequestInfo::TCancelRoutine cancelRoutine);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,9 +404,11 @@ void TIndexTabletActor::HandleLoadCompactionMapChunkCompleted(
EnqueueBlobIndexOpIfNeeded(ctx);

LOG_INFO(ctx, TFileStoreComponents::TABLET,
"%s Compaction state loaded, MaxLoadedInOrderRangeId: %u",
"%s Compaction state loaded, MaxLoadedInOrderRangeId: %u, "
"RangesWithEmptyScore: %u",
LogTag.c_str(),
s.MaxLoadedInOrderRangeId);
s.MaxLoadedInOrderRangeId,
RangesWithEmptyCompactionScore.size());
} else {
// Triggering the next in-order load request
s.LoadQueue.push_back({
Expand Down Expand Up @@ -444,7 +446,8 @@ bool TIndexTabletActor::PrepareTx_LoadCompactionMapChunk(
bool ready = db.ReadCompactionMap(
args.CompactionMap,
args.FirstRangeId,
args.RangeCount);
args.RangeCount,
true);

LOG_INFO_S(ctx, TFileStoreComponents::TABLET,
LogTag << " Loading compaction map chunk "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1285,7 +1285,7 @@ void TIndexTabletActor::HandleHttpInfo_ForceOperation(
if (mode == TEvIndexTabletPrivate::EForcedRangeOperationMode
::DeleteZeroCompactionRanges)
{
ranges = RangesWithEmptyCompactionScore;
ranges = GenerateForceDeleteZeroCompactionRanges();
} else {
ranges = GetNonEmptyCompactionRanges();
}
Expand Down
9 changes: 7 additions & 2 deletions cloud/filestore/libs/storage/tablet/tablet_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1683,16 +1683,21 @@ void TIndexTabletDatabase::WriteCompactionMap(
bool TIndexTabletDatabase::ReadCompactionMap(
TVector<TCompactionRangeInfo>& compactionMap)
{
return ReadCompactionMap(compactionMap, 0, Max<ui32>());
return ReadCompactionMap(compactionMap, 0, Max<ui32>(), true);
}

bool TIndexTabletDatabase::ReadCompactionMap(
TVector<TCompactionRangeInfo>& compactionMap,
ui32 firstRangeId,
ui32 rangeCount)
ui32 rangeCount,
bool prechargeAll)
{
using TTable = TIndexTabletSchema::CompactionMap;

if (!firstRangeId && prechargeAll) {
Table<TTable>().Precharge();
}

auto it = Table<TTable>()
.GreaterOrEqual(firstRangeId)
.Select();
Expand Down
3 changes: 2 additions & 1 deletion cloud/filestore/libs/storage/tablet/tablet_database.h
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,8 @@ FILESTORE_FILESYSTEM_STATS(FILESTORE_DECLARE_STATS)
bool ReadCompactionMap(
TVector<TCompactionRangeInfo>& compactionMap,
ui32 firstRangeId,
ui32 rangeCount);
ui32 rangeCount,
bool prechargeAll);

//
// OpLog
Expand Down
10 changes: 5 additions & 5 deletions cloud/filestore/libs/storage/tablet/tablet_database_ut.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,19 +419,19 @@ Y_UNIT_TEST_SUITE(TIndexTabletDatabaseTest)

executor.ReadTx([&] (TIndexTabletDatabase db) {
TVector<TCompactionRangeInfo> chunk;
UNIT_ASSERT(db.ReadCompactionMap(chunk, 0, 5));
UNIT_ASSERT(db.ReadCompactionMap(chunk, 0, 5, true));
UNIT_ASSERT_VALUES_EQUAL(toString(entries, 0, 5), toString(chunk));

chunk.clear();
UNIT_ASSERT(db.ReadCompactionMap(chunk, 111, 5));
UNIT_ASSERT(db.ReadCompactionMap(chunk, 111, 5, true));
UNIT_ASSERT_VALUES_EQUAL(toString(entries, 5, 5), toString(chunk));

chunk.clear();
UNIT_ASSERT(db.ReadCompactionMap(chunk, 6002, 5));
UNIT_ASSERT(db.ReadCompactionMap(chunk, 6002, 5, true));
UNIT_ASSERT_VALUES_EQUAL(toString(entries, 10, 5), toString(chunk));

chunk.clear();
UNIT_ASSERT(db.ReadCompactionMap(chunk, 7001, 5));
UNIT_ASSERT(db.ReadCompactionMap(chunk, 7001, 5, true));
UNIT_ASSERT_VALUES_EQUAL("", toString(chunk));
});

Expand All @@ -446,7 +446,7 @@ Y_UNIT_TEST_SUITE(TIndexTabletDatabaseTest)

executor.ReadTx([&] (TIndexTabletDatabase db) {
TVector<TCompactionRangeInfo> chunk;
UNIT_ASSERT(db.ReadCompactionMap(chunk, 0, Max<ui32>()));
UNIT_ASSERT(db.ReadCompactionMap(chunk, 0, Max<ui32>(), true));
UNIT_ASSERT_VALUES_EQUAL(
toString(entries, 0, Max<ui32>(), true),
toString(chunk));
Expand Down
Loading