Skip to content

Commit

Permalink
Configurable corrupt error recommendations (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov authored Jan 25, 2022
1 parent a27ff3a commit 5f76661
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions mdbx/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)))
}
Expand Down

0 comments on commit 5f76661

Please sign in to comment.