Liran
Liran

Reputation: 193

using .net StackExchange.Redis with "wait" isn't working as expected

doing a R/W test with redis cluster (servers): 1 master + 2 slaves. the following is the key WRITE code:

var trans = redisDatabase.CreateTransaction();
Task<bool> setResult = trans.StringSetAsync(key, serializedValue, TimeSpan.FromSeconds(10));
Task<RedisResult> waitResult = trans.ExecuteAsync("wait", 3, 10000);
trans.Execute();
trans.WaitAll(setResult, waitResult);

using the following as the connection string:

[server1 ip]:6379,[server2 ip]:6379,[server3 ip]:6379,ssl=False,abortConnect=False

running 100 threads which do 1000 loops of the following steps:

  1. generate a GUID as key and random as value of 1024 bytes
  2. writing the key (using the above code)
  3. retrieve the key using "var stringValue = redisDatabase.StringGet(key, CommandFlags.PreferSlave);"
  4. compare the two values and print an error if they differ.

running this test a few times generates several errors - trying to understand why as the "wait" with (10 seconds!) operation should have guaranteed the write to all slaves before returning.

Any idea?

Upvotes: 1

Views: 474

Answers (2)

user17075172
user17075172

Reputation: 1

What about improving consistency guarantees, by adding in some "check, write, read" iterations?

  1. SET a new key value pair (master node)
  2. Read it (set CommandFlags to DemandReplica.
  3. Not there yet? Wait and Try X times. 4.a) Not there yet? SET again. go back to (3) or give up 4.b) There? You're "done"

Won't be perfect but it should reduce probability of losing a SET??

Upvotes: 0

Itamar Haber
Itamar Haber

Reputation: 50112

WAIT isn't supported by SE.Redis as explained by its prolific author at Stackexchange.redis lacks the "WAIT" support

Upvotes: 1

Related Questions