Добрый день!
Зависают запросы и из-за этого нельзя произвести какое-либо действие на сайте.
У меня на сервере организованы транзакции
const connection = getConnection()
const queryRunner = connection.createQueryRunner()
await queryRunner.connect()
await queryRunner.startTransaction()
try {
await queryRunner.commitTransaction()
} catch (e) {
await queryRunner.rollbackTransaction()
} finally {
await queryRunner.release()
}
При запросе
SELECT * FROM pg_stat_activity WHERE state = 'active';
Висят постоянно одно и тоже, все одинаковые и их штук 8
spoiler
16384 testbase 25447 10 testbase 172.18.0.5 41262 2020-06-27 18:38:18.768562+00 2020-06-27 18:38:18.795934+00 2020-06-27 18:38:18.819928+00 2020-06-27 18:38:18.819929+00 Lock tuple active 9425627 SELECT "FreeGameEntity"."id" AS "FreeGameEntity_id", "FreeGameEntity"."type" AS "FreeGameEntity_type", "FreeGameEntity"."name" AS "FreeGameEntity_name", "FreeGameEntity"."title" AS "FreeGameEntity_title", "FreeGameEntity"."image" AS "FreeGameEntity_image", "FreeGameEntity"."items" AS "FreeGameEntity_items", "FreeGameEntity"."games" AS "FreeGameEntity_games", "FreeGameEntity"."status" AS "FreeGameEntity_status", "FreeGameEntity"."lvls" AS "FreeGameEntity_lvls", "FreeGameEntity"."description" AS "FreeGameEntity_description", "FreeGameEntity"."time_limit" AS "FreeGameEntity_time_limit", "FreeGameEntity"."players" AS "FreeGameEntity_players", "FreeGameEntity"."player" AS "FreeGameEntity_player", "FreeGameEntity"."winner" AS "FreeGameEntity_winner", "FreeGameEntity"."winner_amount" AS "FreeGameEntity_winner_amount", "FreeGameEntity"."created_at" AS "FreeGameEntity_created_at" FROM "free_games" "FreeGameEntity" WHERE title = $1 FOR UPDATE client backend
Код получение данных
const c = await query.manager
.getRepository(FreeGameEntity)
.createQueryBuilder()
.useTransaction(true)
.setLock('pessimistic_write')
.where('title = :title', {title: this.opts.gameName})
.getOne()
Как можно исправить данную проблему?