-
Notifications
You must be signed in to change notification settings - Fork 60
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
Introduce the longer-keys
feature which sets -DMDB_MAXKEYSIZE=0
#263
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @tpunder 👋
What you've done is very cool! I am shocked that I was not aware of this feature before. Than you for your work.
However, could you rename the feature to something more user-firendly (newbie-friendly), please? Something in the vein of read-txn-no-tls
. I am thinking about longer-keys
, infinite-key-length
or unlimited-key-length
. Wat do you think?
I would also like if you could add a description with the advantages, as you describe them in this PR, to the feature of the heed crate (dupsort and stuff), and the limitations and dowsides if there are any (size increase to store length bytes, slowdowns).
BTW @AureliaDolo and @darnuria I don't know if you are aware of this but it fixes your problem with the key-size limits of LMDB when using the DUPSORT
feature 🤩
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for the changes!
@Kerollmops I think I've updated the PR to include the rename. I've also hooked up the It's not clear to me that using I think the database/file format is the same regardless of the I think the only real downsize would be that the database files become potentially non-portable across architectures with different page sizes if you are actually storing long keys. For example: If I create a database on my M1 Macbook Pro (key length limit of 8126 bytes) with a key of size 2000 bytes and then try to open that file on my Intel Macbook pro (key length limit 1982) then I think I would have problems. However, if all of my keys are under 1982 bytes then I don't think there is any problem. |
…ing LMDB By default (and for backwards compatibility) LMDB only allows keys up to 511 bytes in length. If you want larger keys then you need to set "-DMDB_MAXKEYSIZE=0" at compile time. This limit also applies to values when using the MDB_DUPSORT flag on a database.
@Kerollmops I added a note about moving databases between different architectures to the feature flag. I think I also got your proposed changes from above. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for the investigation. Very appreciated 😇
Do you confirm that when using this feature, people will be able to store 2GiB data when opening a database with the DUPSORT
feature? Or will the data length always be restricted to 8192/1982 bytes?
Will merge and do a release just after you fix the remaining issues.
@Kerollmops No, when using the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @tpunder 👋 I can merge only once the files are well formatted (check the CI). You can run a cargo +nightly fmt
on the files you modified, especially heed/src/mdb/lmdb_ffi.rs 😃
…gth. This calls the LMDB mdb_env_get_maxkeysize function.
@Kerollmops I just ran |
longer-keys
feature which sets -DMDB_MAXKEYSIZE=0
when compiling LMDB
longer-keys
feature which sets -DMDB_MAXKEYSIZE=0
when compiling LMDBlonger-keys
feature which sets -DMDB_MAXKEYSIZE=0
[](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [heed](https://togithub.com/Kerollmops/heed) | workspace.dependencies | patch | `0.20.1` -> `0.20.3` | --- ### Release Notes <details> <summary>Kerollmops/heed (heed)</summary> ### [`v0.20.3`](https://togithub.com/meilisearch/heed/releases/tag/v0.20.3): 🛁 [Compare Source](https://togithub.com/Kerollmops/heed/compare/v0.20.2...v0.20.3) <p align="center"><img width="280px" src="https://raw.githubusercontent.com/meilisearch/heed/main/assets/heed-pigeon-logo.png"></a></p> <h1 align="center" >heed</h1> ##### What's Changed * Update dependencies by @​irevoi[https://github.com/meilisearch/heed/pull/265](https://togithub.com/meilisearch/heed/pull/265)ll/265 ### [`v0.20.2`](https://togithub.com/meilisearch/heed/releases/tag/v0.20.2): 🛁 [Compare Source](https://togithub.com/Kerollmops/heed/compare/v0.20.1...v0.20.2) <p align="center"><img width="280px" src="https://raw.githubusercontent.com/meilisearch/heed/main/assets/heed-pigeon-logo.png"></a></p> <h1 align="center" >heed</h1> ##### What's Changed * Introduce the `longer-keys` feature which sets `-DMDB_MAXKEYSIZE=0` by @​tpund[https://github.com/meilisearch/heed/pull/263](https://togithub.com/meilisearch/heed/pull/263)ll/263 * Bump the internal LMDB version to v0.9.33 by @​Kerollmo[https://github.com/meilisearch/heed/pull/264](https://togithub.com/meilisearch/heed/pull/264)ll/264 ##### New Contributors * @​tpunder made their first contributi[https://github.com/meilisearch/heed/pull/263](https://togithub.com/meilisearch/heed/pull/263)ll/263 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 3pm on Wednesday" in timezone America/New_York, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- Release Notes: - N/A <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MzguMCIsInVwZGF0ZWRJblZlciI6IjM3LjQzOC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
[](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [heed](https://togithub.com/Kerollmops/heed) | workspace.dependencies | patch | `0.20.1` -> `0.20.3` | --- ### Release Notes <details> <summary>Kerollmops/heed (heed)</summary> ### [`v0.20.3`](https://togithub.com/meilisearch/heed/releases/tag/v0.20.3): 🛁 [Compare Source](https://togithub.com/Kerollmops/heed/compare/v0.20.2...v0.20.3) <p align="center"><img width="280px" src="https://raw.githubusercontent.com/meilisearch/heed/main/assets/heed-pigeon-logo.png"></a></p> <h1 align="center" >heed</h1> ##### What's Changed * Update dependencies by @&zed-industries#8203;irevoi[https://github.com/meilisearch/heed/pull/265](https://togithub.com/meilisearch/heed/pull/265)ll/265 ### [`v0.20.2`](https://togithub.com/meilisearch/heed/releases/tag/v0.20.2): 🛁 [Compare Source](https://togithub.com/Kerollmops/heed/compare/v0.20.1...v0.20.2) <p align="center"><img width="280px" src="https://raw.githubusercontent.com/meilisearch/heed/main/assets/heed-pigeon-logo.png"></a></p> <h1 align="center" >heed</h1> ##### What's Changed * Introduce the `longer-keys` feature which sets `-DMDB_MAXKEYSIZE=0` by @&zed-industries#8203;tpund[https://github.com/meilisearch/heed/pull/263](https://togithub.com/meilisearch/heed/pull/263)ll/263 * Bump the internal LMDB version to v0.9.33 by @&zed-industries#8203;Kerollmo[https://github.com/meilisearch/heed/pull/264](https://togithub.com/meilisearch/heed/pull/264)ll/264 ##### New Contributors * @&zed-industries#8203;tpunder made their first contributi[https://github.com/meilisearch/heed/pull/263](https://togithub.com/meilisearch/heed/pull/263)ll/263 </details> --- ### Configuration 📅 **Schedule**: Branch creation - "after 3pm on Wednesday" in timezone America/New_York, Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- Release Notes: - N/A <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy40MzguMCIsInVwZGF0ZWRJblZlciI6IjM3LjQzOC4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This PR (which does not have a corresponding issue) adds a
longer-keys
feature tolmdb-master-sys
andheed
which sets-DMDB_MAXKEYSIZE=0
when compiling LMDB. This allows you to use keys that are larger than the default of 511 bytes long.The feature is 100% opt-in.
I've added a conditional test to
lmdb-master-sys
andheed
to check that keys larger than 511 can be successfully stored without returning anMDB_BAD_VALSIZE
error.Enabling this feature also allows you to use values larger than 511 in databases with the
MDB_DUPSORT
flag set (which was the problem I was running into).Here is the documentation snippet from http://www.lmdb.tech/doc/group__internal.html: