4

according to the Berkeley documentation the Transactional (TS) and the Concurrent Datastore version of the Database, multiple threads may access (and change) the database.

Does this also mean that I can have 2 programs linked to the berkely 'client' and have them access the same database file without any problems?

(I ask, since for a separate database server this would be no problem of course, but in the case of Berkeley the database engine is linked long with your program)

thanks!

R

Toad
  • 15,593
  • 16
  • 82
  • 128
  • I seem to recall that the Berkeley DB can be opened with a locking flag so that access will be synchronized. Note that this does NOT work if the Berkeley DB is being accessed over NFS (potentially by multiple hosts). – PP. Nov 17 '09 at 16:14
  • See http://www.oracle.com/technology/documentation/berkeley-db/db/gsg/C/dbconfig.html#Locking – PP. Nov 17 '09 at 16:16
  • pp: the documentation link you provided doesn't give an answer on this. – Toad Nov 17 '09 at 20:44
  • Correct link: http://download.oracle.com/docs/cd/E17076_02/html/gsg/C/dbconfig.html#Locking – codeape Oct 19 '11 at 08:52
  • This may not work for all cases, but i just stood up a Embedded GrizzlyServer/Servlet container and exposed GET/POST/DELETE Rest endpoints...i didn't get much of a performance drop. – Jeryl Cook Apr 24 '15 at 18:29
  • Still, I did not get any solution from any answers. Did anyone find any solution to use Berkeley DB with multiple java processes? – Chintan Patel Aug 05 '19 at 20:11

2 Answers2

4

Some documentation seems to think you can use the same database concurrently from multiple processes as well as from multiple threads. Specifically:

"Multiple processes, or multiple threads in a single process, can all use the database at the same time as each uses the Berkeley DB library. Low-level services like locking, transaction logging, shared buffer management, memory management, and so on are all handled transparently by the library."

A cursory read did not shed any light on what BDB uses to control access from multiple processes, but if filesystem locks are used, access from multiple processes on a network filesystems may well be problematic.

codeape
  • 97,830
  • 24
  • 159
  • 188
Tuure Laurinolli
  • 4,016
  • 1
  • 22
  • 21
4

Chapter 16: The Locking Subsystem from the reference guide looks promising.

codeape
  • 97,830
  • 24
  • 159
  • 188