GithubHelp home page GithubHelp logo

Comments (3)

ebernhardson avatar ebernhardson commented on June 15, 2024

Also wanted to note that if i add run the commands from top of that example:

SELECT 15
ZADD zset 1 a
ZADD zset 2 b
ZADD zset 3 c

I can run the script 3 times without error, the 4th time when zset is empty the error occurs

from predis.

ebernhardson avatar ebernhardson commented on June 15, 2024

One more note to add, If you switch the client profile from dev to 2.0 in the example, the error is also 'DISCARD without MULTI'. I have a feeling the fix for the bug above will also fix this one, but basically the error that should have been output is 'The current profile does not support WATCH and UNWATCH commands'

from predis.

nrk avatar nrk commented on June 15, 2024

Thanks for the detailed report, this is a nasty bug introduced with commit cdfd0b9 while I was trying to fix other weird issues with Predis\MultiExecContext in a couple of corner cases (it slipped through simply because this particular case doesn't seem to be covered by the test suite).

A quick explanation of the cause: DISCARD is automatically used by Predis in order to reset a transaction if client-side errors occur during a MULTI/EXEC, but this is wrong if the exception occur before MULTI when using check-and-set operations since DISCARD will not work and the server will return a DISCARD without MULTI error. Also, Predis tries to avoid sending MULTI if there are no pending commands (empty transaction), but when using check-and-set we still need to reset pending WATCH__ed keys, but again it was using __DISCARD to do that.

I implemented a fix (see commit 85c1a7a) that uses UNWATCH instead of DISCARD for the two cases mentioned above. For empty transactions it is probably better to just fire an EXEC, this will reduce useless complexity. This is a clear evidence of the fact that Predis\MultiExecContext definitely needs some heavy refactoring before releasing Predis 0.7.0 as stable.

Thanks again for the bug report!

from predis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.