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

Commite6f52a7

Browse files
maksm90akorotkov
authored andcommitted
Fix another issue with collector infinite loop.
In some rare cases collector acquires own exclusive lock but doesn'trelease it. I suppose that after acquiring but before releasing of lockthere was some exception that was interrupted somewhere above butcollector lock releasing was lost. This commit adds try-catch blocksurrounding critical lock section to release lock anyway
1 parentd77c9e2 commite6f52a7

File tree

1 file changed

+45
-35
lines changed

1 file changed

+45
-35
lines changed

‎collector.c

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -436,47 +436,57 @@ collector_main(Datum main_arg)
436436
LockAcquire(&tag,ExclusiveLock, false, false);
437437
collector_hdr->request=NO_REQUEST;
438438

439-
if (request==HISTORY_REQUEST||request==PROFILE_REQUEST)
439+
PG_TRY();
440440
{
441-
shm_mq_resultmq_result;
442-
443-
/* Send history or profile */
444-
shm_mq_set_sender(collector_mq,MyProc);
445-
mqh=shm_mq_attach(collector_mq,NULL,NULL);
446-
mq_result=shm_mq_wait_for_attach(mqh);
447-
switch (mq_result)
441+
if (request==HISTORY_REQUEST||request==PROFILE_REQUEST)
442+
{
443+
shm_mq_resultmq_result;
444+
445+
/* Send history or profile */
446+
shm_mq_set_sender(collector_mq,MyProc);
447+
mqh=shm_mq_attach(collector_mq,NULL,NULL);
448+
mq_result=shm_mq_wait_for_attach(mqh);
449+
switch (mq_result)
450+
{
451+
caseSHM_MQ_SUCCESS:
452+
switch (request)
453+
{
454+
caseHISTORY_REQUEST:
455+
send_history(&observations,mqh);
456+
break;
457+
casePROFILE_REQUEST:
458+
send_profile(profile_hash,mqh);
459+
break;
460+
default:
461+
AssertState(false);
462+
}
463+
break;
464+
caseSHM_MQ_DETACHED:
465+
ereport(WARNING,
466+
(errmsg("pg_wait_sampling collector: "
467+
"receiver of message queue have been "
468+
"detached")));
469+
break;
470+
default:
471+
AssertState(false);
472+
}
473+
shm_mq_detach_compat(mqh,collector_mq);
474+
}
475+
elseif (request==PROFILE_RESET)
448476
{
449-
caseSHM_MQ_SUCCESS:
450-
switch (request)
451-
{
452-
caseHISTORY_REQUEST:
453-
send_history(&observations,mqh);
454-
break;
455-
casePROFILE_REQUEST:
456-
send_profile(profile_hash,mqh);
457-
break;
458-
default:
459-
AssertState(false);
460-
}
461-
break;
462-
caseSHM_MQ_DETACHED:
463-
ereport(WARNING,
464-
(errmsg("pg_wait_sampling collector: "
465-
"receiver of message queue have been "
466-
"detached")));
467-
break;
468-
default:
469-
AssertState(false);
477+
/* Reset profile hash */
478+
hash_destroy(profile_hash);
479+
profile_hash=make_profile_hash();
470480
}
471-
shm_mq_detach_compat(mqh,collector_mq);
481+
482+
LockRelease(&tag,ExclusiveLock, false);
472483
}
473-
elseif (request==PROFILE_RESET)
484+
PG_CATCH();
474485
{
475-
/* Reset profile hash */
476-
hash_destroy(profile_hash);
477-
profile_hash=make_profile_hash();
486+
LockRelease(&tag,ExclusiveLock, false);
487+
PG_RE_THROW();
478488
}
479-
LockRelease(&tag,ExclusiveLock, false);
489+
PG_END_TRY();
480490
}
481491
}
482492

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp