@@ -315,6 +315,7 @@ void TPartition::AnswerCurrentWrites(const TActorContext& ctx) {
315
315
already ? maxOffset : offset, CurrentTimestamp, already, maxSeqNo,
316
316
PartitionQuotaWaitTimeForCurrentBlob, TopicQuotaWaitTimeForCurrentBlob, queueTime, writeTime, response.Span
317
317
);
318
+
318
319
PQ_LOG_D (" Answering for message sourceid: '" << EscapeC (s)
319
320
<< " ', Topic: '" << TopicName ()
320
321
<< " ', Partition: " << Partition
@@ -521,6 +522,7 @@ void TPartition::HandleWriteResponse(const TActorContext& ctx) {
521
522
SourceIdCounter.Use (sourceId, now);
522
523
}
523
524
TxSourceIdForPostPersist.clear ();
525
+ TxInflightMaxSeqNoPerSourceId.clear ();
524
526
525
527
TxAffectedSourcesIds.clear ();
526
528
WriteAffectedSourcesIds.clear ();
@@ -1042,6 +1044,7 @@ TPartition::EProcessResult TPartition::PreProcessRequest(TWriteMsg& p) {
1042
1044
TStringBuilder () << " Write to inactive partition " << Partition.OriginalPartitionId );
1043
1045
return EProcessResult::ContinueDrop;
1044
1046
}
1047
+
1045
1048
if (DiskIsFull) {
1046
1049
ScheduleReplyError (p.Cookie ,
1047
1050
NPersQueue::NErrorCode::WRITE_ERROR_DISK_IS_FULL,
@@ -1051,6 +1054,13 @@ TPartition::EProcessResult TPartition::PreProcessRequest(TWriteMsg& p) {
1051
1054
if (TxAffectedSourcesIds.contains (p.Msg .SourceId )) {
1052
1055
return EProcessResult::Blocked;
1053
1056
}
1057
+ auto inflightMaxSeqNo = TxInflightMaxSeqNoPerSourceId.find (p.Msg .SourceId );
1058
+
1059
+ if (!inflightMaxSeqNo.IsEnd ()) {
1060
+ if (p.Msg .SeqNo <= inflightMaxSeqNo->second ) {
1061
+ return EProcessResult::Blocked;
1062
+ }
1063
+ }
1054
1064
WriteAffectedSourcesIds.insert (p.Msg .SourceId );
1055
1065
return EProcessResult::Continue;
1056
1066
}
@@ -1173,12 +1183,11 @@ bool TPartition::ExecRequest(TWriteMsg& p, ProcessParameters& parameters, TEvKey
1173
1183
<< " . Writing seqNo: " << sourceId.UpdatedSeqNo ()
1174
1184
<< " . EndOffset: " << EndOffset << " . CurOffset: " << curOffset << " . Offset: " << poffset
1175
1185
);
1176
- if (!p.Internal ) {
1177
- TabletCounters.Cumulative ()[COUNTER_PQ_WRITE_ALREADY].Increment (1 );
1178
- MsgsDiscarded.Inc ();
1179
- TabletCounters.Cumulative ()[COUNTER_PQ_WRITE_BYTES_ALREADY].Increment (p.Msg .Data .size ());
1180
- BytesDiscarded.Inc (p.Msg .Data .size ());
1181
- }
1186
+ Y_ENSURE (!p.Internal ); // No Already for transactions;
1187
+ TabletCounters.Cumulative ()[COUNTER_PQ_WRITE_ALREADY].Increment (1 );
1188
+ MsgsDiscarded.Inc ();
1189
+ TabletCounters.Cumulative ()[COUNTER_PQ_WRITE_BYTES_ALREADY].Increment (p.Msg .Data .size ());
1190
+ BytesDiscarded.Inc (p.Msg .Data .size ());
1182
1191
} else {
1183
1192
if (!p.Internal ) {
1184
1193
TabletCounters.Cumulative ()[COUNTER_PQ_WRITE_SMALL_OFFSET].Increment (1 );
@@ -1225,6 +1234,7 @@ bool TPartition::ExecRequest(TWriteMsg& p, ProcessParameters& parameters, TEvKey
1225
1234
" , must be at least " << curOffset,
1226
1235
p,
1227
1236
NPersQueue::NErrorCode::EErrorCode::WRITE_ERROR_BAD_OFFSET);
1237
+
1228
1238
return false ;
1229
1239
}
1230
1240
@@ -1279,6 +1289,7 @@ bool TPartition::ExecRequest(TWriteMsg& p, ProcessParameters& parameters, TEvKey
1279
1289
// this must not be happen - client sends gaps, fail this client till the end
1280
1290
// now no changes will leak
1281
1291
ctx.Send (Tablet, new TEvents::TEvPoisonPill ());
1292
+
1282
1293
return false ;
1283
1294
}
1284
1295
WriteNewSizeFull += p.Msg .SourceId .size () + p.Msg .Data .size ();
@@ -1380,7 +1391,6 @@ bool TPartition::ExecRequest(TWriteMsg& p, ProcessParameters& parameters, TEvKey
1380
1391
++curOffset;
1381
1392
PartitionedBlob = TPartitionedBlob (Partition, 0 , " " , 0 , 0 , 0 , Head, NewHead, true , false , MaxBlobSize);
1382
1393
}
1383
-
1384
1394
return true ;
1385
1395
}
1386
1396
0 commit comments