Re: Improve LWLock tranche name visibility across backends - Mailing list pgsql-hackers

From Sami Imseih
Subject Re: Improve LWLock tranche name visibility across backends
Date
Msg-id CAA5RZ0siw2MrVjf9iPYRpe8sgZW+TJRqmxKfCr=QS9mX+ZF8Lw@mail.gmail.com
Whole thread Raw
In response to Re: Improve LWLock tranche name visibility across backends  (Sami Imseih <samimseih@gmail.com>)
Responses Re: Improve LWLock tranche name visibility across backends
List pgsql-hackers
Hi,

Attached v6 which addresses the feedback from the last review.

1/ Rahila raised a point about the necessity to allocate new dsa pointers
for tranche names when copying ( during resize). That is correct. We can simply
memcpy those dsa pointers at the time of copy. All we need to
do is free the dsa pointer that tracks the list.

2/ I also implemented a full sync of the local cache when necessary.
That is the tranche name is not found locally and the tranche index is
not higher than the max used index. To do that we do have to track the
highest index used as the allocated counter is not sufficient to do this.
Allocation will grow geometrically to avoid resize operations.

3/ I also added tests using INJECTION_POINTS. Although the same tests
could be done with DEBUG, I felt INJECTION_POINTS
are better to use for this purpose to avoid unnecessary logging.
I created a test module called test_lwlock_tranches which has
a perl test because we do need to set shared_preload_libraries.

I did have to define the following in wait_classes.h:

+#define WAIT_EVENT_CLASS_MASK  0xFF000000
+#define WAIT_EVENT_ID_MASK             0x0000FFFF

This is because the extension calls
GetLWLockIdentifier ( to mimic pg_stat_activity) and
needs to calculate a classId.

--
Sami

Attachment

pgsql-hackers by date:

Previous
From: Fujii Masao
Date:
Subject: Excessive LOG messages from replication slot sync worker
Next
From: Sandino Araico Sánchez
Date:
Subject: Re: Proposal to adjust typmod argument on base UDT input functions