summaryrefslogtreecommitdiff
path: root/src/backend/storage
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/storage')
-rw-r--r--src/backend/storage/lmgr/Makefile4
-rw-r--r--src/backend/storage/lmgr/generate-lwlocknames.pl49
2 files changed, 51 insertions, 2 deletions
diff --git a/src/backend/storage/lmgr/Makefile b/src/backend/storage/lmgr/Makefile
index c48ba943c4c..504480e8477 100644
--- a/src/backend/storage/lmgr/Makefile
+++ b/src/backend/storage/lmgr/Makefile
@@ -39,8 +39,8 @@ s_lock_test: s_lock.c $(top_builddir)/src/common/libpgcommon.a $(top_builddir)/s
lwlocknames.c: lwlocknames.h
touch $@
-lwlocknames.h: $(top_srcdir)/src/backend/storage/lmgr/lwlocknames.txt generate-lwlocknames.pl
- $(PERL) $(srcdir)/generate-lwlocknames.pl $<
+lwlocknames.h: $(top_srcdir)/src/backend/storage/lmgr/lwlocknames.txt $(top_srcdir)/src/backend/utils/activity/wait_event_names.txt generate-lwlocknames.pl
+ $(PERL) $(srcdir)/generate-lwlocknames.pl $^
check: s_lock_test
./s_lock_test
diff --git a/src/backend/storage/lmgr/generate-lwlocknames.pl b/src/backend/storage/lmgr/generate-lwlocknames.pl
index bef5e16e114..7b93ecf6c1e 100644
--- a/src/backend/storage/lmgr/generate-lwlocknames.pl
+++ b/src/backend/storage/lmgr/generate-lwlocknames.pl
@@ -15,6 +15,7 @@ my $continue = "\n";
GetOptions('outdir:s' => \$output_path);
open my $lwlocknames, '<', $ARGV[0] or die;
+open my $wait_event_names, '<', $ARGV[1] or die;
# Include PID in suffix in case parallel make runs this multiple times.
my $htmp = "$output_path/lwlocknames.h.tmp$$";
@@ -30,6 +31,40 @@ print $c $autogen, "\n";
print $c "const char *const IndividualLWLockNames[] = {";
+#
+# First, record the predefined LWLocks listed in wait_event_names.txt. We'll
+# cross-check those with the ones in lwlocknames.txt.
+#
+my @wait_event_lwlocks;
+my $record_lwlocks = 0;
+
+while (<$wait_event_names>)
+{
+ chomp;
+
+ # Check for end marker.
+ last if /^# END OF PREDEFINED LWLOCKS/;
+
+ # Skip comments and empty lines.
+ next if /^#/;
+ next if /^\s*$/;
+
+ # Start recording LWLocks when we find the WaitEventLWLock section.
+ if (/^Section: ClassName - WaitEventLWLock$/)
+ {
+ $record_lwlocks = 1;
+ next;
+ }
+
+ # Go to the next line if we are not yet recording LWLocks.
+ next if not $record_lwlocks;
+
+ # Record the LWLock.
+ (my $waiteventname, my $waitevendocsentence) = split(/\t/, $_);
+ push(@wait_event_lwlocks, $waiteventname . "Lock");
+}
+
+my $i = 0;
while (<$lwlocknames>)
{
chomp;
@@ -50,6 +85,15 @@ while (<$lwlocknames>)
die "lwlocknames.txt not in order" if $lockidx < $lastlockidx;
die "lwlocknames.txt has duplicates" if $lockidx == $lastlockidx;
+ die "$lockname defined in lwlocknames.txt but missing from "
+ . "wait_event_names.txt"
+ if $i >= scalar @wait_event_lwlocks;
+ die "lists of predefined LWLocks do not match (first mismatch at "
+ . "$wait_event_lwlocks[$i] in wait_event_names.txt and $lockname in "
+ . "lwlocknames.txt)"
+ if $wait_event_lwlocks[$i] ne $lockname;
+ $i++;
+
while ($lastlockidx < $lockidx - 1)
{
++$lastlockidx;
@@ -63,6 +107,11 @@ while (<$lwlocknames>)
print $h "#define $lockname (&MainLWLockArray[$lockidx].lock)\n";
}
+die
+ "$wait_event_lwlocks[$i] defined in wait_event_names.txt but missing from "
+ . "lwlocknames.txt"
+ if $i < scalar @wait_event_lwlocks;
+
printf $c "\n};\n";
print $h "\n";
printf $h "#define NUM_INDIVIDUAL_LWLOCKS %s\n", $lastlockidx + 1;