concurrency - Interleaving Watch Multi/exec on a single Redis connection. Expected or weird behavior? -


View the front of the app where every request shares the same reads connection, which I believe is Recommended method (?).

In this situation, I believe that I am seeing some weird clock multi / exec behavior, I hope optimistic locking failure (ie: clock guard) fails in one of the two transactions due to it, but both start throwing without the charge of an angry, but as a result the final final value is found. / P>

To see the approximate scenario described below. It is in the node, but I believe this is a normal thing. It runs 2 processes in parallel, which both update to a counter. (It basically implements the canonical example of the clock seen as.

The expected result is 1 result of the first process in a increment of 1, while the second is for updating and returns Null Instead, the result is that both processes update the counter with 1. Although a stale is based on the counter, it eventually increases with 1 instead of counter 2.

  // note: db The node is the promisified version of the redis, but it does not really make a difference db = source.app.repos.redis._raw; Promise.all (_ to lower ([1, 2], function (arrival, val) { Db.watch ("incr"); var p = Promise.resolve () then (function () {return db.get ("incr");}) then (function (val) {// say 'val' Console 'log' for both processes 'return'; val ++; db.multi (); db.set ("incr", val); db.exec return ();}) th n (function (ResultsSoldBallAustlastAnces) {console.log (Results Result Operator once); Return; // Explain and} }; Arr.push (p); return arr;}, [])). Next (undefined);}  
.6,35,833 [0 127.0.0.1:60979] "clock" "incr" 14144 9 1001.635, 9 36 [0 127.0.0.1:60979] "clock" "incr" 14144 9 1001.6,36,225 [0 127.0.0.1: 60 9 7 9] "Received" "Ink" 1414491001.636242 [0 127.0.0.1:60 9 7] "Go" "incr" 1414491001.636533 [0 127.0.0.1:60 9 7] "Multi" 1414491001636723 [ 0 127.0.0.1:60 9 7] "set" "incr" "5" 14144 9 1001.6,36,737 [0 127.0.0.1:60979] "Executive" 14144 9 1001.63 9, 660 [0 127.0.0.1:60979 ] "Multi" 14144 9 1001.6, 9, 691 [0 127.0.0.1:60979] "set" "incr" "5" 14144 9 1001.6.3 9, 704 [0 127.0. 0.1: 60 9 7] "exec"

Is this expected behavior? Can many redesign connections be used on this issue?

To answer my own question:

This is the expected behavior first exec unaltered all the properties. Therefore, the second multi / exec goes without the guard-guard.

In it, but it is quite hidden

Solution: Use a lot of connections, despite the obvious answer on it, the warning clearly, because it's (quote) There should be no need ' This situation requires IT


Comments

Popular posts from this blog

java - Can't add JTree to JPanel of a JInternalFrame -

javascript - data.match(var) not working it seems -

javascript - How can I pause a jQuery .each() loop, while waiting for user input? -