From: | Thomas Munro <thomas(dot)munro(at)enterprisedb(dot)com> |
---|---|
To: | Pg Hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | DSM segment handle generation in background workers |
Date: | 2018-10-07 12:17:31 |
Message-ID: | CAEepm=2eJj_6=B+2tEpGu2nf1BjthCf9nXXUouYvJJ4C5WSwhg@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hello,
I noticed that every parallel worker generates the same sequence of
handles here:
/*
* Loop until we find an unused identifier for the new control
segment. We
* sometimes use 0 as a sentinel value indicating that no
control segment
* is known to exist, so avoid using that value for a real control
* segment.
*/
for (;;)
{
Assert(dsm_control_address == NULL);
Assert(dsm_control_mapped_size == 0);
dsm_control_handle = random();
if (dsm_control_handle == DSM_HANDLE_INVALID)
continue;
if (dsm_impl_op(DSM_OP_CREATE, dsm_control_handle, segsize,
&dsm_control_impl_private, &dsm_control_address,
&dsm_control_mapped_size, ERROR))
break;
}
It's harmless AFAICS, but it produces sequences of syscalls like this
when Parallel Hash is building the hash table:
shm_open("/PostgreSQL.240477264",O_RDWR|O_CREAT|O_EXCL,0600) ERR#17
'File exists'
shm_open("/PostgreSQL.638747851",O_RDWR|O_CREAT|O_EXCL,0600) ERR#17
'File exists'
shm_open("/PostgreSQL.1551053007",O_RDWR|O_CREAT|O_EXCL,0600) = 5 (0x5)
That's because the bgworker startup path doesn't contain a call to
srandom(...distinguishing stuff...), unlike BackendRun(). I suppose
do_start_bgworker() could gain a similar call... or perhaps that call
should be moved into InitPostmasterChild(). If we put it in there
right after MyStartTime is assigned a new value, we could use the same
incantation that PostmasterMain() uses.
I noticed that the comment in PostmasterMain() refers to
PostmasterRandom(), which is gone.
--
Thomas Munro
http://www.enterprisedb.com
From | Date | Subject | |
---|---|---|---|
Next Message | Alvaro Herrera | 2018-10-07 14:13:19 | Re: pg_upgrade failed with ERROR: null relpartbound for relation 18159 error. |
Previous Message | Andrew Gierth | 2018-10-07 11:59:18 | Re: Performance improvements for src/port/snprintf.c |