From 3fed417452b226d9bd85a3a54d7056b06eb14897 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Tue, 15 Dec 2015 11:32:13 -0500 Subject: Provide a way to predefine LWLock tranche IDs. It's a bit cumbersome to use LWLockNewTrancheId(), because the returned value needs to be shared between backends so that each backend can call LWLockRegisterTranche() with the correct ID. So, for built-in tranches, use a hard-coded value instead. This is motivated by an upcoming patch adding further built-in tranches. Andres Freund and Robert Haas --- src/backend/access/transam/xlog.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/backend/access/transam/xlog.c') diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 71fc8ffa272..147fd538d2f 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -512,7 +512,6 @@ typedef struct XLogCtlInsert */ WALInsertLockPadded *WALInsertLocks; LWLockTranche WALInsertLockTranche; - int WALInsertLockTrancheId; } XLogCtlInsert; /* @@ -4653,7 +4652,7 @@ XLOGShmemInit(void) /* Initialize local copy of WALInsertLocks and register the tranche */ WALInsertLocks = XLogCtl->Insert.WALInsertLocks; - LWLockRegisterTranche(XLogCtl->Insert.WALInsertLockTrancheId, + LWLockRegisterTranche(LWTRANCHE_WAL_INSERT, &XLogCtl->Insert.WALInsertLockTranche); return; } @@ -4677,17 +4676,14 @@ XLOGShmemInit(void) (WALInsertLockPadded *) allocptr; allocptr += sizeof(WALInsertLockPadded) * NUM_XLOGINSERT_LOCKS; - XLogCtl->Insert.WALInsertLockTrancheId = LWLockNewTrancheId(); - XLogCtl->Insert.WALInsertLockTranche.name = "WALInsertLocks"; XLogCtl->Insert.WALInsertLockTranche.array_base = WALInsertLocks; XLogCtl->Insert.WALInsertLockTranche.array_stride = sizeof(WALInsertLockPadded); - LWLockRegisterTranche(XLogCtl->Insert.WALInsertLockTrancheId, &XLogCtl->Insert.WALInsertLockTranche); + LWLockRegisterTranche(LWTRANCHE_WAL_INSERT, &XLogCtl->Insert.WALInsertLockTranche); for (i = 0; i < NUM_XLOGINSERT_LOCKS; i++) { - LWLockInitialize(&WALInsertLocks[i].l.lock, - XLogCtl->Insert.WALInsertLockTrancheId); + LWLockInitialize(&WALInsertLocks[i].l.lock, LWTRANCHE_WAL_INSERT); WALInsertLocks[i].l.insertingAt = InvalidXLogRecPtr; } -- cgit v1.2.3