Skip to content

Commit

Permalink
Add specific error handling and message for MDBX_MAP_FULL scenario.
Browse files Browse the repository at this point in the history
  • Loading branch information
JkLondon committed Feb 3, 2025
1 parent c6c6c6e commit b6fe156
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions mdbx/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,19 @@ var CorruptErrorHardwareRecommendations = "Maybe free space is over on disk. Oth
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
var MapFullErrorRecommendation = "Environment map size limit is reached, please try to rm -rf /path/to/db"

func (e Errno) Error() string {
if e == Corrupted {
switch e {
case Corrupted:
return fmt.Sprintf("MDBX_FATAL(%d): ", int(e)) + CorruptErrorMessage
}
if e == Panic {
case Panic:
return fmt.Sprintf("MDBX_PANIC(%d): ", int(e)) + CorruptErrorMessage
case MapFull:
return fmt.Sprintf("MDBX_MAP_FULL(%d)", int(e)) + MapFullErrorRecommendation
default:
return C.GoString(C.mdbx_strerror(C.int(e)))
}
return C.GoString(C.mdbx_strerror(C.int(e)))
}

// _operrno is for use by tests that can't import C
Expand Down

0 comments on commit b6fe156

Please sign in to comment.