Skip to content

Commit cec442e

Browse files
committed
Add datashard interface for data cleanup operation
1 parent e464f3d commit cec442e

File tree

5 files changed

+51
-0
lines changed

5 files changed

+51
-0
lines changed

ydb/core/protos/tx_datashard.proto

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2259,3 +2259,18 @@ message TEvInMemoryStateResponse {
22592259
// Will be set for incomplete replies
22602260
optional bytes ContinuationToken = 3;
22612261
}
2262+
2263+
// Forces cleanup-related operations in datashard tablet:
2264+
// compaction, GC, GC log and other temporary data erasure.
2265+
// After this operation, all deleted data that was not used at the beginning of the operation
2266+
// is guaranteed to be garbage-collected in the blobstorage.
2267+
// Note: deleted data may still be used for a while, e.g. for history for MVCC.
2268+
message TEvForceDataCleanup {
2269+
optional uint64 DataCleanupGeneration = 1; // increasing sequence
2270+
}
2271+
2272+
// Returns DataCleanupGeneration of the last successfully completed TEvForceDataCleanup request.
2273+
// Intermediate requests and corresponding TEvForceDataCleanupResult's may be skipped.
2274+
message TEvForceDataCleanupResult {
2275+
optional uint64 DataCleanupGeneration = 1; // from corresponding request
2276+
}

ydb/core/tx/datashard/datashard.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,9 @@ namespace TEvDataShard {
346346
EvInMemoryStateRequest,
347347
EvInMemoryStateResponse,
348348

349+
EvForceDataCleanup,
350+
EvForceDataCleanupResult,
351+
349352
EvEnd
350353
};
351354

@@ -1562,6 +1565,24 @@ namespace TEvDataShard {
15621565
}
15631566
};
15641567

1568+
struct TEvForceDataCleanup : TEventPB<TEvForceDataCleanup, NKikimrTxDataShard::TEvForceDataCleanup,
1569+
TEvDataShard::EvForceDataCleanup> {
1570+
TEvForceDataCleanup() = default;
1571+
1572+
TEvForceDataCleanup(ui64 dataCleanupGeneration) {
1573+
Record.SetDataCleanupGeneration(dataCleanupGeneration);
1574+
}
1575+
};
1576+
1577+
struct TEvForceDataCleanupResult : TEventPB<TEvForceDataCleanupResult, NKikimrTxDataShard::TEvForceDataCleanupResult,
1578+
TEvDataShard::EvForceDataCleanupResult> {
1579+
TEvForceDataCleanupResult() = default;
1580+
1581+
TEvForceDataCleanupResult(ui64 dataCleanupGeneration) {
1582+
Record.SetDataCleanupGeneration(dataCleanupGeneration);
1583+
}
1584+
};
1585+
15651586
/**
15661587
* This message is used to ask datashard to compact any borrowed parts it has
15671588
* for the specified user table.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include "datashard_impl.h"
2+
3+
namespace NKikimr::NDataShard {
4+
5+
void TDataShard::Handle(TEvDataShard::TEvForceDataCleanup::TPtr& ev, const TActorContext& ctx) {
6+
// TODO: implement
7+
Y_UNUSED(ev);
8+
Y_UNUSED(ctx);
9+
}
10+
11+
} // namespace NKikimr::NDataShard

ydb/core/tx/datashard/datashard_impl.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,6 +1389,8 @@ class TDataShard
13891389

13901390
void Handle(TEvIncrementalRestoreScan::TEvFinished::TPtr& ev, const TActorContext& ctx);
13911391

1392+
void Handle(TEvDataShard::TEvForceDataCleanup::TPtr& ev, const TActorContext& ctx);
1393+
13921394
void HandleByReplicationSourceOffsetsServer(STATEFN_SIG);
13931395

13941396
void DoPeriodicTasks(const TActorContext &ctx);
@@ -3211,6 +3213,7 @@ class TDataShard
32113213
HFunc(TEvPrivate::TEvStatisticsScanFinished, Handle);
32123214
HFuncTraced(TEvPrivate::TEvRemoveSchemaSnapshots, Handle);
32133215
HFunc(TEvIncrementalRestoreScan::TEvFinished, Handle);
3216+
HFunc(TEvDataShard::TEvForceDataCleanup, Handle);
32143217
default:
32153218
if (!HandleDefaultEvents(ev, SelfId())) {
32163219
ALOG_WARN(NKikimrServices::TX_DATASHARD, "TDataShard::StateWork unhandled event type: " << ev->GetTypeRewrite() << " event: " << ev->ToString());

ydb/core/tx/datashard/ya.make

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ SRCS(
5555
datashard__compact_borrowed.cpp
5656
datashard__compaction.cpp
5757
datashard__conditional_erase_rows.cpp
58+
datashard__data_cleanup.cpp
5859
datashard__engine_host.cpp
5960
datashard__engine_host.h
6061
datashard__get_state_tx.cpp

0 commit comments

Comments
 (0)