@@ -225,7 +225,8 @@ class TPartitionFixture : public NUnitTest::TBaseFixture {
225
225
void SendSetOffset (ui64 cookie,
226
226
const TString& clientId,
227
227
ui64 offset,
228
- const TString& sessionId);
228
+ const TString& sessionId,
229
+ bool strict = false );
229
230
void SendGetOffset (ui64 cookie,
230
231
const TString& clientId);
231
232
void WaitCmdWrite (const TCmdWriteMatcher& matcher = {});
@@ -488,7 +489,8 @@ void TPartitionFixture::SendCreateSession(ui64 cookie,
488
489
void TPartitionFixture::SendSetOffset (ui64 cookie,
489
490
const TString& clientId,
490
491
ui64 offset,
491
- const TString& sessionId)
492
+ const TString& sessionId,
493
+ bool strict)
492
494
{
493
495
auto event = MakeHolder<TEvPQ::TEvSetClientInfo>(cookie,
494
496
clientId,
@@ -498,6 +500,7 @@ void TPartitionFixture::SendSetOffset(ui64 cookie,
498
500
0 ,
499
501
0 ,
500
502
TActorId{});
503
+ event->Strict = strict;
501
504
Ctx->Runtime ->SingleSys ()->Send (new IEventHandle (ActorId, Ctx->Edge , event.Release ()));
502
505
}
503
506
@@ -712,7 +715,6 @@ void TPartitionFixture::WaitErrorResponse(const TErrorMatcher& matcher)
712
715
}
713
716
714
717
if (matcher.Error ) {
715
-
716
718
UNIT_ASSERT_VALUES_EQUAL (*matcher.Error , event->Error );
717
719
}
718
720
}
@@ -1796,6 +1798,28 @@ void TPartitionTxTestHelper::WaitTxPredicateReplyImpl(ui64 userActId, bool statu
1796
1798
#endif
1797
1799
}
1798
1800
1801
+ Y_UNIT_TEST_F (UserActCount, TPartitionFixture)
1802
+ {
1803
+ // In the test, we check that the reference count for `UserInfo` decreases in case of errors. To do this,
1804
+ // we send a large number of requests to which the server will respond with an error.
1805
+
1806
+ CreatePartition ();
1807
+
1808
+ SendCreateSession (1 , " client" , " session-id" , 2 , 3 );
1809
+ WaitCmdWrite ({.Count =2 , .UserInfos ={{0 , {.Session =" session-id" , .Offset =0 , .Generation =2 , .Step =3 }}}});
1810
+ SendCmdWriteResponse (NMsgBusProxy::MSTATUS_OK);
1811
+ WaitProxyResponse ({.Cookie =1 });
1812
+
1813
+ for (ui64 k = 0 ; k <= MAX_USER_ACTS; ++k) {
1814
+ const ui64 cookie = 2 + k;
1815
+ // 1 > EndOffset
1816
+ SendSetOffset (cookie, " client" , 1 , " session-id" , true ); // strict = true
1817
+ WaitCmdWrite ({.Count =2 , .UserInfos ={{0 , {.Session =" session-id" , .Offset =0 , .Generation =2 , .Step =3 }}}});
1818
+ SendCmdWriteResponse (NMsgBusProxy::MSTATUS_OK);
1819
+ WaitErrorResponse ({.Cookie =cookie, .ErrorCode =NPersQueue::NErrorCode::SET_OFFSET_ERROR_COMMIT_TO_FUTURE});
1820
+ }
1821
+ }
1822
+
1799
1823
Y_UNIT_TEST_F (Batching, TPartitionFixture)
1800
1824
{
1801
1825
CreatePartition ();
0 commit comments