@@ -200,7 +200,8 @@ export class PgIpLock implements AnyLock {
200200 ) ON CONFLICT (id) DO
201201 UPDATE SET app = ${ PgIpLock . schemaName } .deadlock_check(
202202 ${ PgIpLock . schemaName } .lock.app,
203- ${ literal ( this . options . pgClient . appName ) }
203+ ${ literal ( this . options . pgClient . appName ) } ,
204+ NOW()
204205 )
205206 ` ) ;
206207 }
@@ -213,15 +214,16 @@ export class PgIpLock implements AnyLock {
213214 private async acquireChannelLock ( ) : Promise < void > {
214215 // noinspection SqlResolve
215216 await this . options . pgClient . query ( `
216- INSERT INTO ${ PgIpLock . schemaName } .lock (channel, app)
217- VALUES (
218- ${ literal ( this . channel ) } ,
219- ${ literal ( this . options . pgClient . appName ) }
220- ) ON CONFLICT (channel) DO
221- UPDATE SET app = ${ PgIpLock . schemaName } .deadlock_check(
222- ${ PgIpLock . schemaName } .lock.app,
223- ${ literal ( this . options . pgClient . appName ) }
224- )
217+ INSERT INTO ${ PgIpLock . schemaName } .lock (channel, app)
218+ VALUES (
219+ ${ literal ( this . channel ) } ,
220+ ${ literal ( this . options . pgClient . appName ) }
221+ ) ON CONFLICT (channel) DO
222+ UPDATE SET app = ${ PgIpLock . schemaName } .deadlock_check(
223+ ${ PgIpLock . schemaName } .lock.app,
224+ ${ literal ( this . options . pgClient . appName ) } ,
225+ NOW()
226+ )
225227 ` ) ;
226228 }
227229
@@ -432,7 +434,9 @@ export class PgIpLock implements AnyLock {
432434 await this . options . pgClient . query ( `
433435 CREATE OR REPLACE FUNCTION ${ PgIpLock . schemaName } .deadlock_check(
434436 old_app TEXT,
435- new_app TEXT)
437+ new_app TEXT,
438+ time TIMESTAMP WITH TIME ZONE
439+ )
436440 RETURNS TEXT LANGUAGE PLPGSQL AS $$
437441 DECLARE num_apps INTEGER;
438442 BEGIN
0 commit comments