Skip to content

Commit

Permalink
fix test suite on openbsd, document openbsd limitations
Browse files Browse the repository at this point in the history
fixes drycpp#6
  • Loading branch information
hoytech committed May 7, 2021
1 parent 29bca15 commit bc62b22
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 2 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,19 @@ possible LMDB error conditions:
* `MDB_KEYEXIST` and `MDB_NOTFOUND` are handled specially by some functions.



## OpenBSD

OpenBSD is only partially supported by LMDB. The issue is that OpenBSD does not have a unified buffer cache. This means that modifications made to a file through `write()` will not be visible to processes that have memory mapped the file. This is something that [may be fixed some day](http://openbsd-archive.7691.n7.nabble.com/Will-mmap-and-the-read-buffer-cache-be-unified-anyone-working-with-it-td271270.html).

In the mean-time, on OpenBSD you should always open environments with the `MDB_WRITEMAP` flag:

env.open("/path/to/db/", MDB_WRITEMAP);

Because nested transactions are incompatible with `MDB_WRITEMAP`, they cannot be used on OpenBSD. The test suite disables the nested transaction tests on OpenBSD.



## Support

To report a bug or submit a patch for lmdb++, please file an issue in the [issue tracker on GitHub](https://github.com/hoytech/lmdbxx/issues).
Expand Down
14 changes: 12 additions & 2 deletions check.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,19 @@


int main() {
unsigned int envFlags = 0;

#ifdef __OpenBSD__
envFlags = MDB_WRITEMAP;
#endif


std::string longLivedValue;

try {
auto env = lmdb::env::create();
env.set_max_dbs(64);
env.open("testdb/");
env.open("testdb/", envFlags);
lmdb::dbi mydb;
lmdb::dbi mydbdups;

Expand Down Expand Up @@ -250,6 +257,8 @@ int main() {

// Nested transactions

// These tests will fail when WRITEMAP enabled, which must be done on OpenBSD
#ifndef __OpenBSD__
{
auto txn = lmdb::txn::begin(env);

Expand Down Expand Up @@ -332,6 +341,7 @@ int main() {

if (!caught) throw std::runtime_error("bad nested tx 5");
}
#endif



Expand Down Expand Up @@ -374,7 +384,7 @@ int main() {
auto env = lmdb::env::create();
env.set_max_dbs(64);
env.set_mapsize(30000);
env.open("testdb/");
env.open("testdb/", envFlags);

lmdb::dbi mydb;

Expand Down

0 comments on commit bc62b22

Please sign in to comment.