Skip to content

Commit ab2e760

Browse files
JkLondonJkLondon
andauthored
Add error handling for MDBX_MAP_FULL with descriptive error messages (#161)
* Add error handling for MDBX_MAP_FULL with descriptive error messages * Allow cmake installation downgrade in GitHub Actions workflow setup. --------- Co-authored-by: JkLondon <ilya@mikheev.fun>
1 parent f71fbcb commit ab2e760

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ jobs:
3434
- name: Install dependencies
3535
run: |
3636
choco upgrade mingw -y --no-progress --version 13.2.0
37-
choco install cmake -y --no-progress --version 3.27.8
37+
choco install cmake -y --no-progress --version 3.27.8 --allow-downgrade
3838
3939
- uses: actions/checkout@v4
4040
- uses: actions/setup-go@v5

mdbx/error.go

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,19 @@ var CorruptErrorHardwareRecommendations = "Maybe free space is over on disk. Oth
8484
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'."
8585
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."
8686
var CorruptErrorMessage = CorruptErrorHardwareRecommendations + " " + CorruptErrorBacktraceRecommendations + " " + CorruptErrorRecoveryRecommendations
87+
var MapFullErrorMessage = "The allocated database storage size limit has been reached."
8788

8889
func (e Errno) Error() string {
89-
if e == Corrupted {
90-
return "MDBX_FATAL: " + CorruptErrorMessage
90+
switch e {
91+
case Corrupted:
92+
return fmt.Sprintf("MDBX_FATAL(%d): ", int(e)) + CorruptErrorMessage
93+
case Panic:
94+
return fmt.Sprintf("MDBX_PANIC(%d): ", int(e)) + CorruptErrorMessage
95+
case MapFull:
96+
return fmt.Sprintf("MDBX_MAP_FULL(%d)", int(e)) + MapFullErrorMessage
97+
default:
98+
return C.GoString(C.mdbx_strerror(C.int(e)))
9199
}
92-
if e == Panic {
93-
return "MDBX_PANIC: " + CorruptErrorMessage
94-
}
95-
return C.GoString(C.mdbx_strerror(C.int(e)))
96100
}
97101

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

0 commit comments

Comments
 (0)