I'm running into what I think is a thread safety issue under the tcl
interface to berkeleydb.
I made a very simple web page in aolserver (which is multithreaded)
which does this:
set db [berkdb open /tmp/test.bdb test]
puts [$db count x]
$db close
It works fine, except under high load, when the "$db count" command
gives
Looking at the docs, I'm not seeing a way to enable multithreading from
the tcl interface. And looking at the C source, it seems that
something is very wrong if this db info pointer is missing.
So... questions:
1) is the tcl bdb interface thread safe, assuming no data sharing
between threads (ie, the code example above)
2) do I need to wrap all my bdb code with semaphores, and if so, will
that work?
-john
This comment in tcl_db_pkg.c sounds bad:
/*
* If/when our Tcl interface becomes thread-safe, we should enable
* DB_THREAD here in all cases. For now, we turn it on later in this
* function, and only when we're in testing and we specify the
* -thread flag, so that we can exercise MUTEX_THREAD_LOCK cases.
*
* In order to become truly thread-safe, we need to look at making sure
* DBTCL_INFO structs are safe to share across threads (they're not
* mutex-protected) before we declare the Tcl interface thread-safe.
* Meanwhile, there's no strong reason to enable DB_THREAD when not
* testing.
*/