Skip to content

Commit

Permalink
RavenDB-21653 : fix flaky test - fix race between updating compare ex…
Browse files Browse the repository at this point in the history
…change value in one session and querying with compare exchange includes in a different session - wait for last cluster transaction index before the query
  • Loading branch information
aviv86 committed Nov 30, 2023
1 parent fac5eff commit 837952a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions test/SlowTests/Issues/RavenDB_14006.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using FastTests;
Expand Down Expand Up @@ -412,7 +413,7 @@ public void CanUseCompareExchangeValueIncludesInQueries_Dynamic()
}

[Fact]
public void CanUseCompareExchangeValueIncludesInQueries_Dynamic_JavaScript()
public async Task CanUseCompareExchangeValueIncludesInQueries_Dynamic_JavaScript()
{
using (var store = GetDocumentStore())
{
Expand Down Expand Up @@ -476,14 +477,20 @@ select incl(c)"
Assert.Equal(-1, stats.DurationInMs); // from cache
Assert.Equal(resultEtag, stats.ResultEtag);

long lastClusterTxIndex;
var database = await Databases.GetDocumentDatabaseInstanceFor(store);

using (var innerSession = store.OpenSession(new SessionOptions { TransactionMode = TransactionMode.ClusterWide }))
{
var value = innerSession.Advanced.ClusterTransaction.GetCompareExchangeValue<Address>(companies[0].ExternalId);
value.Value.City = "Bydgoszcz";

innerSession.SaveChanges();
lastClusterTxIndex = value.Index;
}

await database.RachisLogIndexNotifications.WaitForIndexNotification(lastClusterTxIndex, TimeSpan.FromSeconds(5));

companies = companies = session.Advanced
.RawQuery<Company>(
@"
Expand Down

0 comments on commit 837952a

Please sign in to comment.