@@ -125,10 +125,12 @@ struct TTxCoordinator::TTxRestoreTransactions : public TTransactionBase<TTxCoord
125
125
return true ;
126
126
}
127
127
128
- void RestoreVolatileSteps () {
128
+ TStepId RestoreVolatileSteps () {
129
+ TStepId maxStep = 0 ;
129
130
for (auto &pr : Self->VolatileTransactions ) {
130
131
auto txId = pr.first ;
131
132
auto &tx = pr.second ;
133
+ maxStep = Max (maxStep, tx.PlanOnStep );
132
134
for (auto &prmed : tx.UnconfirmedAffectedSet ) {
133
135
auto medId = prmed.first ;
134
136
auto &medTx = GetMediatorTx (medId, tx.PlanOnStep , txId);
@@ -137,6 +139,7 @@ struct TTxCoordinator::TTxRestoreTransactions : public TTransactionBase<TTxCoord
137
139
}
138
140
}
139
141
}
142
+ return maxStep;
140
143
}
141
144
142
145
TTxType GetTxType () const override { return TXTYPE_INIT; }
@@ -146,15 +149,24 @@ struct TTxCoordinator::TTxRestoreTransactions : public TTransactionBase<TTxCoord
146
149
bool result = Restore (transactions, txc, ctx);
147
150
if (!result)
148
151
return false ;
149
- RestoreVolatileSteps ();
152
+ TStepId maxVolatileStep = RestoreVolatileSteps ();
150
153
i64 txCounter = transactions.size () + Self->VolatileTransactions .size ();
151
154
Self->Transactions .swap (transactions);
152
155
*Self->MonCounters .TxInFly += txCounter;
153
156
Self->MonCounters .CurrentTxInFly = txCounter;
154
157
155
- if (Self->PrevStateActorId ) {
156
- NIceDb::TNiceDb db (txc.DB );
158
+ NIceDb::TNiceDb db (txc.DB );
157
159
160
+ // Previous coordinator might have had transactions that were after
161
+ // its persistent blocked range, but before LastPlanned was updated.
162
+ // Since we pick them up as planned and send to mediators we also need
163
+ // to make sure LastPlanned reflects that.
164
+ if (Self->VolatileState .LastPlanned < maxVolatileStep) {
165
+ Self->VolatileState .LastPlanned = maxVolatileStep;
166
+ Schema::SaveState (db, Schema::State::KeyLastPlanned, maxVolatileStep);
167
+ }
168
+
169
+ if (Self->PrevStateActorId ) {
158
170
ui64 volatileLeaseMs = Self->VolatilePlanLeaseMs ;
159
171
if (volatileLeaseMs > 0 ) {
160
172
// Make sure we start and persist new state actor before allowing clients to acquire new read steps
0 commit comments