couchbase / forestdb

A Fast Key-Value Storage Engine Based on Hierarchical B+-Tree Trie
Apache License 2.0
1.29k stars 173 forks source link

libmusl compatibility #11

Closed jlopez closed 8 years ago

jlopez commented 8 years ago

I'm working on compiling couchbase on alpine linux. There were just two changes needed to get forestdb to successfully run all tests:

spin_t

The existing code doesn't call spin_init() for some (most?) spin_t variables. The code works fine, however, since SPIN_INITIALIZER seems to be properly 'initializing' them. This is not the case when running on libmusl though, and calling spin_lock() on such 'initialized' spin_t's leads to a deadlock.

While the proper solution would entail properly initializing all spin_t variables by calling spin_init(), I'm reluctant to do so, as there's no clear place where this can be done. Instead, setting the initializer to the correct value for musl (spin_t)(0) instead of (spin_t)(1) does the trick.

pthread stack

Threads are crashing since the default musl pthread stack size is only 80k as opposed to the 2Mb when running on glibc. So I'm explicitly setting the stack size to 2Mb.

Change-Id: I02f7f4123a8d46d0ce1cef2285ac8fcefe02dc0d

chiyoung commented 8 years ago

Thanks for reporting these issues.

We made a fix to the spin lock init issue:

http://review.couchbase.org/#/c/64846/

Regarding the pthread stack size limit, we will address it with a slightly different way soon and also make sure that we don't allocate large chunk memory in the local stack.

jlopez commented 8 years ago

Great! I'll close this pull request then.