@@ -171,12 +171,10 @@ class TFixture : public NUnitTest::TBaseFixture {
171
171
void CreateTable (const TString& path);
172
172
void UpsertToTable (const TString& tablePath,
173
173
const TVector<TTableRecord>& records,
174
- ISession& session,
175
- TTransactionBase* tx);
174
+ NTable::TTransaction* tx);
176
175
void InsertToTable (const TString& tablePath,
177
176
const TVector<TTableRecord>& records,
178
- ISession& session,
179
- TTransactionBase* tx);
177
+ NTable::TTransaction* tx);
180
178
void DeleteFromTable (const TString& tablePath,
181
179
const TVector<TTableRecord>& records,
182
180
NTable::TTransaction* tx);
@@ -1370,8 +1368,8 @@ void TFixture::TestWriteToTopic24()
1370
1368
NTable::TTransaction tx = BeginTx (tableSession);
1371
1369
1372
1370
auto records = MakeTableRecords ();
1373
- UpsertToTable (" table_A" , records, tx. get () );
1374
- WriteToTopic (" topic_A" , TEST_MESSAGE_GROUP_ID, MakeJsonDoc (records), tx. get () );
1371
+ UpsertToTable (" table_A" , records, &tx );
1372
+ WriteToTopic (" topic_A" , TEST_MESSAGE_GROUP_ID, MakeJsonDoc (records), &tx );
1375
1373
1376
1374
CommitTx (tx, EStatus::SUCCESS);
1377
1375
@@ -2222,13 +2220,13 @@ auto TFixture::MakeJsonDoc(const TVector<TTableRecord>& records) -> TString
2222
2220
2223
2221
void TFixture::UpsertToTable (const TString& tablePath,
2224
2222
const TVector<TTableRecord>& records,
2225
- ISession& session,
2226
2223
NTable::TTransaction* tx)
2227
2224
{
2228
2225
TString query = Sprintf (" DECLARE $key AS Utf8;"
2229
2226
" DECLARE $value AS Utf8;"
2230
2227
" UPSERT INTO `%s` (key, value) VALUES ($key, $value);" ,
2231
2228
tablePath.data ());
2229
+ NTable::TSession session = tx->GetSession ();
2232
2230
2233
2231
for (const auto & r : records) {
2234
2232
auto params = session.GetParamsBuilder ()
@@ -2244,41 +2242,47 @@ void TFixture::UpsertToTable(const TString& tablePath,
2244
2242
2245
2243
void TFixture::InsertToTable (const TString& tablePath,
2246
2244
const TVector<TTableRecord>& records,
2247
- ISession& session,
2248
- TTransactionBase* tx)
2245
+ NTable::TTransaction* tx)
2249
2246
{
2250
2247
TString query = Sprintf (" DECLARE $key AS Utf8;"
2251
2248
" DECLARE $value AS Utf8;"
2252
2249
" INSERT INTO `%s` (key, value) VALUES ($key, $value);" ,
2253
2250
tablePath.data ());
2251
+ NTable::TSession session = tx->GetSession ();
2254
2252
2255
2253
for (const auto & r : records) {
2256
2254
auto params = TParamsBuilder ()
2257
2255
.AddParam (" $key" ).Utf8 (r.Key ).Build ()
2258
2256
.AddParam (" $value" ).Utf8 (r.Value ).Build ()
2259
2257
.Build ();
2260
2258
2261
- session.Execute (query, tx, false , params);
2259
+ auto result = session.ExecuteDataQuery (query,
2260
+ NYdb::NTable::TTxControl::Tx (*tx),
2261
+ params).GetValueSync ();
2262
+ UNIT_ASSERT_C (result.IsSuccess (), result.GetIssues ().ToString ());
2262
2263
}
2263
2264
}
2264
2265
2265
2266
void TFixture::DeleteFromTable (const TString& tablePath,
2266
2267
const TVector<TTableRecord>& records,
2267
- ISession& session,
2268
- TTransactionBase* tx)
2268
+ NTable::TTransaction* tx)
2269
2269
{
2270
2270
TString query = Sprintf (" DECLARE $key AS Utf8;"
2271
2271
" DECLARE $value AS Utf8;"
2272
2272
" DELETE FROM `%s` ON (key, value) VALUES ($key, $value);" ,
2273
2273
tablePath.data ());
2274
+ NTable::TSession session = tx->GetSession ();
2274
2275
2275
2276
for (const auto & r : records) {
2276
2277
auto params = TParamsBuilder ()
2277
2278
.AddParam (" $key" ).Utf8 (r.Key ).Build ()
2278
2279
.AddParam (" $value" ).Utf8 (r.Value ).Build ()
2279
2280
.Build ();
2280
2281
2281
- session.Execute (query, tx, false , params);
2282
+ auto result = session.ExecuteDataQuery (query,
2283
+ NYdb::NTable::TTxControl::Tx (*tx),
2284
+ params).GetValueSync ();
2285
+ UNIT_ASSERT_C (result.IsSuccess (), result.GetIssues ().ToString ());
2282
2286
}
2283
2287
}
2284
2288
@@ -2794,30 +2798,19 @@ class TFixtureSinks : public TFixture {
2794
2798
2795
2799
void TestSinksOltpWriteToTopic5 ();
2796
2800
2797
- void TestSinksOltpWriteToTopicAndTable2 ();
2798
2801
void TestSinksOltpWriteToTopicAndTable3 ();
2799
2802
void TestSinksOltpWriteToTopicAndTable4 ();
2800
- void TestSinksOltpWriteToTopicAndTable5 ();
2801
2803
void TestSinksOltpWriteToTopicAndTable6 ();
2802
2804
2803
2805
void TestSinksOlapWriteToTopicAndTable1 ();
2804
2806
void TestSinksOlapWriteToTopicAndTable2 ();
2805
- void TestSinksOlapWriteToTopicAndTable3 ();
2806
2807
void TestSinksOlapWriteToTopicAndTable4 ();
2807
2808
};
2808
2809
2809
2810
class TFixtureSinksTable : public TFixtureSinks {
2810
- protected:
2811
- EClientType GetClientType () const override {
2812
- return EClientType::Table;
2813
- }
2814
2811
};
2815
2812
2816
2813
class TFixtureSinksQuery : public TFixtureSinks {
2817
- protected:
2818
- EClientType GetClientType () const override {
2819
- return EClientType::Query;
2820
- }
2821
2814
};
2822
2815
2823
2816
void TFixtureSinks::CreateRowTable (const TString& path)
@@ -2935,7 +2928,7 @@ Y_UNIT_TEST_F(Sinks_Oltp_WriteToTopicAndTable_2, TFixtureSinks)
2935
2928
NTable::TTransaction tx = BeginTx (tableSession);
2936
2929
2937
2930
auto records = MakeTableRecords ();
2938
- UpsertToTable (" table_A" , records, *session, tx. get () );
2931
+ UpsertToTable (" table_A" , records, &tx );
2939
2932
2940
2933
WriteToTopic (" topic_A" , TEST_MESSAGE_GROUP_ID, MakeJsonDoc (records), &tx);
2941
2934
@@ -2963,17 +2956,7 @@ Y_UNIT_TEST_F(Sinks_Oltp_WriteToTopicAndTable_2, TFixtureSinks)
2963
2956
}
2964
2957
2965
2958
2966
- Y_UNIT_TEST_F (Sinks_Oltp_WriteToTopicAndTable_2_Table, TFixtureSinksTable)
2967
- {
2968
- TestSinksOltpWriteToTopicAndTable2 ();
2969
- }
2970
-
2971
- Y_UNIT_TEST_F (Sinks_Oltp_WriteToTopicAndTable_2_Query, TFixtureSinksQuery)
2972
- {
2973
- TestSinksOltpWriteToTopicAndTable2 ();
2974
- }
2975
-
2976
- void TFixtureSinks::TestSinksOltpWriteToTopicAndTable3 ()
2959
+ Y_UNIT_TEST_F (Sinks_Oltp_WriteToTopicAndTable_3, TFixtureSinks)
2977
2960
{
2978
2961
CreateTopic (" topic_A" );
2979
2962
CreateTopic (" topic_B" );
@@ -2985,8 +2968,8 @@ void TFixtureSinks::TestSinksOltpWriteToTopicAndTable3()
2985
2968
NTable::TTransaction tx = BeginTx (tableSession);
2986
2969
2987
2970
auto records = MakeTableRecords ();
2988
- UpsertToTable (" table_A" , records, *session, tx. get () );
2989
- UpsertToTable (" table_B" , records, *session, tx. get () );
2971
+ UpsertToTable (" table_A" , records, &tx );
2972
+ UpsertToTable (" table_B" , records, &tx );
2990
2973
2991
2974
WriteToTopic (" topic_A" , TEST_MESSAGE_GROUP_ID, MakeJsonDoc (records), &tx);
2992
2975
@@ -3027,7 +3010,7 @@ Y_UNIT_TEST_F(Sinks_Oltp_WriteToTopicAndTable_4, TFixtureSinks)
3027
3010
ExecuteDataQuery (tableSession, R"( SELECT COUNT(*) FROM `table_A`)" , NTable::TTxControl::Tx (tx1));
3028
3011
3029
3012
auto records = MakeTableRecords ();
3030
- UpsertToTable (" table_A" , records, *session, tx2. get () );
3013
+ UpsertToTable (" table_A" , records, & tx2);
3031
3014
3032
3015
WriteToTopic (" topic_A" , TEST_MESSAGE_GROUP_ID, MakeJsonDoc (records), &tx1);
3033
3016
WaitForAcks (" topic_A" , TEST_MESSAGE_GROUP_ID);
@@ -3051,7 +3034,7 @@ Y_UNIT_TEST_F(Sinks_Oltp_WriteToTopicAndTable_5, TFixtureSinks)
3051
3034
NTable::TTransaction tx = BeginTx (tableSession);
3052
3035
3053
3036
auto records = MakeTableRecords ();
3054
- UpsertToTable (" table_A" , records, *session, tx. get () );
3037
+ UpsertToTable (" table_A" , records, &tx );
3055
3038
3056
3039
WriteToTopic (" topic_A" , TEST_MESSAGE_GROUP_ID, MakeJsonDoc (records), &tx);
3057
3040
WaitForAcks (" topic_A" , TEST_MESSAGE_GROUP_ID);
@@ -3065,37 +3048,27 @@ Y_UNIT_TEST_F(Sinks_Oltp_WriteToTopicAndTable_5, TFixtureSinks)
3065
3048
CheckTabletKeys (" topic_A" );
3066
3049
}
3067
3050
3068
- Y_UNIT_TEST_F (Sinks_Oltp_WriteToTopicAndTable_5_Table, TFixtureSinksTable)
3069
- {
3070
- TestSinksOltpWriteToTopicAndTable5 ();
3071
- }
3072
-
3073
- Y_UNIT_TEST_F (Sinks_Oltp_WriteToTopicAndTable_5_Query, TFixtureSinksQuery)
3074
- {
3075
- TestSinksOltpWriteToTopicAndTable5 ();
3076
- }
3077
-
3078
3051
void TFixtureSinks::TestSinksOltpWriteToTopicAndTable6 ()
3079
3052
{
3080
3053
CreateTopic (" topic_A" );
3081
3054
CreateTopic (" topic_B" );
3082
3055
CreateRowTable (" /Root/table_A" );
3083
3056
3084
- auto session = CreateSession ();
3085
- auto tx = session-> BeginTx ();
3057
+ NTable::TSession tableSession = CreateTableSession ();
3058
+ NTable::TTransaction tx = BeginTx (tableSession );
3086
3059
3087
3060
auto records = MakeTableRecords ();
3088
- InsertToTable (" table_A" , records, *session, tx. get () );
3061
+ InsertToTable (" table_A" , records, &tx );
3089
3062
3090
- WriteToTopic (" topic_A" , TEST_MESSAGE_GROUP_ID, MakeJsonDoc (records), tx. get () );
3063
+ WriteToTopic (" topic_A" , TEST_MESSAGE_GROUP_ID, MakeJsonDoc (records), &tx );
3091
3064
3092
- WriteToTopic (" topic_B" , TEST_MESSAGE_GROUP_ID, " message #1" , tx. get () );
3093
- WriteToTopic (" topic_B" , TEST_MESSAGE_GROUP_ID, " message #2" , tx. get () );
3094
- WriteToTopic (" topic_B" , TEST_MESSAGE_GROUP_ID, " message #3" , tx. get () );
3065
+ WriteToTopic (" topic_B" , TEST_MESSAGE_GROUP_ID, " message #1" , &tx );
3066
+ WriteToTopic (" topic_B" , TEST_MESSAGE_GROUP_ID, " message #2" , &tx );
3067
+ WriteToTopic (" topic_B" , TEST_MESSAGE_GROUP_ID, " message #3" , &tx );
3095
3068
3096
- DeleteFromTable (" table_A" , records, *session, tx. get () );
3069
+ DeleteFromTable (" table_A" , records, &tx );
3097
3070
3098
- session-> CommitTx (* tx, EStatus::SUCCESS);
3071
+ CommitTx (tx, EStatus::SUCCESS);
3099
3072
3100
3073
{
3101
3074
auto messages = Read_Exactly_N_Messages_From_Topic (" topic_A" , TEST_CONSUMER, 1 );
@@ -3135,8 +3108,8 @@ void TFixtureSinks::TestSinksOlapWriteToTopicAndTable1()
3135
3108
NTable::TTransaction tx = BeginTx (tableSession);
3136
3109
3137
3110
auto records = MakeTableRecords ();
3138
- UpsertToTable (" table_A" , records, *session, tx. get () );
3139
- WriteToTopic (" topic_A" , TEST_MESSAGE_GROUP_ID, MakeJsonDoc (records), tx. get () );
3111
+ UpsertToTable (" table_A" , records, &tx );
3112
+ WriteToTopic (" topic_A" , TEST_MESSAGE_GROUP_ID, MakeJsonDoc (records), &tx );
3140
3113
3141
3114
CommitTx (tx, EStatus::SUCCESS);
3142
3115
@@ -3162,8 +3135,8 @@ Y_UNIT_TEST_F(Sinks_Olap_WriteToTopicAndTable_2, TFixtureSinks)
3162
3135
3163
3136
auto records = MakeTableRecords ();
3164
3137
3165
- UpsertToTable (" table_A" , records, *session, tx. get () );
3166
- UpsertToTable (" table_B" , records, *session, tx. get () );
3138
+ UpsertToTable (" table_A" , records, &tx );
3139
+ UpsertToTable (" table_B" , records, &tx );
3167
3140
3168
3141
WriteToTopic (" topic_A" , TEST_MESSAGE_GROUP_ID, MakeJsonDoc (records), &tx);
3169
3142
@@ -3201,7 +3174,7 @@ Y_UNIT_TEST_F(Sinks_Olap_WriteToTopicAndTable_3, TFixtureSinks)
3201
3174
NTable::TTransaction tx = BeginTx (tableSession);
3202
3175
3203
3176
auto records = MakeTableRecords ();
3204
- UpsertToTable (" table_A" , records, *session, tx. get () );
3177
+ UpsertToTable (" table_A" , records, &tx );
3205
3178
3206
3179
WriteToTopic (" topic_A" , TEST_MESSAGE_GROUP_ID, MakeJsonDoc (records), &tx);
3207
3180
WaitForAcks (" topic_A" , TEST_MESSAGE_GROUP_ID);
@@ -3215,16 +3188,6 @@ Y_UNIT_TEST_F(Sinks_Olap_WriteToTopicAndTable_3, TFixtureSinks)
3215
3188
CheckTabletKeys (" topic_A" );
3216
3189
}
3217
3190
3218
- Y_UNIT_TEST_F (Write_Random_Sized_Messages_In_Wide_Transactions, TFixture)
3219
- {
3220
- // Consumes a lot of memory. Temporarily disabled
3221
- return ;
3222
-
3223
- Y_UNIT_TEST_F (Sinks_Olap_WriteToTopicAndTable_3_Query, TFixtureSinksQuery)
3224
- {
3225
- TestSinksOlapWriteToTopicAndTable3 ();
3226
- }
3227
-
3228
3191
void TFixtureSinks::TestSinksOlapWriteToTopicAndTable4 ()
3229
3192
{
3230
3193
return ; // https://github.com/ydb-platform/ydb/issues/17271
@@ -3235,25 +3198,25 @@ void TFixtureSinks::TestSinksOlapWriteToTopicAndTable4()
3235
3198
CreateColumnTable (" /Root/table_B" );
3236
3199
CreateColumnTable (" /Root/table_C" );
3237
3200
3238
- auto session = CreateSession ();
3239
- auto tx = session-> BeginTx ();
3201
+ NTable::TSession tableSession = CreateTableSession ();
3202
+ NTable::TTransaction tx = BeginTx (tableSession );
3240
3203
3241
3204
auto records = MakeTableRecords ();
3242
3205
3243
- InsertToTable (" table_A" , records, *session, tx. get () );
3244
- InsertToTable (" table_B" , records, *session, tx. get () );
3245
- UpsertToTable (" table_C" , records, *session, tx. get () );
3206
+ InsertToTable (" table_A" , records, &tx );
3207
+ InsertToTable (" table_B" , records, &tx );
3208
+ UpsertToTable (" table_C" , records, &tx );
3246
3209
3247
- WriteToTopic (" topic_A" , TEST_MESSAGE_GROUP_ID, MakeJsonDoc (records), tx. get () );
3210
+ WriteToTopic (" topic_A" , TEST_MESSAGE_GROUP_ID, MakeJsonDoc (records), &tx );
3248
3211
3249
3212
const size_t topicMsgCnt = 10 ;
3250
3213
for (size_t i = 1 ; i <= topicMsgCnt; ++i) {
3251
- WriteToTopic (" topic_B" , TEST_MESSAGE_GROUP_ID, " message #" + std::to_string (i), tx. get () );
3214
+ WriteToTopic (" topic_B" , TEST_MESSAGE_GROUP_ID, " message #" + std::to_string (i), &tx );
3252
3215
}
3253
3216
3254
- DeleteFromTable (" table_B" , records, *session, tx. get () );
3217
+ DeleteFromTable (" table_B" , records, &tx );
3255
3218
3256
- session-> CommitTx (* tx, EStatus::SUCCESS);
3219
+ CommitTx (tx, EStatus::SUCCESS);
3257
3220
3258
3221
{
3259
3222
auto messages = Read_Exactly_N_Messages_From_Topic (" topic_A" , TEST_CONSUMER, 1 );
@@ -3284,59 +3247,6 @@ Y_UNIT_TEST_F(Sinks_Olap_WriteToTopicAndTable_4_Query, TFixtureSinksQuery)
3284
3247
TestSinksOlapWriteToTopicAndTable4 ();
3285
3248
}
3286
3249
3287
- void TFixture::TestWriteRandomSizedMessagesInWideTransactions ()
3288
- {
3289
- // The test verifies the simultaneous execution of several transactions. There is a topic
3290
- // with PARTITIONS_COUNT partitions. In each transaction, the test writes to all the partitions.
3291
- // The size of the messages is random. Such that both large blobs in the body and small ones in
3292
- // the head of the partition are obtained. Message sizes are multiples of 500 KB. This way we
3293
- // will make sure that when committing transactions, the division into blocks is taken into account.
3294
-
3295
- const size_t PARTITIONS_COUNT = 20 ;
3296
- const size_t TXS_COUNT = 100 ;
3297
-
3298
- CreateTopic (" topic_A" , TEST_CONSUMER, PARTITIONS_COUNT);
3299
-
3300
- std::vector<NTable::TSession> sessions;
3301
- std::vector<NTable::TTransaction> transactions;
3302
-
3303
- // We open TXS_COUNT transactions and write messages to the topic.
3304
- for (size_t i = 0 ; i < TXS_COUNT; ++i) {
3305
- sessions.push_back (CreateTableSession ());
3306
- auto & session = sessions.back ();
3307
-
3308
- transactions.push_back (BeginTx (session));
3309
- auto & tx = transactions.back ();
3310
-
3311
- for (size_t j = 0 ; j < PARTITIONS_COUNT; ++j) {
3312
- TString sourceId = TEST_MESSAGE_GROUP_ID;
3313
- sourceId += " _" ;
3314
- sourceId += ToString (i);
3315
- sourceId += " _" ;
3316
- sourceId += ToString (j);
3317
-
3318
- size_t count = RandomNumber<size_t >(20 ) + 3 ;
3319
- WriteToTopic (" topic_A" , sourceId, TString (512 * 1000 * count, ' x' ), &tx, j);
3320
-
3321
- WaitForAcks (" topic_A" , sourceId);
3322
- }
3323
- }
3324
-
3325
- // We are doing an asynchronous commit of transactions. They will be executed simultaneously.
3326
- std::vector<NTable::TAsyncCommitTransactionResult> futures;
3327
-
3328
- for (size_t i = 0 ; i < TXS_COUNT; ++i) {
3329
- futures.push_back (transactions[i].Commit ());
3330
- }
3331
-
3332
- // All transactions must be completed successfully.
3333
- for (size_t i = 0 ; i < TXS_COUNT; ++i) {
3334
- futures[i].Wait ();
3335
- const auto & result = futures[i].GetValueSync ();
3336
- UNIT_ASSERT_VALUES_EQUAL_C (result.GetStatus (), EStatus::SUCCESS, result.GetIssues ().ToString ());
3337
- }
3338
- }
3339
-
3340
3250
Y_UNIT_TEST_F (The_Configuration_Is_Changing_As_We_Write_To_The_Topic, TFixture)
3341
3251
{
3342
3252
// To test that you can change the topic configuration while writing to the partition
0 commit comments