forked from ydb-platform/ydb
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Statistic: Delete analyze after deadline (ydb-platform#8214)
- Loading branch information
1 parent
dba2bab
commit 7b765a8
Showing
7 changed files
with
92 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
#include "aggregator_impl.h" | ||
|
||
#include <ydb/core/protos/hive.pb.h> | ||
#include <ydb/core/statistics/service/service.h> | ||
|
||
#include <util/string/vector.h> | ||
|
||
namespace NKikimr::NStat { | ||
|
||
struct TStatisticsAggregator::TTxAnalyzeDeadline : public TTxBase { | ||
TString OperationId; | ||
TActorId ReplyToActorId; | ||
|
||
TTxAnalyzeDeadline(TSelf* self) | ||
: TTxBase(self) | ||
{} | ||
|
||
TTxType GetTxType() const override { return TXTYPE_ANALYZE_DEADLINE; } | ||
|
||
bool Execute(TTransactionContext& txc, const TActorContext& ctx) override { | ||
SA_LOG_T("[" << Self->TabletID() << "] TTxAnalyzeDeadline::Execute"); | ||
|
||
NIceDb::TNiceDb db(txc.DB); | ||
auto now = ctx.Now(); | ||
|
||
for (TForceTraversalOperation& operation : Self->ForceTraversals) { | ||
if (operation.CreatedAt + Self->AnalyzeDeadline < now) { | ||
SA_LOG_E("[" << Self->TabletID() << "] Delete long analyze operation, OperationId=" << operation.OperationId); | ||
|
||
OperationId = operation.OperationId; | ||
ReplyToActorId = operation.ReplyToActorId; | ||
Self->DeleteForceTraversalOperation(operation.OperationId, db); | ||
break; | ||
} | ||
} | ||
|
||
return true; | ||
} | ||
|
||
void Complete(const TActorContext& ctx) override { | ||
SA_LOG_T("[" << Self->TabletID() << "] TTxAnalyzeDeadline::Complete"); | ||
|
||
if (OperationId) { | ||
if (ReplyToActorId) { | ||
SA_LOG_D("[" << Self->TabletID() << "] TTxAnalyzeDeadline::Complete. " << | ||
"Send TEvAnalyzeResponse for deleted operation, OperationId=" << OperationId << ", ActorId=" << ReplyToActorId); | ||
auto response = std::make_unique<TEvStatistics::TEvAnalyzeResponse>(); | ||
response->Record.SetOperationId(OperationId); | ||
ctx.Send(ReplyToActorId, response.release()); | ||
} else { | ||
SA_LOG_D("[" << Self->TabletID() << "] TTxAnalyzeDeadline::Complete. No ActorId to send reply. OperationId=" << OperationId); | ||
} | ||
ctx.Send(Self->SelfId(), new TEvPrivate::TEvAnalyzeDeadline()); | ||
} else { | ||
ctx.Schedule(AnalyzeDeadlinePeriod, new TEvPrivate::TEvAnalyzeDeadline()); | ||
} | ||
} | ||
}; | ||
|
||
void TStatisticsAggregator::Handle(TEvPrivate::TEvAnalyzeDeadline::TPtr&) { | ||
Execute(new TTxAnalyzeDeadline(this), | ||
TActivationContext::AsActorContext()); | ||
} | ||
|
||
} // NKikimr::NStat |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters