Skip to content

How does executeIsolated impact watched keys? #2613

Open
@jedkass

Description

@jedkass

Description

In your main README, the Transactions (Multi/Exec) gives an example without calling .watch(). Below the example, there is a little blurb that you can first call .watch(), in which case, if any of the watched keys change while executing the transaction, Redis will roll it back. Digging a big further, this blurb also links to Isolated Execution Guide, which differs from the main README in that it calls .watch(). However, before calling .watch(), an isolatedClient is created with the executeIsolated method.

What exactly are the implications of using an isolatedClient? Do we need to use one of these if we are calling .watch() and if so, why? Will a WatchError be thrown if a different connection is used between .watch() and .exec()?

For some background, I'm trying to debug some WatchErrors in my project and am noticing that we aren't using an isolatedClient and am wondering if that is the cause. I don't see any logs (or code paths) that would indicate that the watched keys are being changed after being watched:

try {
  await this.client.watch(key);
  await this.client
    .multi()
    .hSet(key, some_value)
    .expire(key, some_expiration)
    .exec();
}
catch (e) {
  if (e instanceof WatchError) {
    // seeing this block get hit often
  }

  throw e;
}

Thanks for any help you can provide here!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions