StackExchange.Redis icon indicating copy to clipboard operation
StackExchange.Redis copied to clipboard

threads hanging on production when using transaction

Open pianoman4873 opened this issue 10 months ago • 0 comments

Hello, I have a synchronous method which does the following -

var transaction = _connectionMultiplexer.GetDatabase(0).CreateTransaction();

var returnValueTask = transaction.HashSetAsync(key, KeyValuePairsToHashEntries(keyValuePairs));

transaction.KeyExpireAsync(key, expiry);

var success = transaction.Commit(); if (!success) throw new Exception("transaction failed");

return returnValueTask.Result;

I've load tested it locally (100 threads doing the same to either the same key or different keys ) everything seems to be working fine, but we've seen in production env that pretty frequently the transactions don't seem to complete ( or take very long to complete ).

Am I doing something wrong in the code ? ( other than the method being synchronous which is a prerequisite ). Could you suggest an alternative to simulate atomic writing of both the hash and the expiry ?

Thanks in advance !

pianoman4873 avatar Apr 10 '24 14:04 pianoman4873