Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -211,27 +211,36 @@ public async Task TestTransactionFromAnotherClientThrows()
[Test]
public async Task TestReadOnlyTxSeesOldDataAfterUpdate([Values(true, false)] bool readBeforeUpdate)
{
// TODO IGNITE-26619 Implicit client ro tx does not include observableTimestamp - remove workaround below.
// Use single-node connection to work around causality issues due to round-robin in GetNextSocketWithoutReconnect.
var cfg = GetConfig();
cfg.Endpoints.Clear();
cfg.Endpoints.Add($"127.0.0.1:{ServerPort}");

using var client = await IgniteClient.StartAsync(cfg);
var recordView = (await client.Tables.GetTableAsync(TableName))!.GetRecordView<Poco>();

var key = Random.Shared.NextInt64(1000, long.MaxValue);
var keyPoco = new Poco { Key = key };

await PocoView.UpsertAsync(null, new Poco { Key = key, Val = "11" });
await recordView.UpsertAsync(null, new Poco { Key = key, Val = "11" });

await using var roTx = await Client.Transactions.BeginAsync(new TransactionOptions { ReadOnly = true });
await using var roTx = await client.Transactions.BeginAsync(new TransactionOptions { ReadOnly = true });

if (readBeforeUpdate)
{
Assert.AreEqual("11", (await PocoView.GetAsync(roTx, keyPoco)).Value.Val);
Assert.AreEqual("11", (await recordView.GetAsync(roTx, keyPoco)).Value.Val);
}

// Update data in a different (implicit) tx.
await PocoView.UpsertAsync(transaction: null, new Poco { Key = key, Val = "22" });
await recordView.UpsertAsync(transaction: null, new Poco { Key = key, Val = "22" });

// Old read-only tx sees old data.
Assert.AreEqual("11", (await PocoView.GetAsync(roTx, keyPoco)).Value.Val);
Assert.AreEqual("11", (await recordView.GetAsync(roTx, keyPoco)).Value.Val);

// New tx sees new data
await using var tx3 = await Client.Transactions.BeginAsync(new TransactionOptions { ReadOnly = true });
Assert.AreEqual("22", (await PocoView.GetAsync(tx3, keyPoco)).Value.Val);
await using var tx3 = await client.Transactions.BeginAsync(new TransactionOptions { ReadOnly = true });
Assert.AreEqual("22", (await recordView.GetAsync(tx3, keyPoco)).Value.Val);
}

[Test]
Expand Down