sidnt / lmdz

0 stars 0 forks source link

story of 5 mdb_put s #40

Open sidnt opened 4 years ago

sidnt commented 4 years ago

i want to modify 5 keys transactionally. previously these keys were put in an mdb env x. let's assume that env x is operating under single¹ unnamed dbi "". i want to change all the keys, but the update should be made visible only as one state jump. mdb_put will be the most primitive of the operations that will definitely be called, at lower levels.

mdb_put(
  txn-handle,
  dbi-handle, key, value,
  flags-for-this-mdb_put
)

now. for each unique dbi-handle, key tuple, i could address a unique location in lmdb. dbi-handle is a global static on our app, so only key is used to address different values.

now i could create 5 transaction handles, in mdb-env-x.

(when we say writes are always serialised, we mean mdb_txn_commit or mdb_put?)

¹ but there could be multiple dbis and these keys might be distributed arbitrarily over them

i properly


ripland stupid question

true/false

sidnt commented 4 years ago

a doubt. i have to modify 5 keys and expose these changes as one state jump. i will use

mdb_put(
  txn-handle,
  dbi-handle, key, value,
  flags-for-this-mdb_put
)

implA: make a txn handle 1, make 5 calls of mdb_put with this same txn handle 1. then after call mdb_txn_commit(tx-handle-1)

implB: make 5 txn handles 1 .. 5. make 5 calls of mdb_put with each of these 5 txn handles used once. commit in sequence.

implC: make 5 txn handles 1 .. 5. nest them linearly like a linked list,