Skip to content

Commit

Permalink
pg.Pool 해결 시도
Browse files Browse the repository at this point in the history
  • Loading branch information
tirr-c committed Mar 24, 2024
1 parent f84e22e commit 6e52380
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/model/model.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import * as Bunyan from 'bunyan';
import * as pg from 'pg';
import { DatabaseError, Pool } from 'pg';
import type { PoolConfig } from 'pg';
import type Config from '../config.js';
import EmailAddresses from './email_addresses.js';
import { ControllableError } from './errors.js';
Expand All @@ -25,12 +26,12 @@ export default class Model {
public readonly hosts: Hosts;
public readonly oauth: OAuth;

private readonly pgConfig: pg.PoolConfig;
private readonly pgPool: pg.Pool;
private readonly pgConfig: PoolConfig;
private readonly pgPool: Pool;

constructor(public readonly config: Config, public readonly log: Bunyan) {
this.pgConfig = config.postgresql;
this.pgPool = new pg.Pool(this.pgConfig);
this.pgPool = new Pool(this.pgConfig);

this.users = new Users(this);
this.emailAddresses = new EmailAddresses();
Expand Down Expand Up @@ -75,7 +76,7 @@ export default class Model {
} catch (e) {
await client.query('ROLLBACK');

if (e instanceof pg.DatabaseError) {
if (e instanceof DatabaseError) {
if (e.code === PSQL_SERIALIZATION_FAILURE || e.code === PSQL_DEADLOCK_DETECTED) {
retryCount++;
if (retryCount < Model.MAX_TRANSACTION_RETRY) {
Expand Down

0 comments on commit 6e52380

Please sign in to comment.