-
Notifications
You must be signed in to change notification settings - Fork 58
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception with cursor.Get(k, nil, Set) #96
Comments
That is a strange error. The function causing that panic is The error is probably because I will probably end up having the AFAIK the op in question is the only one which does not return data. Are you aware of any other ops like this @slav? http://www.lmdb.tech/doc/group__mdb.html#ga1206b2af8b95e7f6b0ef6b28708c9127 Thanks for the report. |
Interestingly, on my primary Linux machine I notice that you are running your program in a Windows environment. Perhaps you could run the tests for me on your computer and confirm that the test case I added does in fact reproduce the panic for you? It has been some time since I compiled lmdb-go on Windows myself, so I will have to try to get that environment running again. Branch: bmatsuo/cursor-op-set-testing (commit c9757f4) |
All the tests in branch "bmatsuo/cursor-op-set-testing" pass on windows. I'm also unaware which ops init key/data and which don't. Documentation is only specific about MDB_SET_KEY to return key + data. |
I have pushed a commit to that branch (bmatsuo/cursor-op-set-testing). I have a working fix that I will upload to another branch and issue a pull request to respect the process. Thanks again for your help, @slav. It is very much appreciated. |
Fixes #96 Issue #56 illustrated that working with Go memory using "C-style" memory does not work well in modern Go runtimes. That problem was thought to be properly addressed, but #96 showed a lingering case where Set does not modify MDB_val key passed to mdb_cursor_get. This commit addresses this lingering case by special-casing return value processing for the Set operation of Cursor.Get. If LMDB will not modify the MDB_val, the returned key must use non-standard methods for copying the value. Likewise, when txn.RawRead is true the Cursor.Get must use a special method to ensure that the returned key shares memory with the corresponding input argument.
Fixes #96 Issue #56 illustrated that working with Go memory using "C-style" access patterns does not work well in modern Go runtimes. That problem was thought to be properly addressed, but #96 showed a lingering case where Set does not modify MDB_val key passed to mdb_cursor_get. This commit addresses this lingering case by special-casing return value processing for the Set operation of Cursor.Get. If LMDB will not modify the MDB_val, the returned key must use non-standard methods for copying the value. Likewise, when txn.RawRead is true the Cursor.Get must use a special method to ensure that the returned key shares memory with the corresponding input argument.
I have db with dup values (not sure if relevant). When I'm trying to do
k, v, e = cursor.Get(buf.Bytes(), nil, lmdb.Set)
I get exception (see below). Withk, v, e = cursor.Get(buf.Bytes(), nil, lmdb.SetKey)
it works. Just Set positions cursor at the key but doesn't read value. But cursor.Get still attempts to read it which leads to the exception.The text was updated successfully, but these errors were encountered: