crossdb-org / crossdb

Ultra High-performance Lightweight Embedded and Server OLTP RDBMS✨
https://crossdb.org
Mozilla Public License 2.0
184 stars 12 forks source link

how "safe" is concurrent writing / reading using golang or other language binding? #25

Closed sprappcom closed 1 month ago

sprappcom commented 1 month ago

i havent check the code in detail but i'm assuming it's using mmap but for the locking mechanism also mmap?

  1. can you point out the code area where the concurrency is "locked / unlocked"?

  2. how thread safe is the concurrent reading / writing? i'm currently only using golang binding to do the read and write in separate unrelated programs and it seemed to work very well but i'm not sure if i can crash it in future etc.

pls do mention the caveats or limitations if any for

  1. programming language binding
  2. what i need to look out for to prevent data corruption or race conditions etc.
jcwangxp commented 1 month ago

The lock can be OS process scope or OS thread scope transaction lock: xdb_wrlock_table storage lock: xdb_wrlock_tblstg, xdb_rdlock_tblstg on-disk DB needs WAL to recover power cycle or crash during DB access, which is under development. in theory, lang binding doesn't need to care about the concurrency, you only need to config the DB mode correctly by your application access: multi-process or multi-thread.