@@ -2675,6 +2675,7 @@ void TPersQueue::HandleEventForSupportivePartition(const ui64 responseCookie,
2675
2675
//
2676
2676
TTxWriteInfo& writeInfo = TxWrites[writeId];
2677
2677
TPartitionId partitionId (originalPartitionId, writeId, NextSupportivePartitionId++);
2678
+ PQ_LOG_D (" partition " << partitionId << " for WriteId " << writeId);
2678
2679
2679
2680
writeInfo.Partitions .emplace (originalPartitionId, partitionId);
2680
2681
TxWritesChanged = true ;
@@ -3109,7 +3110,7 @@ void TPersQueue::Handle(TEvPersQueue::TEvCancelTransactionProposal::TPtr& ev, co
3109
3110
3110
3111
void TPersQueue::Handle (TEvPersQueue::TEvProposeTransaction::TPtr& ev, const TActorContext& ctx)
3111
3112
{
3112
- LOG_DEBUG_S (ctx, NKikimrServices::PERSQUEUE, " Tablet " << TabletID () << " Handle TEvPersQueue::TEvProposeTransaction " );
3113
+ PQ_LOG_D ( " Handle TEvPersQueue::TEvProposeTransaction " << ev-> Get ()-> Record . DebugString () );
3113
3114
3114
3115
NKikimrPQ::TEvProposeTransaction& event = ev->Get ()->Record ;
3115
3116
switch (event.GetTxBodyCase ()) {
@@ -3122,6 +3123,8 @@ void TPersQueue::Handle(TEvPersQueue::TEvProposeTransaction::TPtr& ev, const TAc
3122
3123
case NKikimrPQ::TEvProposeTransaction::TXBODY_NOT_SET:
3123
3124
SendProposeTransactionAbort (ActorIdFromProto (event.GetSourceActor ()),
3124
3125
event.GetTxId (),
3126
+ NKikimrPQ::TError::ERROR,
3127
+ " missing TxBody" ,
3125
3128
ctx);
3126
3129
break ;
3127
3130
}
@@ -3134,6 +3137,7 @@ bool TPersQueue::CheckTxWriteOperation(const NKikimrPQ::TPartitionOperation& ope
3134
3137
TPartitionId partitionId (operation.GetPartitionId (),
3135
3138
writeId,
3136
3139
operation.GetSupportivePartition ());
3140
+ PQ_LOG_D (" partitionId=" << partitionId);
3137
3141
return Partitions.contains (partitionId);
3138
3142
}
3139
3143
@@ -3144,6 +3148,7 @@ bool TPersQueue::CheckTxWriteOperations(const NKikimrPQ::TDataTransaction& txBod
3144
3148
}
3145
3149
3146
3150
ui64 writeId = txBody.GetWriteId ();
3151
+ PQ_LOG_D (" writeId=" << writeId);
3147
3152
3148
3153
for (auto & operation : txBody.GetOperations ()) {
3149
3154
auto isWrite = [](const NKikimrPQ::TPartitionOperation& o) {
@@ -3169,8 +3174,11 @@ void TPersQueue::HandleDataTransaction(TAutoPtr<TEvPersQueue::TEvProposeTransact
3169
3174
const NKikimrPQ::TDataTransaction& txBody = event.GetData ();
3170
3175
3171
3176
if (TabletState != NKikimrPQ::ENormal) {
3177
+ PQ_LOG_D (" invalid PQ tablet state (" << NKikimrPQ::ETabletState_Name (TabletState) << " )" );
3172
3178
SendProposeTransactionAbort (ActorIdFromProto (event.GetSourceActor ()),
3173
3179
event.GetTxId (),
3180
+ NKikimrPQ::TError::ERROR,
3181
+ " invalid PQ tablet state" ,
3174
3182
ctx);
3175
3183
return ;
3176
3184
}
@@ -3180,36 +3188,49 @@ void TPersQueue::HandleDataTransaction(TAutoPtr<TEvPersQueue::TEvProposeTransact
3180
3188
//
3181
3189
3182
3190
if (txBody.OperationsSize () <= 0 ) {
3191
+ PQ_LOG_D (" empty list of operations" );
3183
3192
SendProposeTransactionAbort (ActorIdFromProto (event.GetSourceActor ()),
3184
3193
event.GetTxId (),
3194
+ NKikimrPQ::TError::BAD_REQUEST,
3195
+ " empty list of operations" ,
3185
3196
ctx);
3186
3197
return ;
3187
3198
}
3188
3199
3189
3200
if (!CheckTxWriteOperations (txBody)) {
3201
+ PQ_LOG_D (" invalid WriteId " << txBody.GetWriteId ());
3190
3202
SendProposeTransactionAbort (ActorIdFromProto (event.GetSourceActor ()),
3191
3203
event.GetTxId (),
3204
+ NKikimrPQ::TError::BAD_REQUEST,
3205
+ " invalid WriteId" ,
3192
3206
ctx);
3193
3207
return ;
3194
3208
}
3195
3209
3196
3210
TMaybe<TPartitionId> partitionId = FindPartitionId (txBody);
3197
3211
if (!partitionId.Defined ()) {
3212
+ PQ_LOG_D (" unknown partition for WriteId " << txBody.GetWriteId ());
3198
3213
SendProposeTransactionAbort (ActorIdFromProto (event.GetSourceActor ()),
3199
3214
event.GetTxId (),
3215
+ NKikimrPQ::TError::INTERNAL,
3216
+ " unknown supportive partition" ,
3200
3217
ctx);
3201
3218
return ;
3202
3219
}
3203
3220
3204
3221
if (!Partitions.contains (*partitionId)) {
3222
+ PQ_LOG_D (" unknown partition " << *partitionId);
3205
3223
SendProposeTransactionAbort (ActorIdFromProto (event.GetSourceActor ()),
3206
3224
event.GetTxId (),
3225
+ NKikimrPQ::TError::INTERNAL,
3226
+ " unknown supportive partition" ,
3207
3227
ctx);
3208
3228
return ;
3209
3229
}
3210
3230
3211
3231
3212
3232
if (txBody.GetImmediate ()) {
3233
+ PQ_LOG_D (" immediate transaction" );
3213
3234
TPartitionId originalPartitionId (txBody.GetOperations (0 ).GetPartitionId ());
3214
3235
const TPartitionInfo& partition = Partitions.at (originalPartitionId);
3215
3236
@@ -3221,6 +3242,7 @@ void TPersQueue::HandleDataTransaction(TAutoPtr<TEvPersQueue::TEvProposeTransact
3221
3242
3222
3243
ctx.Send (partition.Actor , ev.Release ());
3223
3244
} else {
3245
+ PQ_LOG_D (" distributed transaction" );
3224
3246
EvProposeTransactionQueue.emplace_back (ev.Release ());
3225
3247
3226
3248
TryWriteTxs (ctx);
@@ -3697,6 +3719,7 @@ void TPersQueue::SaveTxWrites(NKikimrPQ::TTabletTxInfo& info)
3697
3719
3698
3720
void TPersQueue::ScheduleProposeTransactionResult (const TDistributedTransaction& tx)
3699
3721
{
3722
+ PQ_LOG_D (" schedule TEvProposeTransactionResult(PREPARED)" );
3700
3723
auto event = std::make_unique<TEvPersQueue::TEvProposeTransactionResult>();
3701
3724
3702
3725
event->Record .SetOrigin (TabletID ());
@@ -3766,16 +3789,27 @@ void TPersQueue::SendEvReadSetAckToSenders(const TActorContext& ctx,
3766
3789
3767
3790
TMaybe<TPartitionId> TPersQueue::FindPartitionId (const NKikimrPQ::TDataTransaction& txBody) const
3768
3791
{
3792
+ auto hasWriteOperation = [](const auto & txBody) {
3793
+ for (const auto & o : txBody.GetOperations ()) {
3794
+ if (!o.HasBegin ()) {
3795
+ return true ;
3796
+ }
3797
+ }
3798
+ return false ;
3799
+ };
3800
+
3769
3801
ui32 partitionId = txBody.GetOperations (0 ).GetPartitionId ();
3770
3802
3771
- if (txBody.HasWriteId ()) {
3803
+ if (txBody.HasWriteId () && hasWriteOperation (txBody) ) {
3772
3804
ui64 writeId = txBody.GetWriteId ();
3773
3805
if (!TxWrites.contains (writeId)) {
3806
+ PQ_LOG_D (" unknown WriteId " << writeId);
3774
3807
return Nothing ();
3775
3808
}
3776
3809
3777
3810
const TTxWriteInfo& writeInfo = TxWrites.at (writeId);
3778
3811
if (!writeInfo.Partitions .contains (partitionId)) {
3812
+ PQ_LOG_D (" unknown partition " << partitionId << " for WriteId " << writeId);
3779
3813
return Nothing ();
3780
3814
}
3781
3815
@@ -3882,6 +3916,9 @@ void TPersQueue::SendEvProposeTransactionResult(const TActorContext& ctx,
3882
3916
result->Record .SetTxId (tx.TxId );
3883
3917
result->Record .SetStep (tx.Step );
3884
3918
3919
+ PQ_LOG_D (" send TEvPersQueue::TEvProposeTransactionResult(" <<
3920
+ NKikimrPQ::TEvProposeTransactionResult_EStatus_Name (result->Record .GetStatus ()) <<
3921
+ " )" );
3885
3922
ctx.Send (tx.SourceActor , std::move (result));
3886
3923
}
3887
3924
@@ -4204,6 +4241,8 @@ bool TPersQueue::AllTransactionsHaveBeenProcessed() const
4204
4241
4205
4242
void TPersQueue::SendProposeTransactionAbort (const TActorId& target,
4206
4243
ui64 txId,
4244
+ NKikimrPQ::TError::EKind kind,
4245
+ const TString& reason,
4207
4246
const TActorContext& ctx)
4208
4247
{
4209
4248
auto event = std::make_unique<TEvPersQueue::TEvProposeTransactionResult>();
@@ -4212,6 +4251,15 @@ void TPersQueue::SendProposeTransactionAbort(const TActorId& target,
4212
4251
event->Record .SetStatus (NKikimrPQ::TEvProposeTransactionResult::ABORTED);
4213
4252
event->Record .SetTxId (txId);
4214
4253
4254
+ if (kind != NKikimrPQ::TError::OK) {
4255
+ auto * error = event->Record .MutableErrors ()->Add ();
4256
+ error->SetKind (kind);
4257
+ error->SetReason (reason);
4258
+ }
4259
+
4260
+ PQ_LOG_D (" send TEvPersQueue::TEvProposeTransactionResult(" <<
4261
+ NKikimrPQ::TEvProposeTransactionResult_EStatus_Name (event->Record .GetStatus ()) <<
4262
+ " )" );
4215
4263
ctx.Send (target, std::move (event));
4216
4264
}
4217
4265
@@ -4509,6 +4557,7 @@ void TPersQueue::Handle(TEvPQ::TEvDeletePartitionDone::TPtr& ev, const TActorCon
4509
4557
DeleteTx (*tx);
4510
4558
}
4511
4559
}
4560
+ PQ_LOG_D (" delete WriteId " << writeId);
4512
4561
TxWrites.erase (writeId);
4513
4562
}
4514
4563
TxWritesChanged = true ;
@@ -4562,7 +4611,7 @@ void TPersQueue::BeginDeletePartitions(TTxWriteInfo& writeInfo)
4562
4611
}
4563
4612
4564
4613
TString TPersQueue::LogPrefix () const {
4565
- return TStringBuilder () << SelfId () << " " ;
4614
+ return TStringBuilder () << " [PQ: " << TabletID () << " ] " ;
4566
4615
}
4567
4616
4568
4617
ui64 TPersQueue::GetGeneration () {
0 commit comments