Skip to content

BlockingRedisDataSourceImpl doesn't call DISCARD if consumer function throws an exception #49531

@Ladicek

Description

@Ladicek

Discussed in #49436

Originally posted by luca-bassoricci August 8, 2025
In BlockingRedisDataSourceImpl#withTransaction() if the call to BiConsumer<I, TransactionalRedisDataSource> tx throws an exception DISCARD command is not issued left redis in a stale state.
Is this the expected flow?
Would be a good idea to try/catch tx.accept() call and send DISCARD from BlockingRedisDataSourceImpl#withTransaction() if TransactionalRedisDataSource#discard() has not been called?

Pseudo

try {
  tx.accept(t, u);
}
catch (Throwable e)  {
  if(!u.discarded())  {
    u.discard();
  }
}

Looking at ReactiveRedisDataSourceImpl it sends a DISCARD command in case of failure.

Thanks
Luca.

Metadata

Metadata

Assignees

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions