Skip to content

Commit bc90b90

Browse files
committed
Fixes
1 parent da7e50a commit bc90b90

File tree

7 files changed

+35
-50
lines changed

7 files changed

+35
-50
lines changed

ydb/core/protos/tx_sequenceshard.proto

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@ message TEvMarkSchemeShardPipe {
1717
uint64 Round = 3;
1818
}
1919

20+
message TSetVal {
21+
sint64 NextValue = 1;
22+
bool NextUsed = 2;
23+
}
24+
2025
message TEvCreateSequence {
2126
NKikimrProto.TPathID PathId = 1;
2227
uint64 TxId = 2;
@@ -40,7 +45,9 @@ message TEvCreateSequence {
4045
bool Cycle = 9;
4146
}
4247
bool Frozen = 10; // defaults to false
43-
bool Overflowed = 11; // defaults to false
48+
oneof OptionalSetVal {
49+
TSetVal SetVal = 11;
50+
}
4451
}
4552

4653
message TEvCreateSequenceResult {

ydb/core/tx/schemeshard/schemeshard__operation_copy_sequence.cpp

Lines changed: 4 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -275,47 +275,15 @@ class TProposedCopySequence : public TSubOperationState {
275275
}
276276

277277
void UpdateSequenceDescription(NKikimrSchemeOp::TSequenceDescription& descr) {
278-
descr.SetStartValue(GetSequenceResult.GetNextValue());
278+
descr.SetStartValue(GetSequenceResult.GetStartValue());
279279
descr.SetMinValue(GetSequenceResult.GetMinValue());
280280
descr.SetMaxValue(GetSequenceResult.GetMaxValue());
281281
descr.SetCache(GetSequenceResult.GetCache());
282282
descr.SetIncrement(GetSequenceResult.GetIncrement());
283283
descr.SetCycle(GetSequenceResult.GetCycle());
284-
285-
i64 nextValue = GetSequenceResult.GetNextValue();
286-
i64 minValue = GetSequenceResult.GetMinValue();
287-
i64 maxValue = GetSequenceResult.GetMaxValue();
288-
bool cycle = GetSequenceResult.GetCycle();
289-
bool overflowed = false;
290-
291-
if (GetSequenceResult.GetNextUsed()) {
292-
i64 increment = GetSequenceResult.GetIncrement();
293-
if (increment > 0) {
294-
ui64 delta = increment;
295-
296-
if (nextValue < maxValue && ui64(maxValue) - ui64(nextValue) >= delta) {
297-
nextValue += delta;
298-
} else {
299-
if (cycle) {
300-
nextValue = minValue;
301-
}
302-
overflowed = true;
303-
}
304-
} else {
305-
ui64 delta = -increment;
306-
307-
if (nextValue > minValue && ui64(nextValue) - ui64(minValue) >= delta) {
308-
nextValue -= delta;
309-
} else {
310-
if (cycle) {
311-
nextValue = maxValue;
312-
}
313-
overflowed = true;
314-
}
315-
}
316-
}
317-
descr.SetStartValue(nextValue);
318-
descr.SetOverflowed(overflowed);
284+
auto* setValMsg = descr.MutableSetVal();
285+
setValMsg->SetNextValue(GetSequenceResult.GetNextValue());
286+
setValMsg->SetNextUsed(GetSequenceResult.GetNextUsed());
319287
}
320288

321289
public:

ydb/core/tx/schemeshard/schemeshard__operation_create_sequence.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,10 @@ class TConfigureParts : public TSubOperationState {
142142
if (alterData->Description.HasCycle()) {
143143
event->Record.SetCycle(alterData->Description.GetCycle());
144144
}
145-
event->Record.SetOverflowed(alterData->Description.GetOverflowed());
145+
if (alterData->Description.HasSetVal()) {
146+
event->Record.MutableSetVal()->SetNextValue(alterData->Description.GetSetVal().GetNextValue());
147+
event->Record.MutableSetVal()->SetNextUsed(alterData->Description.GetSetVal().GetNextUsed());
148+
}
146149

147150
LOG_DEBUG_S(context.Ctx, NKikimrServices::FLAT_TX_SCHEMESHARD,
148151
"TCreateSequence TConfigureParts ProgressState"

ydb/core/tx/schemeshard/schemeshard_import_flow_proposals.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,11 @@ THolder<TEvSchemeShard::TEvModifySchemeTransaction> CreateTablePropose(
7272
if (fromSequence.has_cycle()) {
7373
seqDesc->SetCycle(fromSequence.cycle());
7474
}
75-
seqDesc->SetOverflowed(fromSequence.overflowed());
75+
if (fromSequence.has_set_val()) {
76+
auto* setVal = seqDesc->MutableSetVal();
77+
setVal->SetNextUsed(fromSequence.set_val().next_used());
78+
setVal->SetNextValue(fromSequence.set_val().next_value());
79+
}
7680

7781
break;
7882
}

ydb/core/tx/sequenceshard/public/events.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,6 @@ namespace NSequenceShard {
104104
return std::move(*this);
105105
}
106106

107-
TBuilder&& SetOverflowed(bool overflowed) && {
108-
Msg->Record.SetOverflowed(overflowed);
109-
return std::move(*this);
110-
}
111-
112107
THolder<TEvCreateSequence> Done() && {
113108
return std::move(Msg);
114109
}

ydb/core/tx/sequenceshard/tx_create_sequence.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,14 @@ namespace NSequenceShard {
7474
sequence.Cycle = msg->Record.GetCycle();
7575
}
7676

77-
sequence.NextValue = sequence.StartValue;
78-
bool overflowed = msg->Record.GetOverflowed();
79-
sequence.NextUsed = overflowed;
77+
78+
if (msg->Record.OptionalSetVal_case() == NKikimrTxSequenceShard::TEvCreateSequence::kSetVal) {
79+
sequence.NextValue = msg->Record.GetSetVal().GetNextValue();
80+
sequence.NextUsed = msg->Record.GetSetVal().GetNextUsed();
81+
} else {
82+
sequence.NextUsed = false;
83+
sequence.NextValue = sequence.StartValue;
84+
}
8085

8186
if (msg->Record.OptionalCache_case() == NKikimrTxSequenceShard::TEvCreateSequence::kCache) {
8287
sequence.Cache = msg->Record.GetCache();
@@ -105,8 +110,7 @@ namespace NSequenceShard {
105110
<< " Cache# " << sequence.Cache
106111
<< " Increment# " << sequence.Increment
107112
<< " Cycle# " << (sequence.Cycle ? "true" : "false")
108-
<< " State# " << (frozen ? "Frozen" : "Active")
109-
<< " Overflowed# " << (overflowed ? "true" : "false"));
113+
<< " State# " << (frozen ? "Frozen" : "Active"));
110114
return true;
111115
}
112116

ydb/core/ydb_convert/table_description.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1419,7 +1419,11 @@ void FillSequenceDescription(Ydb::Table::CreateTableRequest& out, const NKikimrS
14191419
if (sequenceDescription.HasCycle()) {
14201420
fromSequence->set_cycle(sequenceDescription.GetCycle());
14211421
}
1422-
fromSequence->set_overflowed(sequenceDescription.GetOverflowed());
1422+
if (sequenceDescription.HasSetVal()) {
1423+
auto* setVal = fromSequence->mutable_set_val();
1424+
setVal->set_next_used(sequenceDescription.GetSetVal().GetNextUsed());
1425+
setVal->set_next_value(sequenceDescription.GetSetVal().GetNextValue());
1426+
}
14231427
break;
14241428
}
14251429
case Ydb::Table::ColumnMeta::kFromLiteral: {

0 commit comments

Comments
 (0)