bbolt
bbolt copied to clipboard
Windows CreateFileMapping: Not enough memory resources
I have a issue opening large DB files on Windows.
The code does not do much here: https://github.com/lunemec/ed-router/blob/96c8fa872b48b5eb83c6afb2b31b24d8106ddbc5/pkg/db/boltdb/boltdb.go#L46
The error I get:
Error: unable to open database: unable to open index DB: index_xyz.db: CreateFileMapping: Not enough memory resources are available to process this command.
The DB files I have are pretty big:
10/11/2020 17:05 35,615,076,352 galaxy.db
10/11/2020 17:10 16,660,320,256 index_xyz.db
The strange thing is, this code works just fine on my MacOS MBP with only 4GB Ram, but not on my Windows machine with 32GB ram, even with swap file enabled to up to 32GB.
How do I open these large databases on windows?
I run Windows 10 Home, version 1083, build 17134.1069 64bit.
I'm working on a PR for an etcd snapshot feature, I fixed an issue in that PR but then I'm running into this issue. I notice the CreateFileMapping call from the Windows API has the parameters as sizeHigh
then sizeLow
but in bbolt, the parameters look reversed.
Does this fix look right? I'm not really a go developer so I don't know how I'd go about testing this but I can submit a PR blind if this is a straightforward.
index 09e00b6..a5a08e9 100644
--- a/bolt_windows.go
+++ b/bolt_windows.go
@@ -72,7 +72,7 @@ func mmap(db *DB, sz int) error {
// Open a file mapping handle.
sizelo := uint32(sz >> 32)
sizehi := uint32(sz) & 0xffffffff
- h, errno := syscall.CreateFileMapping(syscall.Handle(db.file.Fd()), nil, syscall.PAGE_READONLY, sizelo, sizehi, nil)
+ h, errno := syscall.CreateFileMapping(syscall.Handle(db.file.Fd()), nil, syscall.PAGE_READONLY, sizehi, sizelo, nil)
if h == 0 {
return os.NewSyscallError("CreateFileMapping", errno)
}
This issue should have already been fixed,
https://github.com/etcd-io/bbolt/blob/0cecda66e016f212c9d13aa74cfd93cb07948ff6/bolt_windows.go#L79