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

Commit18c170a

Browse files
committed
Include the process PID in assertion-failure messages.
This should help to identify what happened when studying the postmasterlog after-the-fact.While here, clean up some old comments in the same function.Discussion:https://postgr.es/m/1568983.1601845687@sss.pgh.pa.us
1 parent53c6daf commit18c170a

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

‎src/backend/utils/error/assert.c

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*-------------------------------------------------------------------------
22
*
33
* assert.c
4-
* Assert code.
4+
* Assertsupportcode.
55
*
66
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
77
* Portions Copyright (c) 1994, Regents of the University of California
@@ -10,9 +10,6 @@
1010
* IDENTIFICATION
1111
* src/backend/utils/error/assert.c
1212
*
13-
* NOTE
14-
* This should eventually work with elog()
15-
*
1613
*-------------------------------------------------------------------------
1714
*/
1815
#include"postgres.h"
@@ -24,27 +21,32 @@
2421

2522
/*
2623
* ExceptionalCondition - Handles the failure of an Assert()
24+
*
25+
* We intentionally do not go through elog() here, on the grounds of
26+
* wanting to minimize the amount of infrastructure that has to be
27+
* working to report an assertion failure.
2728
*/
2829
void
2930
ExceptionalCondition(constchar*conditionName,
3031
constchar*errorType,
3132
constchar*fileName,
3233
intlineNumber)
3334
{
35+
/* Report the failure on stderr (or local equivalent) */
3436
if (!PointerIsValid(conditionName)
3537
|| !PointerIsValid(fileName)
3638
|| !PointerIsValid(errorType))
37-
write_stderr("TRAP: ExceptionalCondition: bad arguments\n");
39+
write_stderr("TRAP: ExceptionalCondition: bad arguments in PID %d\n",
40+
(int)getpid());
3841
else
39-
{
40-
write_stderr("TRAP: %s(\"%s\", File: \"%s\", Line: %d)\n",
42+
write_stderr("TRAP: %s(\"%s\", File: \"%s\", Line: %d, PID: %d)\n",
4143
errorType,conditionName,
42-
fileName,lineNumber);
43-
}
44+
fileName,lineNumber, (int)getpid());
4445

4546
/* Usually this shouldn't be needed, but make sure the msg went out */
4647
fflush(stderr);
4748

49+
/* If we have support for it, dump a simple backtrace */
4850
#ifdefHAVE_BACKTRACE_SYMBOLS
4951
{
5052
void*buf[100];
@@ -55,12 +57,12 @@ ExceptionalCondition(const char *conditionName,
5557
}
5658
#endif
5759

58-
#ifdefSLEEP_ON_ASSERT
59-
6060
/*
61-
* It would be nice to use pg_usleep() here, but only does 2000 sec or 33
62-
* minutes, which seems too short.
61+
* If configured to do so, sleep indefinitely to allow user to attach a
62+
* debugger. It would be nice to use pg_usleep() here, but that can sleep
63+
* at most 2G usec or ~33 minutes, which seems too short.
6364
*/
65+
#ifdefSLEEP_ON_ASSERT
6466
sleep(1000000);
6567
#endif
6668

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp