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

Make max commit size configurable with icb #4774

Merged
merged 1 commit into from
May 23, 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
9 changes: 9 additions & 0 deletions ydb/core/protos/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1256,13 +1256,22 @@ message TImmediateControlsConfig {
DefaultValue: 10 }];
}

message TTabletControls {
optional uint64 MaxCommitRedoMB = 1 [(ControlOptions) = {
Description: "Maximum redo size per commit in megabytes",
MinValue: 8,
MaxValue: 4096,
DefaultValue: 256 }];
}

optional TDataShardControls DataShardControls = 1;
optional TTxLimitControls TxLimitControls = 2;
optional TCoordinatorControls CoordinatorControls = 3;
optional TSchemeShardControls SchemeShardControls = 4;
optional TTCMallocControls TCMallocControls = 5;
reserved 6;
optional TVDiskControls VDiskControls = 7;
optional TTabletControls TabletControls = 8;
};

message TMeteringConfig {
Expand Down
16 changes: 0 additions & 16 deletions ydb/core/tablet_flat/flat_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
#include <util/generic/cast.h>
#include <util/stream/output.h>


#define MAX_REDO_BYTES_PER_COMMIT 268435456U // 256MB


namespace NKikimr {
namespace NTable {

Expand Down Expand Up @@ -672,18 +668,6 @@ size_t TDatabase::GetCommitRedoBytes() const
return Redo->Bytes();
}

bool TDatabase::ValidateCommit(TString &err)
{
if (*Redo && Redo->Bytes() > MAX_REDO_BYTES_PER_COMMIT) {
err = TStringBuilder()
<< "Redo commit of " << Redo->Bytes()
<< " bytes is more than the allowed limit";
return false;
}

return true;
}

bool TDatabase::HasChanges() const
{
Y_ABORT_UNLESS(Redo, "Transaction is not in progress");
Expand Down
1 change: 0 additions & 1 deletion ydb/core/tablet_flat/flat_database.h
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,6 @@ class TDatabase {
void RollUpRemoveRowVersions(ui32 table, const TRowVersion& lower, const TRowVersion& upper);

size_t GetCommitRedoBytes() const;
bool ValidateCommit(TString&);

TCompactionStats GetCompactionStats(ui32 table) const;

Expand Down
19 changes: 13 additions & 6 deletions ydb/core/tablet_flat/flat_executor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ TExecutor::TExecutor(
, CounterEventsInFlight(new TEvTabletCounters::TInFlightCookie)
, Stats(new TExecutorStatsImpl())
, LogFlushDelayOverrideUsec(-1, -1, 60*1000*1000)
, MaxCommitRedoMB(256, 1, 4096)
{}

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

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

bool failed = false;
TString failureReason;
if (done && (failed = !Database->ValidateCommit(failureReason))) {
if (auto logl = Logger->Log(ELnLev::Crit)) {
logl
<< NFmt::Do(*this) << " " << NFmt::Do(*seat)
<< " fatal commit failure: " << failureReason;
if (done) {
ui64 commitRedoBytes = Database->GetCommitRedoBytes();
ui64 maxCommitRedoBytes = ui64(MaxCommitRedoMB) << 20; // MB to bytes
if (commitRedoBytes > maxCommitRedoBytes) {
if (auto logl = Logger->Log(ELnLev::Crit)) {
logl
<< NFmt::Do(*this) << " " << NFmt::Do(*seat)
<< " fatal commit failure: Redo commit of " << commitRedoBytes
<< " bytes is more than the allowed limit";
}
failed = true;
}
}

Expand Down
1 change: 1 addition & 0 deletions ydb/core/tablet_flat/flat_executor.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,7 @@ class TExecutor
TActorContext OwnerCtx() const;

TControlWrapper LogFlushDelayOverrideUsec;
TControlWrapper MaxCommitRedoMB;

ui64 Stamp() const noexcept;
void Registered(TActorSystem*, const TActorId&) override;
Expand Down
Loading