Skip to content
Browse files

Making sure that when using read striping, we never read the hilo fro…

…m the secondary servers
  • Loading branch information...
1 parent 4ef9d89 commit 7d4d6e12d2e00c5a9409ef58ef914f13b5a0f20c @ayende ayende committed
View
3 Raven.Client.Embedded/EmbeddedDatabaseCommands.cs
@@ -547,9 +547,10 @@ public IDatabaseCommands With(ICredentials credentialsForSession)
/// <summary>
/// Force the database commands to read directly from the master, unless there has been a failover.
/// </summary>
- public void ForceReadFromMaster()
+ public IDisposable ForceReadFromMaster()
{
// nothing to do, there is no replication for embedded
+ return null;
}
/// <summary>
View
13 Raven.Client.Lightweight/Connection/CreateHttpJsonRequestParams.cs
@@ -14,18 +14,6 @@
namespace Raven.Client.Connection
{
- public static class HttpCacheSettings
- {
- [ThreadStatic]static internal bool avoidCachingRequest;
-
- public static IDisposable AvoidUsingTheCacheForRequestsInThisScope()
- {
- var old = avoidCachingRequest;
- avoidCachingRequest = true;
- return new DisposableAction(() => avoidCachingRequest = old);
- }
- }
-
public class CreateHttpJsonRequestParams
{
public CreateHttpJsonRequestParams(IHoldProfilingInformation self, string url, string method, RavenJObject metadata, ICredentials credentials, DocumentConvention convention)
@@ -37,7 +25,6 @@ public CreateHttpJsonRequestParams(IHoldProfilingInformation self, string url, s
Credentials = credentials;
Convention = convention;
operationsHeadersCollection = new NameValueCollection();
- AvoidCachingRequest = HttpCacheSettings.avoidCachingRequest;
}
/// <summary>
View
2 Raven.Client.Lightweight/Connection/IDatabaseCommands.cs
@@ -407,7 +407,7 @@ public interface IDatabaseCommands : IHoldProfilingInformation
/// <summary>
/// Force the database commands to read directly from the master, unless there has been a failover.
/// </summary>
- void ForceReadFromMaster();
+ IDisposable ForceReadFromMaster();
/// <summary>
/// Get the low level bulk insert operation
View
4 Raven.Client.Lightweight/Connection/ServerClient.cs
@@ -1212,9 +1212,11 @@ public ILowLevelBulkInsertOperation GetBulkInsertOperation(BulkInsertOptions opt
/// <summary>
/// Force the database commands to read directly from the master, unless there has been a failover.
/// </summary>
- public void ForceReadFromMaster()
+ public IDisposable ForceReadFromMaster()
{
+ var old = readStripingBase;
readStripingBase = -1;// this means that will have to use the master url first
+ return new DisposableAction(() => readStripingBase = old);
}
/// <summary>
View
2 Raven.Client.Lightweight/Document/HiLoKeyGenerator.cs
@@ -68,7 +68,7 @@ public long NextId(IDatabaseCommands commands)
private RangeValue GetNextRange(IDatabaseCommands databaseCommands)
{
using (new TransactionScope(TransactionScopeOption.Suppress))
- using (HttpCacheSettings.AvoidUsingTheCacheForRequestsInThisScope())
+ using (databaseCommands.ForceReadFromMaster())
{
ModifyCapacityIfRequired();
while (true)
View
2 Raven.Tests/Bundles/Replication/Bugs/HiLoHanging.cs
@@ -16,7 +16,7 @@ public void HiLo_Modified_InReplicated_Scenario()
{
const string key = "Raven/Hilo/managers";
- var store1 = CreateStore();
+ var store1 = CreateStore(configureStore: store => store.Conventions.FailoverBehavior = FailoverBehavior.ReadFromAllServers);
var store2 = CreateStore();
TellFirstInstanceToReplicateToSecondInstance();

0 comments on commit 7d4d6e1

Please sign in to comment.
Something went wrong with that request. Please try again.