typeorm-transactional-cls-hooked icon indicating copy to clipboard operation
typeorm-transactional-cls-hooked copied to clipboard

When i use Propagation.NESTED, serializable not work

Open GuihaiHU opened this issue 5 years ago • 1 comments

I write a method A with transaction SERIALIZABLE in my code, and it works as my expect. However, When I add another method B with transaction Propagation.NESTED, and A calls B. I found the transaction A not work like SERIALIZABLE. This is my code.

 @Transactional({ isolationLevel: IsolationLevel.SERIALIZABLE })
  async addUserScoreAuto(user: AuthUser) {
    await this.service.findOrCreate({ userId: user.id });
  }
 @Transactional({ propagation: Propagation.NESTED })
  async findOrCreate(info: DeepPartial<T>): Promise<[T, boolean]> {
    const entity = await this.repo.findOne(info);
    if (!entity) {
      return [await this.repo.save(info), true];
    }
    return [entity, false];
  }

GuihaiHU avatar Apr 07 '20 12:04 GuihaiHU

any news?

xfishernet avatar Jun 15 '22 19:06 xfishernet