From 5f766616e1d7842da23862b8fee53a74a99d9ec7 Mon Sep 17 00:00:00 2001 From: Alex Sharov Date: Tue, 25 Jan 2022 15:19:56 +0700 Subject: [PATCH] Configurable corrupt error recommendations (#52) --- mdbx/error.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/mdbx/error.go b/mdbx/error.go index 8192173..cdcb6cb 100644 --- a/mdbx/error.go +++ b/mdbx/error.go @@ -76,15 +76,17 @@ const ( // other values may still be produced. const minErrno, maxErrno C.int = C.MDBX_KEYEXIST, C.MDBX_LAST_ADDED_ERRCODE -const hardwareRecommendations = "Likely because hardware failure. Before creating issue please use tools like https://www.memtest86.com to test RAM and tools like https://www.smartmontools.org to test Disk. To handle hardware risks: use ECC RAM, use RAID of disks, run multiple application instances (or do backups). If hardware checks passed - check FS settings - 'fsync' and 'flock' must be enabled. " -const coredumpRecommendations = "Otherwise - please create issue in Application repo." // with backtrace or coredump. To create coredump set compile option 'MDBX_FORCE_ASSERTIONS=1' and env variable 'GOTRACEBACK=crash'." -const recoveryRecommendations = "On default DURABLE mode, power outage can't cause this error. On other modes - power outage may break last transaction and mdbx_chk can recover db in this case, see '-t' and '-0|1|2' options." +// App can re-define this messages from init() func +var CorruptErrorHardwareRecommendations = "Likely because hardware failure. Before creating issue please use tools like https://www.memtest86.com to test RAM and tools like https://www.smartmontools.org to test Disk. To handle hardware risks: use ECC RAM, use RAID of disks, run multiple application instances (or do backups). If hardware checks passed - check FS settings - 'fsync' and 'flock' must be enabled. " +var CorruptErrorBacktraceRecommendations = "Otherwise - please create issue in Application repo." // with backtrace or coredump. To create coredump set compile option 'MDBX_FORCE_ASSERTIONS=1' and env variable 'GOTRACEBACK=crash'." +var CorruptErrorRecoveryRecommendations = "On default DURABLE mode, power outage can't cause this error. On other modes - power outage may break last transaction and mdbx_chk can recover db in this case, see '-t' and '-0|1|2' options." +var CorruptErrorMessage = CorruptErrorHardwareRecommendations + " " + CorruptErrorBacktraceRecommendations + " " + CorruptErrorRecoveryRecommendations func (e Errno) Error() string { if e == Corrupted { - return "MDBX_CORRUPTED: " + hardwareRecommendations + " " + coredumpRecommendations + " " + recoveryRecommendations + return "MDBX_CORRUPTED: " + CorruptErrorMessage } else if e == Panic { - return "MDBX_PANIC: " + hardwareRecommendations + " " + coredumpRecommendations + " " + recoveryRecommendations + return "MDBX_PANIC: " + CorruptErrorMessage } return C.GoString(C.mdbx_strerror(C.int(e))) }