Re: [HACKERS] max backends checking patch - Mailing list pgsql-hackers

From Vadim Mikheev
Subject Re: [HACKERS] max backends checking patch
Date
Msg-id 3698B980.EB62133A@krs.ru
Whole thread Raw
In response to max backends checking patch  (Tatsuo Ishii <t-ishii@sra.co.jp>)
Responses Re: [HACKERS] max backends checking patch  (Tatsuo Ishii <t-ishii@sra.co.jp>)
List pgsql-hackers
Tatsuo Ishii wrote:
> 
> As of 6.4.2 (and snapshot, I guess), postmaser does not check if the
> number of backends exceeds MaxBackendId (defined in
> include/storage/sinvaladt.h). As a result (MaxBackendId+1)th backend
> gets started but failed in the middle of its initialising process.
> Typical error would be:
> 
> NOTICE:  SIAssignBackendId: discarding tag 2147430138
> Connection databese 'request' failed.
> FATAL 1:  Backend cache invalidation initialization failed
> 
> Then postmaster decides to re-initialize the shared memory and all
> running backends are killed. Too bad.
> 
> Attached patches try to fix the problem.


Couldn't postmaster just keep # of backends running
in some variable, instead of examining BackendList ?


> + /*
> +  * Count up number of chidren processes.
> +  */
> + static int
> + CountChildren(void)
> + {
> +       Dlelem     *curr,
> +                          *next;
> +       Backend    *bp;
> +       int                     mypid = getpid();
> +       int     cnt = 0;
> +
> +       curr = DLGetHead(BackendList);
> +       while (curr)
> +       {
> +               next = DLGetSucc(curr);
> +               bp = (Backend *) DLE_VAL(curr);
> +
> +               if (bp->pid != mypid)
> +               {
> +                       cnt++;
> +               }
> +
> +               curr = next;
> +       }
> +       return(cnt);
>   }

Vadim


pgsql-hackers by date:

Previous
From: Tatsuo Ishii
Date:
Subject: max backends checking patch
Next
From: Tatsuo Ishii
Date:
Subject: Re: [HACKERS] max backends checking patch