Skip to content

Commit 9d1fdab

Browse files
authored
Merge 4798870 into ca3aa76
2 parents ca3aa76 + 4798870 commit 9d1fdab

16 files changed

+638
-197
lines changed

ydb/core/tablet_flat/flat_exec_seat.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@ namespace NKikimr {
44
namespace NTabletFlatExecutor {
55

66
void TSeat::Complete(const TActorContext& ctx, bool isRW) noexcept {
7+
if (Y_UNLIKELY(IsTerminated())) {
8+
Y_ABORT_UNLESS(!isRW, "Terminating a read-write transaction");
9+
Self->Terminate(TerminationReason, ctx);
10+
Self->TxSpan.EndError("Terminated");
11+
return;
12+
}
13+
714
NWilson::TSpan span(TWilsonTablet::TabletDetailed, Self->TxSpan.GetTraceId(), "Tablet.Transaction.Complete");
815
for (auto& callback : OnPersistent) {
916
callback();
@@ -15,11 +22,5 @@ namespace NTabletFlatExecutor {
1522
Self->TxSpan.EndOk();
1623
}
1724

18-
void TSeat::Terminate(ETerminationReason reason, const TActorContext& ctx) noexcept {
19-
Self->Terminate(reason, ctx);
20-
21-
Self->TxSpan.EndError("Terminated");
22-
}
23-
2425
} // namespace NTabletFlatExecutor
2526
} // namespace NKikimr

ydb/core/tablet_flat/flat_exec_seat.h

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "tablet_flat_executor.h"
55
#include "flat_sausagecache.h"
66

7+
#include <util/generic/intrlist.h>
78
#include <util/generic/ptr.h>
89
#include <util/system/hp_timer.h>
910
#include <ydb/library/actors/wilson/wilson_span.h>
@@ -12,7 +13,17 @@
1213
namespace NKikimr {
1314
namespace NTabletFlatExecutor {
1415

15-
struct TSeat {
16+
enum class ESeatState {
17+
None,
18+
Pending,
19+
Active,
20+
ActiveLow,
21+
Postponed,
22+
Waiting,
23+
Done,
24+
};
25+
26+
struct TSeat : public TIntrusiveListItem<TSeat> {
1627
using TPinned = THashMap<TLogoBlobID, THashMap<ui32, TIntrusivePtr<TPrivatePageCachePinPad>>>;
1728

1829
TSeat(const TSeat&) = delete;
@@ -30,9 +41,11 @@ namespace NTabletFlatExecutor {
3041
out << "}";
3142
}
3243

33-
void Complete(const TActorContext& ctx, bool isRW) noexcept;
44+
bool IsTerminated() const {
45+
return TerminationReason != ETerminationReason::None;
46+
}
3447

35-
void Terminate(ETerminationReason reason, const TActorContext& ctx) noexcept;
48+
void Complete(const TActorContext& ctx, bool isRW) noexcept;
3649

3750
void StartEnqueuedSpan() noexcept {
3851
WaitingSpan = NWilson::TSpan(TWilsonTablet::TabletDetailed, Self->TxSpan.GetTraceId(), "Tablet.Transaction.Enqueued");
@@ -54,7 +67,7 @@ namespace NTabletFlatExecutor {
5467
return Self->TxSpan.GetTraceId();
5568
}
5669

57-
const ui64 UniqID = Max<ui64>();
70+
const ui64 UniqID;
5871
const TAutoPtr<ITransaction> Self;
5972
NWilson::TSpan WaitingSpan;
6073
ui64 Retries = 0;
@@ -74,6 +87,10 @@ namespace NTabletFlatExecutor {
7487
ui32 NotEnoughMemoryCount = 0;
7588
ui64 TaskId = 0;
7689

90+
ESeatState State = ESeatState::Done;
91+
bool LowPriority = false;
92+
bool Cancelled = false;
93+
7794
TAutoPtr<TMemoryToken> AttachedMemory;
7895
TIntrusivePtr<TMemoryGCToken> CapturedMemory;
7996
TVector<std::function<void()>> OnPersistent;

0 commit comments

Comments
 (0)