mirror of https://github.com/citusdata/citus.git
Improve error messages when a backend is cancelled by deadlock detection
We send SIGINT to a backend that is cancelled due to a deadlock. That approach ends up being a very confusing error message. With this commit we intercept the error messages and show a more meaningful error message to the user.pull/1529/head
parent
be4fc45c03
commit
66936053a0
|
@ -57,6 +57,7 @@ static char *CitusVersion = CITUS_VERSION;
|
||||||
|
|
||||||
void _PG_init(void);
|
void _PG_init(void);
|
||||||
|
|
||||||
|
static void multi_log_hook(ErrorData *edata);
|
||||||
static void CreateRequiredDirectories(void);
|
static void CreateRequiredDirectories(void);
|
||||||
static void RegisterCitusConfigVariables(void);
|
static void RegisterCitusConfigVariables(void);
|
||||||
static void WarningForEnableDeadlockPrevention(bool newval, void *extra);
|
static void WarningForEnableDeadlockPrevention(bool newval, void *extra);
|
||||||
|
@ -175,6 +176,9 @@ _PG_init(void)
|
||||||
set_rel_pathlist_hook = multi_relation_restriction_hook;
|
set_rel_pathlist_hook = multi_relation_restriction_hook;
|
||||||
set_join_pathlist_hook = multi_join_restriction_hook;
|
set_join_pathlist_hook = multi_join_restriction_hook;
|
||||||
|
|
||||||
|
/* register hook for error messages */
|
||||||
|
emit_log_hook = multi_log_hook;
|
||||||
|
|
||||||
InitializeMaintenanceDaemon();
|
InitializeMaintenanceDaemon();
|
||||||
|
|
||||||
/* organize that task tracker is started once server is up */
|
/* organize that task tracker is started once server is up */
|
||||||
|
@ -195,6 +199,27 @@ _PG_init(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* multi_log_hook intercepts postgres log commands. We use this to override
|
||||||
|
* postgres error messages when they're not specific enough for the users.
|
||||||
|
*/
|
||||||
|
static void
|
||||||
|
multi_log_hook(ErrorData *edata)
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Show the user a meaningful error message when a backend is cancelled
|
||||||
|
* by the distributed deadlock detection.
|
||||||
|
*/
|
||||||
|
if (edata->elevel == ERROR && edata->sqlerrcode == ERRCODE_QUERY_CANCELED &&
|
||||||
|
MyBackendGotCancelledDueToDeadlock())
|
||||||
|
{
|
||||||
|
edata->sqlerrcode = ERRCODE_T_R_DEADLOCK_DETECTED;
|
||||||
|
edata->message = "canceling the transaction since it has "
|
||||||
|
"involved in a distributed deadlock";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* StartupCitusBackend initializes per-backend infrastructure, and is called
|
* StartupCitusBackend initializes per-backend infrastructure, and is called
|
||||||
* the first time citus is used in a database.
|
* the first time citus is used in a database.
|
||||||
|
|
Loading…
Reference in New Issue