edis.clients.jedis.exceptions.JedisDataException: Please close pipeline or multi block before calling this method

By Ankit Gupta

I am batching some commands using pipelining and I sync them with a timer.

Scenario:

  1. Pipeline commands to redis (in process() method)
  2. JedisConnectionException occurs (inside flush(), return Jedis resource)
  3. Pipeline new commands by re-using the same pipeline with pipeline.setClient(mJedis)
  4. On performing sync() on the pipeline, Jedis throws the below exception
    redis.clients.jedis.exceptions.JedisDataException: Please close pipeline or multi block before calling this method.

Code:

    void process() {
        mPipeline.evalsha(...);
        // other application code
    }
    // Timer based flush
    void flush() {
        if (mJedis == null) {
            mJedis = sJedisPool.getResource();
            mPipeline.setClient(mJedis);
        }
        try {
            mPipeline.sync();
        } catch (JedisException je) {
            mJedis.close();
            mJedis = null;
        }
    }

I do not want to lose the already pipelined commands, so i do not do mPipeline=mJedis.pipelined() inside flush()

Is there a way to queue the earlier pipelined commands during JedisConnectionException?

Source: Stack Overflow

    

Share it with your friends!

    Fatal error: Uncaught Exception: 12: REST API is deprecated for versions v2.1 and higher (12) thrown in /home/content/19/9652219/html/wp-content/plugins/seo-facebook-comments/facebook/base_facebook.php on line 1273