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

Function errstart

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

* errstart --- begin an error-reporting cycle * * Create and initialize error stack entry. Subsequently, errmsg() and * perhaps other routines will be called to further populate the stack entry. * Finally, errfinish() will be called to actually process the error report. * * Returns true in normal case. Returns false to short-circuit the error * report (if it's a warning or lower and not t

Source from the content-addressed store, hash-verified

393 * report (if it's a warning or lower and not to be reported anywhere).
394 */
395bool
396errstart(int elevel, const char *domain)
397{
398 ErrorData *edata;
399 bool output_to_server = false;
400 bool output_to_client = false;
401 int i;
402
403 /*
404 * Check some cases in which we want to promote an error into a more
405 * severe error. None of this logic applies for non-error messages.
406 */
407 if (elevel >= ERROR)
408 {
409 /*
410 * If we are inside a critical section, all errors become PANIC
411 * errors. See miscadmin.h.
412 */
413 if (CritSectionCount > 0)
414 elevel = PANIC;
415
416 /*
417 * Check reasons for treating ERROR as FATAL:
418 *
419 * 1. we have no handler to pass the error to (implies we are in the
420 * postmaster or in backend startup).
421 *
422 * 2. ExitOnAnyError mode switch is set (initdb uses this).
423 *
424 * 3. the error occurred after proc_exit has begun to run. (It's
425 * proc_exit's responsibility to see that this doesn't turn into
426 * infinite recursion!)
427 */
428 if (elevel == ERROR)
429 {
430 if (PG_exception_stack == NULL ||
431 ExitOnAnyError ||
432 proc_exit_inprogress)
433 elevel = FATAL;
434 }
435
436 /*
437 * If master process hits FATAL, post PREPARE but before COMMIT / ABORT on segment,
438 * just master process dies silently, leaves dangling prepared xact on segment.
439 * This also introduces inconsistency in the cluster, as xact is commited on master
440 * and some segments and still in-progress on few others.
441 * Hence converting FATAL to PANIC, here to reset master and perform full recovery
442 * instead, which would clean the dangling transaction update to COMMIT / ABORT.
443 */
444 if ((elevel == FATAL) && (Gp_role == GP_ROLE_DISPATCH))
445 {
446 switch (getCurrentDtxState())
447 {
448 case DTX_STATE_PREPARING:
449 case DTX_STATE_PREPARED:
450 case DTX_STATE_INSERTING_COMMITTED:
451 case DTX_STATE_INSERTED_COMMITTED:
452 case DTX_STATE_NOTIFYING_COMMIT_PREPARED:

Callers 10

errstart_coldFunction · 0.70
ThrowErrorDataFunction · 0.70
elog_dismissFunction · 0.70
GpdbEreportImplMethod · 0.50
GPOS_CATCH_EXFunction · 0.50
SerializeDXLPlanMethod · 0.50
cdbdisp_get_PQerrorFunction · 0.50

Calls 7

getCurrentDtxStateFunction · 0.85
MemoryContextResetFunction · 0.85
should_output_to_serverFunction · 0.70
should_output_to_clientFunction · 0.70
write_stderrFunction · 0.70
errmsg_internalFunction · 0.70

Tested by

no test coverage detected