Skip to content
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

Value of mdb_mapsize in lmdb-safe.cc #2

Open
maxwong opened this issue Jun 6, 2019 · 2 comments
Open

Value of mdb_mapsize in lmdb-safe.cc #2

maxwong opened this issue Jun 6, 2019 · 2 comments

Comments

@maxwong
Copy link

maxwong commented Jun 6, 2019

Hi there, thanks for the great job for this neat project.
But I have a question in lmdb-safe.cc, line 30 - 31:

  if(mdb_env_set_mapsize(d_env, 16ULL*4096*244140ULL)) // 4GB
    throw std::runtime_error("setting map size");

But 16ULL * 4096 * 244140ULL != 4GB (4 * 1024 * 1024 * 1024?). Is it a typo or a purposed feature? Not sure about it.

And it will be great if users can set some configs when getting the env, especially those can only be set after calling mdb_env_create() but before mdb_env_open(), (e.g. maxdbs). Is there any plan for this? Maybe something like wrapping those configs in a class and pass it when calling getMdbEnv().

Thanks.

@horazont
Copy link
Contributor

Having this a constant is indeed not great (for starters, the default constant isn’t going to work on 32 bit systems at all).

I’m not sure what a good way of setting it would be though, given that the Environment is essentially a (per file descriptor) singleton:

  • Do all calls need to set a (the same) size?
  • Would a differing size be an error or a resize request?
  • What if a resize request happens while the environment is still open (we’d have to halt all transactions in some way)?

I don’t have necessarily good answers. I have a proposal, but it’d be hard to implement and get right:

  • Opening an environment without argument: re-use the size of the (existing) environment
  • With size
    • If not open: open and resize
    • If already open and size differs: block until all transactions have finished; block new transactions from starting. Resize the environment. Allow transactions to continue.

Would that work? Would it make sense?

@maxwong
Copy link
Author

maxwong commented May 11, 2020

Sorry for the late reply.
Auto resize looks good. But I also suggest giving an option to users, allowing them to disable auto resize.

Error handling strategies may differ in different libraries / systems. It will be difficult to debug if these strategies are different.
So I personally prefer more manual control in the storage engine layer. If there is an existing db being open with a different dbsize, throwing an exception or returning an error code (but not core dump) will be good. The application can decide what to do with the error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants