@@ -125,6 +125,24 @@ static const ui32 MAX_KEYS = 10000;
125125static const ui32 MAX_TXS = 1000 ;
126126static const ui32 MAX_WRITE_CYCLE_SIZE = 16_MB;
127127
128+ TStringBuilder MakeTxWriteErrorMessage (TMaybe<ui64> txId,
129+ TStringBuf topicName, const TPartitionId& partitionId,
130+ TStringBuf sourceId, ui64 seqNo)
131+ {
132+ TStringBuilder ss;
133+ ss << " [TxId: " << txId << " , Topic: '" << topicName << " ', Partition " << partitionId << " , SourceId '" << EscapeC (sourceId) << " ', SeqNo " << seqNo << " ] " ;
134+ return ss;
135+ }
136+
137+ TStringBuilder MakeTxReadErrorMessage (TMaybe<ui64> txId,
138+ TStringBuf topicName, const TPartitionId& partitionId,
139+ TStringBuf consumer)
140+ {
141+ TStringBuilder ss;
142+ ss << " [TxId: " << txId << " , Topic: '" << topicName << " ', Partition " << partitionId << " , Consumer '" << consumer << " ] " ;
143+ return ss;
144+ }
145+
128146auto GetStepAndTxId (ui64 step, ui64 txId)
129147{
130148 return std::make_pair (step, txId);
@@ -1205,7 +1223,8 @@ void TPartition::ProcessPendingEvent(std::unique_ptr<TEvPQ::TEvTxCalcPredicate>
12051223 MakeHolder<TEvPQ::TEvTxCalcPredicateResult>(ev->Step ,
12061224 ev->TxId ,
12071225 Partition,
1208- Nothing ()).Release ());
1226+ Nothing (),
1227+ TString ()).Release ());
12091228 return ;
12101229 }
12111230 }
@@ -1447,7 +1466,9 @@ TPartition::EProcessResult TPartition::ApplyWriteInfoResponse(TTransaction& tx)
14471466 if (auto inFlightIter = TxInflightMaxSeqNoPerSourceId.find (s.first ); !inFlightIter.IsEnd ()) {
14481467 if (SeqnoViolation (inFlightIter->second .KafkaProducerEpoch , inFlightIter->second .SeqNo , s.second .ProducerEpoch , s.second .MinSeqNo )) {
14491468 tx.Predicate = false ;
1450- tx.Message = TStringBuilder () << " MinSeqNo violation failure on " << s.first ;
1469+ tx.Message = (MakeTxWriteErrorMessage (tx.GetTxId (), TopicName (), Partition, s.first , inFlightIter->second .SeqNo ) <<
1470+ " MinSeqNo violation failure. " <<
1471+ " SeqNo " << s.second .MinSeqNo );
14511472 tx.WriteInfoApplied = true ;
14521473 break ;
14531474 }
@@ -1456,7 +1477,9 @@ TPartition::EProcessResult TPartition::ApplyWriteInfoResponse(TTransaction& tx)
14561477 if (auto existing = knownSourceIds.find (s.first ); !existing.IsEnd ()) {
14571478 if (SeqnoViolation (existing->second .ProducerEpoch , existing->second .SeqNo , s.second .ProducerEpoch , s.second .MinSeqNo )) {
14581479 tx.Predicate = false ;
1459- tx.Message = TStringBuilder () << " MinSeqNo violation failure on " << s.first ;
1480+ tx.Message = (MakeTxWriteErrorMessage (tx.GetTxId (), TopicName (), Partition, s.first , existing->second .SeqNo ) <<
1481+ " MinSeqNo violation failure. " <<
1482+ " SeqNo " << s.second .MinSeqNo );
14601483 tx.WriteInfoApplied = true ;
14611484 break ;
14621485 }
@@ -1511,6 +1534,8 @@ void TPartition::Handle(TEvPQ::TEvGetWriteInfoError::TPtr& ev, const TActorConte
15111534void TPartition::ReplyToProposeOrPredicate (TSimpleSharedPtr<TTransaction>& tx, bool isPredicate) {
15121535
15131536 if (isPredicate) {
1537+ TabletCounters.Percentile ()[COUNTER_LATENCY_PQ_TXCALCPREDICATE].IncrementFor ((Now () - tx->CalcPredicateTimestamp ).MilliSeconds ());
1538+
15141539 tx->CalcPredicateSpan .End ();
15151540 tx->CalcPredicateSpan = {};
15161541
@@ -1527,7 +1552,8 @@ void TPartition::ReplyToProposeOrPredicate(TSimpleSharedPtr<TTransaction>& tx, b
15271552 MakeHolder<TEvPQ::TEvTxCalcPredicateResult>(tx->Tx ->Step ,
15281553 tx->Tx ->TxId ,
15291554 Partition,
1530- *tx->Predicate ).Release ());
1555+ *tx->Predicate ,
1556+ tx->Message ).Release ());
15311557 } else {
15321558 auto insRes = TransactionsInflight.emplace (tx->ProposeConfig ->TxId , tx);
15331559 Y_ABORT_UNLESS (insRes.second );
@@ -2022,7 +2048,7 @@ void TPartition::Handle(TEvKeyValue::TEvResponse::TPtr& ev, const TActorContext&
20222048
20232049void TPartition::PushBackDistrTx (TSimpleSharedPtr<TEvPQ::TEvTxCalcPredicate> event)
20242050{
2025- UserActionAndTransactionEvents.emplace_back (MakeSimpleShared<TTransaction>(std::move (event)));
2051+ UserActionAndTransactionEvents.emplace_back (MakeSimpleShared<TTransaction>(std::move (event), Now () ));
20262052 RequestWriteInfoIfRequired ();
20272053}
20282054
@@ -2459,7 +2485,7 @@ TPartition::EProcessResult TPartition::PreProcessUserActionOrTransaction(TSimple
24592485 ReplyToProposeOrPredicate (t, true );
24602486 return EProcessResult::Continue;
24612487 }
2462- result = BeginTransaction (*t->Tx , t->Predicate );
2488+ result = BeginTransaction (*t->Tx , t->Predicate , t-> Message );
24632489 if (t->Predicate .Defined ()) {
24642490 ReplyToProposeOrPredicate (t, true );
24652491 }
@@ -2527,7 +2553,8 @@ bool TPartition::ExecUserActionOrTransaction(TSimpleSharedPtr<TTransaction>& t,
25272553 return true ;
25282554}
25292555
2530- TPartition::EProcessResult TPartition::BeginTransaction (const TEvPQ::TEvTxCalcPredicate& tx, TMaybe<bool >& predicateOut)
2556+ TPartition::EProcessResult TPartition::BeginTransaction (const TEvPQ::TEvTxCalcPredicate& tx,
2557+ TMaybe<bool >& predicateOut, TString& issueMsg)
25312558{
25322559 if (tx.ForcePredicateFalse ) {
25332560 predicateOut = false ;
@@ -2550,13 +2577,17 @@ TPartition::EProcessResult TPartition::BeginTransaction(const TEvPQ::TEvTxCalcPr
25502577 if (AffectedUsers.contains (consumer) && !GetPendingUserIfExists (consumer)) {
25512578 PQ_LOG_D (" Partition " << Partition <<
25522579 " Consumer '" << consumer << " ' has been removed" );
2580+ issueMsg = (MakeTxReadErrorMessage (tx.TxId , TopicName (), Partition, consumer) <<
2581+ " Consumer has been removed" );
25532582 result = false ;
25542583 break ;
25552584 }
25562585
25572586 if (!UsersInfoStorage->GetIfExists (consumer)) {
25582587 PQ_LOG_D (" Partition " << Partition <<
25592588 " Unknown consumer '" << consumer << " '" );
2589+ issueMsg = (MakeTxReadErrorMessage (tx.TxId , TopicName (), Partition, consumer) <<
2590+ " Unknown consumer" );
25602591 result = false ;
25612592 break ;
25622593 }
@@ -2585,20 +2616,32 @@ TPartition::EProcessResult TPartition::BeginTransaction(const TEvPQ::TEvTxCalcPr
25852616 " Bad request (invalid range) " <<
25862617 " Begin " << operation.GetCommitOffsetsBegin () <<
25872618 " End " << operation.GetCommitOffsetsEnd ());
2619+ issueMsg = (MakeTxReadErrorMessage (tx.TxId , TopicName (), Partition, consumer) <<
2620+ " Invalid range. " <<
2621+ " Range begin " << operation.GetCommitOffsetsBegin () <<
2622+ " , range end " << operation.GetCommitOffsetsEnd ());
25882623 result = false ;
25892624 } else if (!operation.GetForceCommit () && userInfo.Offset != (i64 )operation.GetCommitOffsetsBegin ()) {
25902625 PQ_LOG_D (" Partition " << Partition <<
25912626 " Consumer '" << consumer << " '" <<
25922627 " Bad request (gap) " <<
25932628 " Offset " << userInfo.Offset <<
25942629 " Begin " << operation.GetCommitOffsetsBegin ());
2630+ issueMsg = (MakeTxReadErrorMessage (tx.TxId , TopicName (), Partition, consumer) <<
2631+ " Gap. " <<
2632+ " Offset " << userInfo.Offset <<
2633+ " , range begin " << operation.GetCommitOffsetsBegin ());
25952634 result = false ;
25962635 } else if (!operation.GetForceCommit () && operation.GetCommitOffsetsEnd () > EndOffset) {
25972636 PQ_LOG_D (" Partition " << Partition <<
25982637 " Consumer '" << consumer << " '" <<
25992638 " Bad request (behind the last offset) " <<
26002639 " EndOffset " << EndOffset <<
26012640 " End " << operation.GetCommitOffsetsEnd ());
2641+ issueMsg = (MakeTxReadErrorMessage (tx.TxId , TopicName (), Partition, consumer) <<
2642+ " Behind the last offset. " <<
2643+ " Partition end offset " << EndOffset <<
2644+ " , range end " << operation.GetCommitOffsetsEnd ());
26022645 result = false ;
26032646 }
26042647
0 commit comments