Skip to content

"Nested batches are not supported" with Pipeline and Json.SetAsync #401

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
concueror opened this issue Mar 19, 2025 · 1 comment · Fixed by #402
Closed

"Nested batches are not supported" with Pipeline and Json.SetAsync #401

concueror opened this issue Mar 19, 2025 · 1 comment · Fixed by #402
Assignees
Labels
bug Something isn't working

Comments

@concueror
Copy link

Using NUnit.

`
var db = _redis.GetDatabase();

    var pipeline = new Pipeline(db);
    
    var setTask = 
        pipeline.Json.SetAsync(key, "$", value, when);
    _ = pipeline.Db.KeyExpireAsync(key, ttl);
    
    pipeline.Execute();
    
    return await setTask;

`

Exception:
System.NotSupportedException : Nested batches are not supported at StackExchange.Redis.RedisDatabase.CreateBatch(Object asyncState) in /_/src/StackExchange.Redis/RedisDatabase.cs:line 24 at NRedisStack.Pipeline..ctor(IDatabase db) at NRedisStack.Auxiliary.SetInfoInPipeline(IDatabase db) at NRedisStack.Auxiliary.ExecuteAsync(IDatabaseAsync db, SerializedCommand command) at NRedisStack.JsonCommandsAsync.SetAsync(RedisKey key, RedisValue path, RedisValue json, When when)

Going to NRedisStack.Auxiliary, here is creating new pipeline (and new batch inside it):

Image

So getting "System.NotSupportedException : Nested batches are not supported"

@atakavci
Copy link
Collaborator

hi @concueror , thanks for using NRedisStack and reporting the issue.

as i see this is caused when the first command using db is in a pipeline and it attempts to set some info on connection. I will explore how to solve it.

Meanwhile could you try to follow this as a workaround;

  1. send an initial command on db object without a pipeline (this will set up the info on conn)
  2. then use the pipeline as you need with same db object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants