Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit a43f193

Browse files
committed
Remove or reduce verbosity of some debug messages.
The debug messages that merely print StartTransactionCommand, CommitTransactionCommand, ProcessUtilty, or ProcessQuery with no additional details seem to be useless. Get rid of them. The transaction status messages produced by ShowTransactionState are occasionally useful, but they are extremely verbose, producing multiple lines of log output every time they fire, which can happens multiple times per transaction. So, reduce the level to DEBUG5; avoid emitting an extra line just to explain which debug point is at issue; and tighten up the rest of the message so it doesn't use quite so much horizontal space. With these changes, it's possible to run a somewhat busy system with a log level even as high as DEBUG4, whereas previously anything above DEBUG2 would flood the log with output that probably wasn't really all that useful.
1 parent d8c05af commit a43f193

File tree

3 files changed

+10
-22
lines changed

3 files changed

+10
-22
lines changed

src/backend/access/transam/xact.c

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ static void AtSubStart_Memory(void);
327327
static void AtSubStart_ResourceOwner(void);
328328

329329
static void ShowTransactionState(const char *str);
330-
static void ShowTransactionStateRec(TransactionState state);
330+
static void ShowTransactionStateRec(const char *str, TransactionState state);
331331
static const char *BlockStateAsString(TBlockState blockState);
332332
static const char *TransStateAsString(TransState state);
333333

@@ -4944,19 +4944,16 @@ static void
49444944
ShowTransactionState(const char *str)
49454945
{
49464946
/* skip work if message will definitely not be printed */
4947-
if (log_min_messages <= DEBUG3 || client_min_messages <= DEBUG3)
4948-
{
4949-
elog(DEBUG3, "%s", str);
4950-
ShowTransactionStateRec(CurrentTransactionState);
4951-
}
4947+
if (log_min_messages <= DEBUG5 || client_min_messages <= DEBUG5)
4948+
ShowTransactionStateRec(str, CurrentTransactionState);
49524949
}
49534950

49544951
/*
49554952
* ShowTransactionStateRec
49564953
* Recursive subroutine for ShowTransactionState
49574954
*/
49584955
static void
4959-
ShowTransactionStateRec(TransactionState s)
4956+
ShowTransactionStateRec(const char *str, TransactionState s)
49604957
{
49614958
StringInfoData buf;
49624959

@@ -4966,25 +4963,26 @@ ShowTransactionStateRec(TransactionState s)
49664963
{
49674964
int i;
49684965

4969-
appendStringInfo(&buf, "%u", s->childXids[0]);
4966+
appendStringInfo(&buf, ", children: %u", s->childXids[0]);
49704967
for (i = 1; i < s->nChildXids; i++)
49714968
appendStringInfo(&buf, " %u", s->childXids[i]);
49724969
}
49734970

49744971
if (s->parent)
4975-
ShowTransactionStateRec(s->parent);
4972+
ShowTransactionStateRec(str, s->parent);
49764973

49774974
/* use ereport to suppress computation if msg will not be printed */
4978-
ereport(DEBUG3,
4979-
(errmsg_internal("name: %s; blockState: %13s; state: %7s, xid/subid/cid: %u/%u/%u%s, nestlvl: %d, children: %s",
4975+
ereport(DEBUG5,
4976+
(errmsg_internal("%s(%d) name: %s; blockState: %s; state: %s, xid/subid/cid: %u/%u/%u%s%s",
4977+
str, s->nestingLevel,
49804978
PointerIsValid(s->name) ? s->name : "unnamed",
49814979
BlockStateAsString(s->blockState),
49824980
TransStateAsString(s->state),
49834981
(unsigned int) s->transactionId,
49844982
(unsigned int) s->subTransactionId,
49854983
(unsigned int) currentCommandId,
49864984
currentCommandIdUsed ? " (used)" : "",
4987-
s->nestingLevel, buf.data)));
4985+
buf.data)));
49884986

49894987
pfree(buf.data);
49904988
}

src/backend/tcop/postgres.c

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2427,8 +2427,6 @@ start_xact_command(void)
24272427
{
24282428
if (!xact_started)
24292429
{
2430-
ereport(DEBUG3,
2431-
(errmsg_internal("StartTransactionCommand")));
24322430
StartTransactionCommand();
24332431

24342432
/* Set statement timeout running, if any */
@@ -2450,10 +2448,6 @@ finish_xact_command(void)
24502448
/* Cancel any active statement timeout before committing */
24512449
disable_timeout(STATEMENT_TIMEOUT, false);
24522450

2453-
/* Now commit the command */
2454-
ereport(DEBUG3,
2455-
(errmsg_internal("CommitTransactionCommand")));
2456-
24572451
CommitTransactionCommand();
24582452

24592453
#ifdef MEMORY_CONTEXT_CHECKING

src/backend/tcop/pquery.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,6 @@ ProcessQuery(PlannedStmt *plan,
167167
{
168168
QueryDesc *queryDesc;
169169

170-
elog(DEBUG3, "ProcessQuery");
171-
172170
/*
173171
* Create the QueryDesc object
174172
*/
@@ -1151,8 +1149,6 @@ PortalRunUtility(Portal portal, Node *utilityStmt,
11511149
{
11521150
Snapshot snapshot;
11531151

1154-
elog(DEBUG3, "ProcessUtility");
1155-
11561152
/*
11571153
* Set snapshot if utility stmt needs one. Most reliable way to do this
11581154
* seems to be to enumerate those that do not need one; this is a short

0 commit comments

Comments
 (0)