redis/redis-rb · error · Redis::BaseError

Can't nest multi transaction

Error message

Can't nest multi transaction

What it means

Error "Can't nest multi transaction" thrown in redis/redis-rb.

Source

Thrown at lib/redis/pipeline.rb:61

        future._set(result)
      end
      @futures << future
      future
    end

    def send_blocking_command(command, timeout, &block)
      future = Future.new(command, block, @exception)
      @pipeline.blocking_call_v(timeout, command) do |result|
        future._set(result)
      end
      @futures << future
      future
    end
  end

  class MultiConnection < PipelinedConnection
    def multi
      raise Redis::BaseError, "Can't nest multi transaction"
    end

    private

    # Blocking commands inside transaction behave like non-blocking.
    # It shouldn't be done though.
    # https://redis.io/commands/blpop/#blpop-inside-a-multi--exec-transaction
    def send_blocking_command(command, _timeout, &block)
      send_command(command, &block)
    end
  end

  class FutureNotReady < RuntimeError
    def initialize
      super("Value will be available once the pipeline executes.")
    end
  end

View on GitHub (pinned to 2ba9010b91)

Solutions

  1. Do not call multi inside an already-open multi block; flatten the transaction into a single multi block.
  2. Refactor nested helper methods so only the outermost one opens the transaction.

When it happens

Trigger: Thrown at lib/redis/pipeline.rb:61 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of redis/redis-rb@2ba9010b91 (2026-08-23). Data as JSON: /api/errors/c8d98f40503d7d91. Report an issue: GitHub.