Initializing LWLock Array from Server Code

Поиск
Список
Период
Сортировка
От Souvik Bhattacherjee
Тема Initializing LWLock Array from Server Code
Дата
Msg-id CAANrPSd+4=3dwvTz=_wW=hbF_LVB7wfS3FzSLzu5UfdifXSmNg@mail.gmail.com
обсуждение исходный текст
Список pgsql-hackers
Hi,

I have created a shared hash table in partitioned mode inside the postgres server code. In order to guard the partitions, I'm trying to initialize an array of LWLocks. The code that I'm trying to use for that is

void RequestNamedLWLockTranche(const char *tranche_name, int num_lwlocks);
LWLockPadded *GetNamedLWLockTranche(const char *tranche_name);

I'm not sure where exactly should this code be called from the server code. So I had placed it in

void CreateSharedMemoryAndSemaphores(bool makePrivate, int port);

within ipic.c. However, I'm getting the following error message when starting the database:

FATAL:  requested tranche is not registered

So at this point, I'm a little confused as to where the methods should be called from inside the server code. Any pointers would be appreciated.

Thanks,
-SB

PS: I saw that that are two variables controlling access to RequestNamedLWLockTranche()

  return; /* too late */

which implies that IsUnderPostmaster must be false and lock_named_request_allowed should be true. Thus, I had invoked RequestNamedLWLockTranche before the first call to LWLockShmemSize which sets lock_named_request_allowed = true and  GetNamedLWLockTranche later. This works in the single user mode but fails when I start the server explicitly through postgres -D ...

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Justin Pryzby
Дата:
Сообщение: Re: clean up docs for v12
Следующее
От: Andres Freund
Дата:
Сообщение: Re: Regression test PANICs with master-standby setup on same machine