Dead code or buggy code? - Mailing list pgsql-hackers

From Greg Stark
Subject Dead code or buggy code?
Date
Msg-id CAM-w4HOySQ4p3MVBFS4C0=3+KQ1AJDJ-Oi-62=aNTFB7AJGXfg@mail.gmail.com
Whole thread Raw
Responses Re: Dead code or buggy code?
List pgsql-hackers
The following code is in the ProcSleep at proc.c:1138.
GetBlockingAutoVacuumPgproc() should presumably always return a vacuum
pgproc entry since the deadlock state says it's blocked by autovacuum.
But I'm not really familiar enough with this codepath to know whether
there's not a race condition here where it can sometimes return null.
The following code checks autovac != NULL but the PGXACT initializer
would have seg faulted if it returned NULL if that's possible.
       if (deadlock_state == DS_BLOCKED_BY_AUTOVACUUM &&
allow_autovacuum_cancel)       {           PGPROC       *autovac = GetBlockingAutoVacuumPgproc();           PGXACT
*autovac_pgxact =
 
&ProcGlobal->allPgXact[autovac->pgprocno];
           LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
           /*            * Only do it if the worker is not working to protect against Xid            * wraparound.
     */           if ((autovac != NULL) &&               (autovac_pgxact->vacuumFlags & PROC_IS_AUTOVACUUM) &&
    !(autovac_pgxact->vacuumFlags & PROC_VACUUM_FOR_WRAPAROUND))           {
 


-- 
greg



pgsql-hackers by date:

Previous
From: Hannu Krosing
Date:
Subject: Re: record identical operator
Next
From: Noah Misch
Date:
Subject: Re: relscan_details.h