MCPcopy Create free account
hub / github.com/apache/cloudberry / write_message_to_server_log

Function write_message_to_server_log

src/backend/utils/error/elog.c:4154–4299  ·  view source on GitHub ↗

* Write error report to server's log. * * This is an equivalent function as send_message_to_server_log, but will write * the error report in the format of GpPipeProtoHeader, followed by a serialized * format of GpErrorData. The error report is sent over to the syslogger process * through the pipe. * * This function is thread-safe. Here, we assume that sprintf is thread-safe. */

Source from the content-addressed store, hash-verified

4152 * This function is thread-safe. Here, we assume that sprintf is thread-safe.
4153 */
4154void
4155write_message_to_server_log(int elevel,
4156 int sqlerrcode,
4157 const char *message,
4158 const char *detail,
4159 const char *hint,
4160 const char *query_text,
4161 int cursorpos,
4162 int internalpos,
4163 const char *internalquery,
4164 const char *context,
4165 const char *funcname,
4166 bool show_funcname,
4167 const char *filename,
4168 int lineno,
4169 int stacktracesize,
4170 bool omit_location,
4171 void* const *stacktracearray,
4172 bool printstack)
4173{
4174 PipeProtoChunk buffer;
4175
4176 char *data = buffer.data;
4177 GpErrorDataFixFields fix_fields;
4178 static uint64 log_line_number = 0;
4179
4180 Assert(MyBackendType != B_LOGGER);
4181
4182 buffer.hdr.zero = 0;
4183 buffer.hdr.len = 0;
4184 buffer.hdr.pid = MyProcPid;
4185 buffer.hdr.thid = mythread();
4186 buffer.hdr.main_thid = mainthread();
4187 buffer.hdr.chunk_no = 0;
4188 buffer.hdr.is_last = 'f';
4189 buffer.hdr.log_format = 'c';
4190 buffer.hdr.log_line_number = log_line_number++;
4191 buffer.hdr.is_segv_msg = 'f';
4192 buffer.hdr.next = -1;
4193
4194
4195 /* Serialize edata in the order defined in GpErrorData. */
4196
4197 fix_fields.session_start_time =
4198 (MyProcPort == NULL) ? 0 : (pg_time_t) timestamptz_to_time_t(MyStartTimestamp);
4199 fix_fields.omit_location = omit_location ? 't' : 'f';
4200 fix_fields.gp_is_primary = 't';
4201 fix_fields.gp_session_id = gp_session_id;
4202 fix_fields.gp_command_count = gp_command_count;
4203 fix_fields.gp_segment_id = GpIdentity.segindex;
4204 fix_fields.slice_id = currentSliceId;
4205 fix_fields.error_cursor_pos = cursorpos;
4206 fix_fields.internal_query_pos = internalpos;
4207 fix_fields.error_fileline = lineno;
4208 fix_fields.top_trans_id = GetTopTransactionIdIfAny();
4209
4210 GetAllTransactionXids(&(fix_fields.dist_trans_id),
4211 &(fix_fields.local_trans_id),

Callers 3

write_stderrFunction · 0.70
write_logFunction · 0.50

Calls 9

GetTopTransactionIdIfAnyFunction · 0.85
GetAllTransactionXidsFunction · 0.85
error_severityFunction · 0.70
unpack_sql_stateFunction · 0.70
is_log_level_outputFunction · 0.70
append_stacktraceFunction · 0.70
gp_write_pipe_chunkFunction · 0.70
timestamptz_to_time_tFunction · 0.50

Tested by

no test coverage detected