Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitfe400d0

Browse files
committed
[refer #PGPRO-6601]: Removed "init_lock_tag" function which interferes with
the same named function in the AQO extension.Init the "receiver" shared memory queue more carefully using an "ExclusiveLock"lock.Tags: pg_wait_sampling.
1 parente17ab38 commitfe400d0

File tree

3 files changed

+26
-31
lines changed

3 files changed

+26
-31
lines changed

‎collector.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,12 +445,9 @@ collector_main(Datum main_arg)
445445
/* Handle request if any */
446446
if (collector_hdr->request!=NO_REQUEST)
447447
{
448-
LOCKTAGtag;
449448
SHMRequestrequest;
450449

451-
init_lock_tag(&tag,PGWS_COLLECTOR_LOCK);
452-
453-
LockAcquire(&tag,ExclusiveLock, false, false);
450+
LockAcquire(&collectorTag,ExclusiveLock, false, false);
454451
request=collector_hdr->request;
455452
collector_hdr->request=NO_REQUEST;
456453

@@ -494,7 +491,7 @@ collector_main(Datum main_arg)
494491
hash_destroy(profile_hash);
495492
profile_hash=make_profile_hash();
496493
}
497-
LockRelease(&tag,ExclusiveLock, false);
494+
LockRelease(&collectorTag,ExclusiveLock, false);
498495
}
499496
}
500497

‎pg_wait_sampling.c

Lines changed: 21 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,24 @@ CollectorShmqHeader *collector_hdr = NULL;
5656
/* Receiver (backend) local shm_mq pointers and lock */
5757
shm_mq*recv_mq=NULL;
5858
shm_mq_handle*recv_mqh=NULL;
59-
LOCKTAGqueueTag;
59+
60+
constLOCKTAGqueueTag= {
61+
.locktag_field1=PG_WAIT_SAMPLING_MAGIC,
62+
.locktag_field2=PGWS_QUEUE_LOCK,
63+
.locktag_field3=0,
64+
.locktag_field4=0,
65+
.locktag_type=LOCKTAG_USERLOCK,
66+
.locktag_lockmethodid=USER_LOCKMETHOD
67+
};
68+
69+
constLOCKTAGcollectorTag= {
70+
.locktag_field1=PG_WAIT_SAMPLING_MAGIC,
71+
.locktag_field2=PGWS_COLLECTOR_LOCK,
72+
.locktag_field3=0,
73+
.locktag_field4=0,
74+
.locktag_type=LOCKTAG_USERLOCK,
75+
.locktag_lockmethodid=USER_LOCKMETHOD
76+
};
6077

6178
#ifPG_VERSION_NUM >=150000
6279
staticshmem_request_hook_typeprev_shmem_request_hook=NULL;
@@ -563,21 +580,9 @@ typedef struct
563580
ProfileItem*items;
564581
}Profile;
565582

566-
void
567-
init_lock_tag(LOCKTAG*tag,uint32lock)
568-
{
569-
tag->locktag_field1=PG_WAIT_SAMPLING_MAGIC;
570-
tag->locktag_field2=lock;
571-
tag->locktag_field3=0;
572-
tag->locktag_field4=0;
573-
tag->locktag_type=LOCKTAG_USERLOCK;
574-
tag->locktag_lockmethodid=USER_LOCKMETHOD;
575-
}
576-
577583
staticvoid*
578584
receive_array(SHMRequestrequest,Sizeitem_size,Size*count)
579585
{
580-
LOCKTAGcollectorTag;
581586
shm_mq_resultres;
582587
Sizelen,
583588
i;
@@ -587,13 +592,10 @@ receive_array(SHMRequest request, Size item_size, Size *count)
587592
MemoryContextoldctx;
588593

589594
/* Ensure nobody else trying to send request to queue */
590-
init_lock_tag(&queueTag,PGWS_QUEUE_LOCK);
591595
LockAcquire(&queueTag,ExclusiveLock, false, false);
592596

593-
recv_mq=shm_mq_create(collector_mq,COLLECTOR_QUEUE_SIZE);
594-
595-
init_lock_tag(&collectorTag,PGWS_COLLECTOR_LOCK);
596597
LockAcquire(&collectorTag,ExclusiveLock, false, false);
598+
recv_mq=shm_mq_create(collector_mq,COLLECTOR_QUEUE_SIZE);
597599
collector_hdr->request=request;
598600
LockRelease(&collectorTag,ExclusiveLock, false);
599601

@@ -754,23 +756,17 @@ PG_FUNCTION_INFO_V1(pg_wait_sampling_reset_profile);
754756
Datum
755757
pg_wait_sampling_reset_profile(PG_FUNCTION_ARGS)
756758
{
757-
LOCKTAGtag;
758-
LOCKTAGcollectorTag;
759-
760759
check_shmem();
761760

762-
init_lock_tag(&tag,PGWS_QUEUE_LOCK);
763-
764-
LockAcquire(&tag,ExclusiveLock, false, false);
761+
LockAcquire(&queueTag,ExclusiveLock, false, false);
765762

766-
init_lock_tag(&collectorTag,PGWS_COLLECTOR_LOCK);
767763
LockAcquire(&collectorTag,ExclusiveLock, false, false);
768764
collector_hdr->request=PROFILE_RESET;
769765
LockRelease(&collectorTag,ExclusiveLock, false);
770766

771767
SetLatch(collector_hdr->latch);
772768

773-
LockRelease(&tag,ExclusiveLock, false);
769+
LockRelease(&queueTag,ExclusiveLock, false);
774770

775771
PG_RETURN_VOID();
776772
}

‎pg_wait_sampling.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,14 @@ typedef struct
7070
boolprofileQueries;
7171
}CollectorShmqHeader;
7272

73+
externconstLOCKTAGqueueTag;
74+
externconstLOCKTAGcollectorTag;
75+
7376
/* pg_wait_sampling.c */
7477
externvoidcheck_shmem(void);
7578
externCollectorShmqHeader*collector_hdr;
7679
externshm_mq*collector_mq;
7780
externuint64*proc_queryids;
78-
externvoidinit_lock_tag(LOCKTAG*tag,uint32lock);
7981

8082
/* collector.c */
8183
externvoidregister_wait_collector(void);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp