Skip to content

Commit bc62b22

Browse files
committed
fix test suite on openbsd, document openbsd limitations
fixes drycpp#6
1 parent 29bca15 commit bc62b22

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,19 @@ possible LMDB error conditions:
329329
* `MDB_KEYEXIST` and `MDB_NOTFOUND` are handled specially by some functions.
330330

331331

332+
333+
## OpenBSD
334+
335+
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).
336+
337+
In the mean-time, on OpenBSD you should always open environments with the `MDB_WRITEMAP` flag:
338+
339+
env.open("/path/to/db/", MDB_WRITEMAP);
340+
341+
Because nested transactions are incompatible with `MDB_WRITEMAP`, they cannot be used on OpenBSD. The test suite disables the nested transaction tests on OpenBSD.
342+
343+
344+
332345
## Support
333346

334347
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).

check.cc

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,19 @@
77

88

99
int main() {
10+
unsigned int envFlags = 0;
11+
12+
#ifdef __OpenBSD__
13+
envFlags = MDB_WRITEMAP;
14+
#endif
15+
16+
1017
std::string longLivedValue;
1118

1219
try {
1320
auto env = lmdb::env::create();
1421
env.set_max_dbs(64);
15-
env.open("testdb/");
22+
env.open("testdb/", envFlags);
1623
lmdb::dbi mydb;
1724
lmdb::dbi mydbdups;
1825

@@ -250,6 +257,8 @@ int main() {
250257

251258
// Nested transactions
252259

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

@@ -332,6 +341,7 @@ int main() {
332341

333342
if (!caught) throw std::runtime_error("bad nested tx 5");
334343
}
344+
#endif
335345

336346

337347

@@ -374,7 +384,7 @@ int main() {
374384
auto env = lmdb::env::create();
375385
env.set_max_dbs(64);
376386
env.set_mapsize(30000);
377-
env.open("testdb/");
387+
env.open("testdb/", envFlags);
378388

379389
lmdb::dbi mydb;
380390

0 commit comments

Comments
 (0)