bbolt icon indicating copy to clipboard operation
bbolt copied to clipboard

DB.Close(): funlock error

Open kwf2030 opened this issue 9 years ago • 7 comments

windows 10 x64 golang 1.9.1 and 1.8.4 bbolt v1.3.1-coreos.2(no problem with v1.3.1-coreos.1)

error when calling bolt.DB.Close(): 2017/10/10 11:05:57 bolt.Close(): funlock error: The segment is already unlocked.

coreos/bbolt#35(Support no timeout locks on db files) lead to this issue

kwf2030 avatar Oct 10 '17 03:10 kwf2030

It looks like this patch (my mistake) locked the wrong file descriptor.

Before the patch the file descriptor used was based on db.lockfile: err := lockFileEx(syscall.Handle(db.lockfile.Fd()), flag, 0, 1, 0, &syscall.Overlapped{})

The patch factored it out of the loop, but based on db.file: fd := db.file.Fd() ... err := lockFileEx(syscall.Handle(fd), flag, 0, 1, 0, &syscall.Overlapped{})

The file vs. lockfile subtlety seems to exist only on Windows, as the db struct definition tells.

I could happily patch it but I don't have anymore (and won't have for the coming months) a Windows platform to test it. But if you have one, let me know and we can do it together.

rgeronimi avatar Oct 29 '17 16:10 rgeronimi

I just modified bolt_windows.go at line 65, change fd := db.file.Fd() to fd := f.Fd() and it seems fixed @rgeronimi

kwf2030 avatar Oct 31 '17 01:10 kwf2030

LGTM

rgeronimi avatar Oct 31 '17 16:10 rgeronimi

can you send a patch to fix this?

xiang90 avatar Oct 31 '17 16:10 xiang90

@rgeronimi @xiang90 I have just create a pr #64

kwf2030 avatar Nov 01 '17 00:11 kwf2030

fixed by #64

xiang90 avatar Nov 01 '17 01:11 xiang90

Thks

rgeronimi avatar Nov 01 '17 11:11 rgeronimi