Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does boltdb support concurrent queries for reading and updating the db? [closed]

Currently using boltdb for storing various entries in the bucket.

How can I use goroutines and channels in reading and updating in the db?

like image 858
Raunak Dugar Avatar asked Jan 08 '23 05:01

Raunak Dugar


1 Answers

Generally, yes you can, provided you pay attention to the following points:

  • all accesses should be done in their own transactions. Transactions should not be shared between goroutines (whether they are read-only or read-write).

  • boltdb only tolerates one writer at a given point in time. If multiple concurrent transactions try to write at the same time, they will be serialized. The consistency of the database is guaranteed, but it has an impact on the performance, since write operations cannot be parallelized.

  • read-only transactions are executed concurrently (and potentially parallelized).

  • open only one transaction in a given goroutine at the same time to avoid deadlock situations.

like image 191
Didier Spezia Avatar answered Jan 13 '23 13:01

Didier Spezia