ApplyLogRedaction noop func is added

pull/2342/head
mehmet furkan şahin 2018-08-17 12:24:32 -07:00
parent c3c0d62ca6
commit ef9f38b68d
18 changed files with 65 additions and 30 deletions

View File

@ -1240,7 +1240,8 @@ ReportCopyError(MultiConnection *connection, PGresult *result)
bool haveDetail = remoteDetail != NULL;
ereport(ERROR, (errmsg("%s", remoteMessage),
haveDetail ? errdetail("%s", remoteDetail) : 0));
haveDetail ? errdetail("%s", ApplyLogRedaction(remoteDetail)) :
0));
}
else
{
@ -1250,7 +1251,7 @@ ReportCopyError(MultiConnection *connection, PGresult *result)
ereport(ERROR, (errcode(ERRCODE_IO_ERROR),
errmsg("failed to complete COPY on %s:%d", connection->hostname,
connection->port),
errdetail("%s", remoteMessage)));
errdetail("%s", ApplyLogRedaction(remoteMessage))));
}
}

View File

@ -22,6 +22,7 @@
#include "access/hash.h"
#include "commands/dbcommands.h"
#include "distributed/connection_management.h"
#include "distributed/errormessage.h"
#include "distributed/metadata_cache.h"
#include "distributed/hash_helpers.h"
#include "distributed/placement_connection.h"
@ -824,9 +825,9 @@ DefaultCitusNoticeProcessor(void *arg, const char *message)
char *trimmedMessage = TrimLogLevel(message);
char *level = strtok((char *) message, ":");
ereport(CitusNoticeLogLevel, (errmsg("%s", trimmedMessage),
errdetail("%s from %s:%d",
level, nodeName, nodePort)));
ereport(CitusNoticeLogLevel,
(errmsg("%s", ApplyLogRedaction(trimmedMessage)),
errdetail("%s from %s:%d", level, nodeName, nodePort)));
}

View File

@ -14,6 +14,7 @@
#include "libpq-fe.h"
#include "distributed/connection_management.h"
#include "distributed/errormessage.h"
#include "distributed/remote_commands.h"
#include "lib/stringinfo.h"
#include "miscadmin.h"
@ -253,7 +254,8 @@ ReportConnectionError(MultiConnection *connection, int elevel)
ereport(elevel, (errcode(ERRCODE_CONNECTION_FAILURE),
errmsg("connection error: %s:%d", nodeName, nodePort),
messageDetail != NULL ? errdetail("%s", messageDetail) : 0));
messageDetail != NULL ?
errdetail("%s", ApplyLogRedaction(messageDetail)) : 0));
}
@ -295,7 +297,8 @@ ReportResultError(MultiConnection *connection, PGresult *result, int elevel)
}
ereport(elevel, (errcode(sqlState), errmsg("%s", messagePrimary),
messageDetail ? errdetail("%s", messageDetail) : 0,
messageDetail ?
errdetail("%s", ApplyLogRedaction(messageDetail)) : 0,
messageHint ? errhint("%s", messageHint) : 0,
messageContext ? errcontext("%s", messageContext) : 0,
errcontext("while executing command on %s:%d",
@ -344,7 +347,7 @@ LogRemoteCommand(MultiConnection *connection, const char *command)
return;
}
ereport(LOG, (errmsg("issuing %s", command),
ereport(LOG, (errmsg("issuing %s", ApplyLogRedaction(command)),
errdetail("on server %s:%d", connection->hostname, connection->port)));
}

View File

@ -419,8 +419,17 @@ MultiClientSendQuery(int32 connectionId, const char *query)
if (querySent == 0)
{
char *errorMessage = pchomp(PQerrorMessage(connection->pgConn));
ereport(WARNING, (errmsg("could not send remote query \"%s\"", query),
errdetail("Client error: %s", errorMessage)));
/*
* query might include the user query coming from the taskTracker
* code path, that's why we hash it, too. Otherwise, this code
* path is generally exercised for the kind of errors that
* we cannot send the queries that Citus itself produced.
*/
ereport(WARNING, (errmsg("could not send remote query \"%s\"",
ApplyLogRedaction(query)),
errdetail("Client error: %s",
ApplyLogRedaction(errorMessage))));
success = false;
}

View File

@ -67,7 +67,7 @@ JobExecutorType(DistributedPlan *distributedPlan)
ereport(DEBUG2, (errmsg("Plan is router executable"),
errdetail("distribution column value: %s",
partitionColumnString)));
ApplyLogRedaction(partitionColumnString))));
}
else
{

View File

@ -122,7 +122,7 @@ master_apply_delete_command(PG_FUNCTION_ARGS)
if (!IsA(queryTreeNode, DeleteStmt))
{
ereport(ERROR, (errmsg("query \"%s\" is not a delete statement",
queryString)));
ApplyLogRedaction(queryString))));
}
deleteStatement = (DeleteStmt *) queryTreeNode;

View File

@ -145,7 +145,7 @@ master_modify_multiple_shards(PG_FUNCTION_ARGS)
else
{
ereport(ERROR, (errmsg("query \"%s\" is not a delete, update, or truncate "
"statement", queryString)));
"statement", ApplyLogRedaction(queryString))));
}
CheckDistributedTable(relationId);

View File

@ -109,11 +109,13 @@ RebuildQueryStrings(Query *originalQuery, List *taskList)
}
}
ereport(DEBUG4, (errmsg("query before rebuilding: %s", task->queryString)));
ereport(DEBUG4, (errmsg("query before rebuilding: %s",
ApplyLogRedaction(task->queryString))));
UpdateTaskQueryString(query, relationId, valuesRTE, task);
ereport(DEBUG4, (errmsg("query after rebuilding: %s", task->queryString)));
ereport(DEBUG4, (errmsg("query after rebuilding: %s",
ApplyLogRedaction(task->queryString))));
}
}

View File

@ -576,7 +576,8 @@ RouterModifyTaskForShardInterval(Query *originalQuery, ShardInterval *shardInter
/* and generate the full query string */
deparse_shard_query(copiedQuery, distributedTableId, shardInterval->shardId,
queryString);
ereport(DEBUG2, (errmsg("distributed statement: %s", queryString->data)));
ereport(DEBUG2, (errmsg("distributed statement: %s",
ApplyLogRedaction(queryString->data))));
modifyTask = CreateBasicTask(jobId, taskIdIndex, MODIFY_TASK, queryString->data);
modifyTask->dependedTaskList = NULL;

View File

@ -714,7 +714,8 @@ PrintJoinOrderList(List *joinOrder)
}
}
ereport(LOG, (errmsg("join order: %s", printBuffer->data)));
ereport(LOG, (errmsg("join order: %s",
ApplyLogRedaction(printBuffer->data))));
}

View File

@ -2418,7 +2418,8 @@ QueryPushdownTaskCreate(Query *originalQuery, int shardIndex,
taskType == SQL_TASK)
{
pg_get_query_def(taskQuery, queryString);
ereport(DEBUG4, (errmsg("distributed statement: %s", queryString->data)));
ereport(DEBUG4, (errmsg("distributed statement: %s",
ApplyLogRedaction(queryString->data))));
subqueryTask->queryString = queryString->data;
}
@ -2698,7 +2699,8 @@ SqlTaskList(Job *job)
/* log the query string we generated */
ereport(DEBUG4, (errmsg("generated sql query for task %d", sqlTask->taskId),
errdetail("query string: \"%s\"", sqlQueryString->data)));
errdetail("query string: \"%s\"",
ApplyLogRedaction(sqlQueryString->data))));
sqlTask->anchorShardId = INVALID_SHARD_ID;
if (anchorRangeTableBasedAssignment)

View File

@ -218,7 +218,7 @@ GenerateSubplansForSubqueriesAndCTEs(uint64 planId, Query *originalQuery,
ereport(DEBUG1, (errmsg(
"Plan " UINT64_FORMAT
" query after replacing subqueries and CTEs: %s", planId,
subPlanString->data)));
ApplyLogRedaction(subPlanString->data))));
}
return context.subPlanList;
@ -715,9 +715,10 @@ RecursivelyPlanCTEs(Query *query, RecursivePlanningContext *planningContext)
{
StringInfo subPlanString = makeStringInfo();
pg_get_query_def(subquery, subPlanString);
ereport(DEBUG1, (errmsg("generating subplan " UINT64_FORMAT "_%u for "
"CTE %s: %s",
planId, subPlanId, cteName, subPlanString->data)));
ereport(DEBUG1, (errmsg("generating subplan " UINT64_FORMAT
"_%u for CTE %s: %s", planId, subPlanId,
cteName,
ApplyLogRedaction(subPlanString->data))));
}
/* build a sub plan for the CTE */
@ -1120,9 +1121,9 @@ RecursivelyPlanSubquery(Query *subquery, RecursivePlanningContext *planningConte
pg_get_query_def(debugQuery, subqueryString);
ereport(DEBUG1, (errmsg("generating subplan " UINT64_FORMAT "_%u for "
"subquery %s",
planId, subPlanId, subqueryString->data)));
ereport(DEBUG1, (errmsg("generating subplan " UINT64_FORMAT
"_%u for subquery %s", planId, subPlanId,
ApplyLogRedaction(subqueryString->data))));
}
/* finally update the input subquery to point the result query */

View File

@ -76,7 +76,7 @@ deparse_shard_query_test(PG_FUNCTION_ARGS)
deparse_shard_query(query, InvalidOid, 0, buffer);
elog(INFO, "query: %s", buffer->data);
elog(INFO, "query: %s", ApplyLogRedaction(buffer->data));
}
}

View File

@ -17,6 +17,7 @@
#include "access/hash.h"
#include "distributed/backend_data.h"
#include "distributed/distributed_deadlock_detection.h"
#include "distributed/errormessage.h"
#include "distributed/hash_helpers.h"
#include "distributed/listutils.h"
#include "distributed/lock_graph.h"
@ -673,7 +674,7 @@ LogDistributedDeadlockDebugMessage(const char *errorMessage)
}
ereport(LOG, (errmsg("[%s] %s", timestamptz_to_str(GetCurrentTimestamp()),
errorMessage)));
ApplyLogRedaction(errorMessage))));
}

View File

@ -12,6 +12,16 @@
#include "distributed/errormessage.h"
/*
* ApplyLogRedaction is only supported in Citus Enterprise
*/
char *
ApplyLogRedaction(const char *text)
{
return (char *) text;
}
/*
* DeferredErrorInternal is a helper function for DeferredError().
*/

View File

@ -710,7 +710,8 @@ ParseTreeRawStmt(const char *ddlCommand)
/* log immediately if dictated by log statement */
if (check_log_statement(parseTreeList))
{
ereport(LOG, (errmsg("statement: %s", ddlCommand), errhidestmt(true)));
ereport(LOG, (errmsg("statement: %s", ApplyLogRedaction(ddlCommand)),
errhidestmt(true)));
}
parseTreeCount = list_length(parseTreeList);

View File

@ -923,7 +923,7 @@ FilterAndPartitionTable(const char *filterQuery,
if (queryPortal == NULL)
{
ereport(ERROR, (errmsg("could not open implicit cursor for query \"%s\"",
filterQuery)));
ApplyLogRedaction(filterQuery))));
}
rowOutputState = InitRowOutputState();

View File

@ -70,3 +70,5 @@ DeferredErrorMessage * DeferredErrorInternal(int code, const char *message, cons
void RaiseDeferredErrorInternal(DeferredErrorMessage *error, int elevel);
#endif
extern char * ApplyLogRedaction(const char *text);