@ -177,6 +177,10 @@ ReplicationSlotInitialize(void)
static void
static void
ReplicationSlotShmemExit ( int code , Datum arg )
ReplicationSlotShmemExit ( int code , Datum arg )
{
{
/* temp debugging aid to analyze 019_replslot_limit failures */
elog ( DEBUG3 , " replication slot exit hook, %s active slot " ,
MyReplicationSlot ! = NULL ? " with " : " without " ) ;
/* Make sure active replication slots are released */
/* Make sure active replication slots are released */
if ( MyReplicationSlot ! = NULL )
if ( MyReplicationSlot ! = NULL )
ReplicationSlotRelease ( ) ;
ReplicationSlotRelease ( ) ;
@ -554,6 +558,9 @@ ReplicationSlotCleanup(void)
Assert ( MyReplicationSlot = = NULL ) ;
Assert ( MyReplicationSlot = = NULL ) ;
restart :
restart :
/* temp debugging aid to analyze 019_replslot_limit failures */
elog ( DEBUG3 , " temporary replication slot cleanup: begin " ) ;
LWLockAcquire ( ReplicationSlotControlLock , LW_SHARED ) ;
LWLockAcquire ( ReplicationSlotControlLock , LW_SHARED ) ;
for ( i = 0 ; i < max_replication_slots ; i + + )
for ( i = 0 ; i < max_replication_slots ; i + + )
{
{
@ -579,6 +586,8 @@ restart:
}
}
LWLockRelease ( ReplicationSlotControlLock ) ;
LWLockRelease ( ReplicationSlotControlLock ) ;
elog ( DEBUG3 , " temporary replication slot cleanup: done " ) ;
}
}
/*
/*
@ -1284,6 +1293,12 @@ InvalidatePossiblyObsoleteSlot(ReplicationSlot *s, XLogRecPtr oldestLSN,
( void ) kill ( active_pid , SIGTERM ) ;
( void ) kill ( active_pid , SIGTERM ) ;
last_signaled_pid = active_pid ;
last_signaled_pid = active_pid ;
}
}
else
{
/* temp debugging aid to analyze 019_replslot_limit failures */
elog ( DEBUG3 , " not signalling process %d during invalidation of slot \" %s \" " ,
active_pid , NameStr ( slotname ) ) ;
}
/* Wait until the slot is released. */
/* Wait until the slot is released. */
ConditionVariableSleep ( & s - > active_cv ,
ConditionVariableSleep ( & s - > active_cv ,
@ -1347,6 +1362,10 @@ InvalidateObsoleteReplicationSlots(XLogSegNo oldestSegno)
XLogSegNoOffsetToRecPtr ( oldestSegno , 0 , wal_segment_size , oldestLSN ) ;
XLogSegNoOffsetToRecPtr ( oldestSegno , 0 , wal_segment_size , oldestLSN ) ;
restart :
restart :
/* temp debugging aid to analyze 019_replslot_limit failures */
elog ( DEBUG3 , " begin invalidating obsolete replication slots older than %X/%X " ,
LSN_FORMAT_ARGS ( oldestLSN ) ) ;
LWLockAcquire ( ReplicationSlotControlLock , LW_SHARED ) ;
LWLockAcquire ( ReplicationSlotControlLock , LW_SHARED ) ;
for ( int i = 0 ; i < max_replication_slots ; i + + )
for ( int i = 0 ; i < max_replication_slots ; i + + )
{
{
@ -1372,6 +1391,8 @@ restart:
ReplicationSlotsComputeRequiredLSN ( ) ;
ReplicationSlotsComputeRequiredLSN ( ) ;
}
}
elog ( DEBUG3 , " done invalidating obsolete replication slots " ) ;
return invalidated ;
return invalidated ;
}
}