|
1 | 1 | #include <ydb/core/tx/datashard/ut_common/datashard_ut_common.h>
|
2 | 2 | #include "datashard_active_transaction.h"
|
| 3 | +#include "datashard_ut_common_kqp.h" |
3 | 4 |
|
4 | 5 | #include <ydb/core/tx/tx_proxy/proxy.h>
|
5 | 6 |
|
6 | 7 | namespace NKikimr {
|
7 | 8 |
|
8 | 9 | using namespace NKikimr::NDataShard;
|
| 10 | +using namespace NKikimr::NDataShard::NKqpHelpers; |
9 | 11 | using namespace NSchemeShard;
|
10 | 12 | using namespace Tests;
|
11 | 13 |
|
@@ -307,6 +309,46 @@ Y_UNIT_TEST_SUITE(DataShardReplication) {
|
307 | 309 | }, NKikimrTxDataShard::TEvApplyReplicationChangesResult::STATUS_REJECTED);
|
308 | 310 | }
|
309 | 311 |
|
| 312 | + Y_UNIT_TEST(ApplyChangesWithConcurrentTx) { |
| 313 | + TPortManager pm; |
| 314 | + TServerSettings serverSettings(pm.GetPort(2134)); |
| 315 | + serverSettings.SetDomainName("Root") |
| 316 | + .SetUseRealThreads(false); |
| 317 | + |
| 318 | + Tests::TServer::TPtr server = new TServer(serverSettings); |
| 319 | + auto &runtime = *server->GetRuntime(); |
| 320 | + auto sender = runtime.AllocateEdgeActor(); |
| 321 | + |
| 322 | + runtime.SetLogPriority(NKikimrServices::TX_DATASHARD, NLog::PRI_TRACE); |
| 323 | + |
| 324 | + InitRoot(server, sender); |
| 325 | + CreateShardedTable(server, sender, "/Root", "table-1", TShardedTableOptions() |
| 326 | + .Replicated(true) |
| 327 | + .ReplicationConsistency(EReplicationConsistency::Weak) |
| 328 | + ); |
| 329 | + |
| 330 | + auto shards = GetTableShards(server, sender, "/Root/table-1"); |
| 331 | + auto tableId = ResolveTableId(server, sender, "/Root/table-1"); |
| 332 | + |
| 333 | + ApplyChanges(server, shards.at(0), tableId, "my-source", { |
| 334 | + TChange{ .Offset = 0, .WriteTxId = 0, .Key = 1, .Value = 11 }, |
| 335 | + }); |
| 336 | + |
| 337 | + TString sessionId; |
| 338 | + TString txId; |
| 339 | + UNIT_ASSERT_VALUES_EQUAL( |
| 340 | + KqpSimpleBegin(runtime, sessionId, txId, "SELECT key, value FROM `/Root/table-1`;"), |
| 341 | + "{ items { uint32_value: 1 } items { uint32_value: 11 } }"); |
| 342 | + |
| 343 | + ApplyChanges(server, shards.at(0), tableId, "my-source", { |
| 344 | + TChange{ .Offset = 1, .WriteTxId = 0, .Key = 1, .Value = 21 }, |
| 345 | + }); |
| 346 | + |
| 347 | + UNIT_ASSERT_VALUES_EQUAL( |
| 348 | + KqpSimpleCommit(runtime, sessionId, txId, "SELECT key, value FROM `/Root/table-1`;"), |
| 349 | + "{ items { uint32_value: 1 } items { uint32_value: 11 } }"); |
| 350 | + } |
| 351 | + |
310 | 352 | }
|
311 | 353 |
|
312 | 354 | } // namespace NKikimr
|
0 commit comments