Skip to content

Commit 3016e0d

Browse files
authored
Merge 89d2518 into 5056f67
2 parents 5056f67 + 89d2518 commit 3016e0d

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

ydb/core/protos/config.proto

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,13 +1256,22 @@ message TImmediateControlsConfig {
12561256
DefaultValue: 10 }];
12571257
}
12581258

1259+
message TTabletControls {
1260+
optional uint64 MaxCommitRedoMB = 1 [(ControlOptions) = {
1261+
Description: "Maximum redo size per commit in megabytes",
1262+
MinValue: 8,
1263+
MaxValue: 4096,
1264+
DefaultValue: 256 }];
1265+
}
1266+
12591267
optional TDataShardControls DataShardControls = 1;
12601268
optional TTxLimitControls TxLimitControls = 2;
12611269
optional TCoordinatorControls CoordinatorControls = 3;
12621270
optional TSchemeShardControls SchemeShardControls = 4;
12631271
optional TTCMallocControls TCMallocControls = 5;
12641272
reserved 6;
12651273
optional TVDiskControls VDiskControls = 7;
1274+
optional TTabletControls TabletControls = 8;
12661275
};
12671276

12681277
message TMeteringConfig {

ydb/core/tablet_flat/flat_database.cpp

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@
1515
#include <util/generic/cast.h>
1616
#include <util/stream/output.h>
1717

18-
19-
#define MAX_REDO_BYTES_PER_COMMIT 268435456U // 256MB
20-
21-
2218
namespace NKikimr {
2319
namespace NTable {
2420

@@ -672,18 +668,6 @@ size_t TDatabase::GetCommitRedoBytes() const
672668
return Redo->Bytes();
673669
}
674670

675-
bool TDatabase::ValidateCommit(TString &err)
676-
{
677-
if (*Redo && Redo->Bytes() > MAX_REDO_BYTES_PER_COMMIT) {
678-
err = TStringBuilder()
679-
<< "Redo commit of " << Redo->Bytes()
680-
<< " bytes is more than the allowed limit";
681-
return false;
682-
}
683-
684-
return true;
685-
}
686-
687671
bool TDatabase::HasChanges() const
688672
{
689673
Y_ABORT_UNLESS(Redo, "Transaction is not in progress");

ydb/core/tablet_flat/flat_database.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,6 @@ class TDatabase {
257257
void RollUpRemoveRowVersions(ui32 table, const TRowVersion& lower, const TRowVersion& upper);
258258

259259
size_t GetCommitRedoBytes() const;
260-
bool ValidateCommit(TString&);
261260

262261
TCompactionStats GetCompactionStats(ui32 table) const;
263262

ydb/core/tablet_flat/flat_executor.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ TExecutor::TExecutor(
136136
, CounterEventsInFlight(new TEvTabletCounters::TInFlightCookie)
137137
, Stats(new TExecutorStatsImpl())
138138
, LogFlushDelayOverrideUsec(-1, -1, 60*1000*1000)
139+
, MaxCommitRedoMB(256, 1, 4096)
139140
{}
140141

141142
TExecutor::~TExecutor() {
@@ -159,6 +160,7 @@ void TExecutor::Registered(TActorSystem *sys, const TActorId&)
159160
Memory = new TMemory(Logger.Get(), this, Emitter, Sprintf(" at tablet %" PRIu64, Owner->TabletID()));
160161
TString myTabletType = TTabletTypes::TypeToStr(Owner->TabletType());
161162
AppData()->Icb->RegisterSharedControl(LogFlushDelayOverrideUsec, myTabletType + "_LogFlushDelayOverrideUsec");
163+
AppData()->Icb->RegisterSharedControl(MaxCommitRedoMB, "TabletControls.MaxCommitRedoMB");
162164

163165
// instantiate alert counters so even never reported alerts are created
164166
GetServiceCounters(AppData()->Counters, "tablets")->GetCounter("alerts_pending_nodata", true);
@@ -1724,12 +1726,17 @@ void TExecutor::ExecuteTransaction(TAutoPtr<TSeat> seat, const TActorContext &ct
17241726
}
17251727

17261728
bool failed = false;
1727-
TString failureReason;
1728-
if (done && (failed = !Database->ValidateCommit(failureReason))) {
1729-
if (auto logl = Logger->Log(ELnLev::Crit)) {
1730-
logl
1731-
<< NFmt::Do(*this) << " " << NFmt::Do(*seat)
1732-
<< " fatal commit failure: " << failureReason;
1729+
if (done) {
1730+
ui64 commitRedoBytes = Database->GetCommitRedoBytes();
1731+
ui64 maxCommitRedoBytes = ui64(MaxCommitRedoMB) << 20; // MB to bytes
1732+
if (commitRedoBytes > maxCommitRedoBytes) {
1733+
if (auto logl = Logger->Log(ELnLev::Crit)) {
1734+
logl
1735+
<< NFmt::Do(*this) << " " << NFmt::Do(*seat)
1736+
<< " fatal commit failure: Redo commit of " << commitRedoBytes
1737+
<< " bytes is more than the allowed limit";
1738+
}
1739+
failed = true;
17331740
}
17341741
}
17351742

ydb/core/tablet_flat/flat_executor.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ class TExecutor
483483
TActorContext OwnerCtx() const;
484484

485485
TControlWrapper LogFlushDelayOverrideUsec;
486+
TControlWrapper MaxCommitRedoMB;
486487

487488
ui64 Stamp() const noexcept;
488489
void Registered(TActorSystem*, const TActorId&) override;

0 commit comments

Comments
 (0)