@@ -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 }
@@ -1451,7 +1470,9 @@ TPartition::EProcessResult TPartition::ApplyWriteInfoResponse(TTransaction& tx)
14511470 if (auto inFlightIter = TxInflightMaxSeqNoPerSourceId.find (s.first ); !inFlightIter.IsEnd ()) {
14521471 if (SeqnoViolation (inFlightIter->second .KafkaProducerEpoch , inFlightIter->second .SeqNo , s.second .ProducerEpoch , s.second .MinSeqNo )) {
14531472 tx.Predicate = false ;
1454- tx.Message = TStringBuilder () << " MinSeqNo violation failure on " << s.first ;
1473+ tx.Message = (MakeTxWriteErrorMessage (tx.GetTxId (), TopicName (), Partition, s.first , inFlightIter->second .SeqNo ) <<
1474+ " MinSeqNo violation failure. " <<
1475+ " SeqNo " << s.second .MinSeqNo );
14551476 tx.WriteInfoApplied = true ;
14561477 break ;
14571478 }
@@ -1460,7 +1481,9 @@ TPartition::EProcessResult TPartition::ApplyWriteInfoResponse(TTransaction& tx)
14601481 if (auto existing = knownSourceIds.find (s.first ); !existing.IsEnd ()) {
14611482 if (SeqnoViolation (existing->second .ProducerEpoch , existing->second .SeqNo , s.second .ProducerEpoch , s.second .MinSeqNo )) {
14621483 tx.Predicate = false ;
1463- tx.Message = TStringBuilder () << " MinSeqNo violation failure on " << s.first ;
1484+ tx.Message = (MakeTxWriteErrorMessage (tx.GetTxId (), TopicName (), Partition, s.first , existing->second .SeqNo ) <<
1485+ " MinSeqNo violation failure. " <<
1486+ " SeqNo " << s.second .MinSeqNo );
14641487 tx.WriteInfoApplied = true ;
14651488 break ;
14661489 }
@@ -1515,6 +1538,8 @@ void TPartition::Handle(TEvPQ::TEvGetWriteInfoError::TPtr& ev, const TActorConte
15151538void TPartition::ReplyToProposeOrPredicate (TSimpleSharedPtr<TTransaction>& tx, bool isPredicate) {
15161539
15171540 if (isPredicate) {
1541+ TabletCounters.Percentile ()[COUNTER_LATENCY_PQ_TXCALCPREDICATE].IncrementFor ((Now () - tx->CalcPredicateTimestamp ).MilliSeconds ());
1542+
15181543 tx->CalcPredicateSpan .End ();
15191544 tx->CalcPredicateSpan = {};
15201545
@@ -1531,7 +1556,8 @@ void TPartition::ReplyToProposeOrPredicate(TSimpleSharedPtr<TTransaction>& tx, b
15311556 MakeHolder<TEvPQ::TEvTxCalcPredicateResult>(tx->Tx ->Step ,
15321557 tx->Tx ->TxId ,
15331558 Partition,
1534- *tx->Predicate ).Release ());
1559+ *tx->Predicate ,
1560+ tx->Message ).Release ());
15351561 } else {
15361562 auto insRes = TransactionsInflight.emplace (tx->ProposeConfig ->TxId , tx);
15371563 Y_ABORT_UNLESS (insRes.second );
@@ -2026,7 +2052,7 @@ void TPartition::Handle(TEvKeyValue::TEvResponse::TPtr& ev, const TActorContext&
20262052
20272053void TPartition::PushBackDistrTx (TSimpleSharedPtr<TEvPQ::TEvTxCalcPredicate> event)
20282054{
2029- UserActionAndTransactionEvents.emplace_back (MakeSimpleShared<TTransaction>(std::move (event)));
2055+ UserActionAndTransactionEvents.emplace_back (MakeSimpleShared<TTransaction>(std::move (event), Now () ));
20302056 RequestWriteInfoIfRequired ();
20312057}
20322058
@@ -2457,7 +2483,7 @@ TPartition::EProcessResult TPartition::PreProcessUserActionOrTransaction(TSimple
24572483 ReplyToProposeOrPredicate (t, true );
24582484 return EProcessResult::Continue;
24592485 }
2460- result = BeginTransaction (*t->Tx , t->Predicate );
2486+ result = BeginTransaction (*t->Tx , t->Predicate , t-> Message );
24612487 if (t->Predicate .Defined ()) {
24622488 ReplyToProposeOrPredicate (t, true );
24632489 }
@@ -2525,7 +2551,8 @@ bool TPartition::ExecUserActionOrTransaction(TSimpleSharedPtr<TTransaction>& t,
25252551 return true ;
25262552}
25272553
2528- TPartition::EProcessResult TPartition::BeginTransaction (const TEvPQ::TEvTxCalcPredicate& tx, TMaybe<bool >& predicateOut)
2554+ TPartition::EProcessResult TPartition::BeginTransaction (const TEvPQ::TEvTxCalcPredicate& tx,
2555+ TMaybe<bool >& predicateOut, TString& issueMsg)
25292556{
25302557 if (tx.ForcePredicateFalse ) {
25312558 predicateOut = false ;
@@ -2548,13 +2575,17 @@ TPartition::EProcessResult TPartition::BeginTransaction(const TEvPQ::TEvTxCalcPr
25482575 if (AffectedUsers.contains (consumer) && !GetPendingUserIfExists (consumer)) {
25492576 PQ_LOG_D (" Partition " << Partition <<
25502577 " Consumer '" << consumer << " ' has been removed" );
2578+ issueMsg = (MakeTxReadErrorMessage (tx.TxId , TopicName (), Partition, consumer) <<
2579+ " Consumer has been removed" );
25512580 result = false ;
25522581 break ;
25532582 }
25542583
25552584 if (!UsersInfoStorage->GetIfExists (consumer)) {
25562585 PQ_LOG_D (" Partition " << Partition <<
25572586 " Unknown consumer '" << consumer << " '" );
2587+ issueMsg = (MakeTxReadErrorMessage (tx.TxId , TopicName (), Partition, consumer) <<
2588+ " Unknown consumer" );
25582589 result = false ;
25592590 break ;
25602591 }
@@ -2583,20 +2614,32 @@ TPartition::EProcessResult TPartition::BeginTransaction(const TEvPQ::TEvTxCalcPr
25832614 " Bad request (invalid range) " <<
25842615 " Begin " << operation.GetCommitOffsetsBegin () <<
25852616 " End " << operation.GetCommitOffsetsEnd ());
2617+ issueMsg = (MakeTxReadErrorMessage (tx.TxId , TopicName (), Partition, consumer) <<
2618+ " Invalid range. " <<
2619+ " Range begin " << operation.GetCommitOffsetsBegin () <<
2620+ " , range end " << operation.GetCommitOffsetsEnd ());
25862621 result = false ;
25872622 } else if (!operation.GetForceCommit () && userInfo.Offset != (i64 )operation.GetCommitOffsetsBegin ()) {
25882623 PQ_LOG_D (" Partition " << Partition <<
25892624 " Consumer '" << consumer << " '" <<
25902625 " Bad request (gap) " <<
25912626 " Offset " << userInfo.Offset <<
25922627 " Begin " << operation.GetCommitOffsetsBegin ());
2628+ issueMsg = (MakeTxReadErrorMessage (tx.TxId , TopicName (), Partition, consumer) <<
2629+ " Gap. " <<
2630+ " Offset " << userInfo.Offset <<
2631+ " , range begin " << operation.GetCommitOffsetsBegin ());
25932632 result = false ;
25942633 } else if (!operation.GetForceCommit () && operation.GetCommitOffsetsEnd () > EndOffset) {
25952634 PQ_LOG_D (" Partition " << Partition <<
25962635 " Consumer '" << consumer << " '" <<
25972636 " Bad request (behind the last offset) " <<
25982637 " EndOffset " << EndOffset <<
25992638 " End " << operation.GetCommitOffsetsEnd ());
2639+ issueMsg = (MakeTxReadErrorMessage (tx.TxId , TopicName (), Partition, consumer) <<
2640+ " Behind the last offset. " <<
2641+ " Partition end offset " << EndOffset <<
2642+ " , range end " << operation.GetCommitOffsetsEnd ());
26002643 result = false ;
26012644 }
26022645
0 commit comments