Skip to content

Commit

Permalink
RavenDB-21993 - fix so changes api connection doesn't get disposed on…
Browse files Browse the repository at this point in the history
… "no reply for operation", only a database not exists error. added test. moved tests.
  • Loading branch information
lastav5 committed May 2, 2024
1 parent 1eeb2c4 commit 40827ca
Show file tree
Hide file tree
Showing 4 changed files with 617 additions and 395 deletions.
11 changes: 8 additions & 3 deletions src/Raven.Client/Documents/Operations/Operation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Raven.Client.Documents.Conventions;
using Raven.Client.Exceptions;
using Raven.Client.Exceptions.Changes;
using Raven.Client.Exceptions.Database;
using Raven.Client.Extensions;
using Raven.Client.Http;
using Raven.Client.Util;
Expand Down Expand Up @@ -115,15 +116,19 @@ protected virtual async Task Process()
var observable = changes.ForOperationId(_id);
_subscription = observable.Subscribe(this);
await observable.EnsureSubscribedNow().ConfigureAwait(false);


if (_requestExecutor.ForTestingPurposes?.WaitBeforeFetchOperationStatus != null)
_requestExecutor.ForTestingPurposes.WaitBeforeFetchOperationStatus.Wait();

// We start the operation before we subscribe,
// so if we subscribe after the operation was already completed we will miss the notification for it.
await FetchOperationStatus().ConfigureAwait(false);
}
catch
catch(DatabaseDoesNotExistException)
{
// If the websocket connection failed, we need to remove it from the dictionary
// If the websocket connection failed fatally, we need to remove it from the dictionary
// so we won't attempt to reuse it in the next call to the same node
// DatabaseDoesNotExistException is the only exception that should cause the websocket to stop trying to reconnect in DoWork
changes?.Dispose();
throw;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Raven.Client/Http/RequestExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2453,6 +2453,8 @@ internal TestingStuff(RequestExecutor requestExecutor)
internal Action DelayRequest;

internal Action<GetDatabaseTopologyCommand> SetCommandTimeout;

public ManualResetEventSlim WaitBeforeFetchOperationStatus;
}
}
}

0 comments on commit 40827ca

Please sign in to comment.