Vendors/lmdb: Change the default sync flags
The default was unsafe but fast, we change that to the safe version.
This commit is contained in:
parent
39e8c4f6b5
commit
bfeff69794
@ -204,13 +204,13 @@ let list_sub l pos len =
|
|||||||
else inner (h :: acc, pred n) t in
|
else inner (h :: acc, pred n) t in
|
||||||
inner ([], len) l
|
inner ([], len) l
|
||||||
|
|
||||||
let with_rw_cursor_lwt ?sync ?metasync ?flags ?name { dir ; parent } ~f =
|
let with_rw_cursor_lwt ?nosync ?nometasync ?flags ?name { dir ; parent } ~f =
|
||||||
let local_parent =
|
let local_parent =
|
||||||
match Lwt.get parent with
|
match Lwt.get parent with
|
||||||
| None -> None
|
| None -> None
|
||||||
| Some (txn, _db, _cursor) -> Some txn in
|
| Some (txn, _db, _cursor) -> Some txn in
|
||||||
Lmdb.create_rw_txn
|
Lmdb.create_rw_txn
|
||||||
?sync ?metasync ?parent:local_parent dir >>=? fun txn ->
|
?nosync ?nometasync ?parent:local_parent dir >>=? fun txn ->
|
||||||
Lmdb.opendb ?flags ?name txn >>=? fun db ->
|
Lmdb.opendb ?flags ?name txn >>=? fun db ->
|
||||||
Lmdb.opencursor txn db >>=? fun cursor ->
|
Lmdb.opencursor txn db >>=? fun cursor ->
|
||||||
Lwt.with_value parent (Some (txn, db, cursor)) begin fun () ->
|
Lwt.with_value parent (Some (txn, db, cursor)) begin fun () ->
|
||||||
|
16
vendors/ocaml-lmdb/src/lmdb.ml
vendored
16
vendors/ocaml-lmdb/src/lmdb.ml
vendored
@ -344,8 +344,8 @@ let rawtxn_of_txn : type a. a txn -> rawtxn = function
|
|||||||
external txn_begin :
|
external txn_begin :
|
||||||
t -> int -> rawtxn option -> (rawtxn, int) result = "stub_mdb_txn_begin"
|
t -> int -> rawtxn option -> (rawtxn, int) result = "stub_mdb_txn_begin"
|
||||||
|
|
||||||
let create_rw_txn ?(sync=true) ?(metasync=true) ?parent t =
|
let create_rw_txn ?(nosync=false) ?(nometasync=false) ?parent t =
|
||||||
let flags = match sync, metasync with
|
let flags = match nosync, nometasync with
|
||||||
| true, true -> int_of_flags_env [NoSync; NoMetaSync]
|
| true, true -> int_of_flags_env [NoSync; NoMetaSync]
|
||||||
| true, false -> int_of_flag_env NoSync
|
| true, false -> int_of_flag_env NoSync
|
||||||
| false, true -> int_of_flag_env NoMetaSync
|
| false, true -> int_of_flag_env NoMetaSync
|
||||||
@ -354,8 +354,8 @@ let create_rw_txn ?(sync=true) ?(metasync=true) ?parent t =
|
|||||||
| Error i -> Error (error_of_int i)
|
| Error i -> Error (error_of_int i)
|
||||||
| Ok tx -> Ok (Txn_rw tx)
|
| Ok tx -> Ok (Txn_rw tx)
|
||||||
|
|
||||||
let create_ro_txn ?(sync=true) ?(metasync=true) ?parent t =
|
let create_ro_txn ?(nosync=false) ?(nometasync=false) ?parent t =
|
||||||
let flags = match sync, metasync with
|
let flags = match nosync, nometasync with
|
||||||
| true, true -> int_of_flags_env [RdOnly; NoSync; NoMetaSync]
|
| true, true -> int_of_flags_env [RdOnly; NoSync; NoMetaSync]
|
||||||
| true, false -> int_of_flags_env [RdOnly; NoSync]
|
| true, false -> int_of_flags_env [RdOnly; NoSync]
|
||||||
| false, true -> int_of_flags_env [RdOnly; NoMetaSync]
|
| false, true -> int_of_flags_env [RdOnly; NoMetaSync]
|
||||||
@ -420,8 +420,8 @@ external db_drop :
|
|||||||
let db_drop txn dbi =
|
let db_drop txn dbi =
|
||||||
return (db_drop (rawtxn_of_txn txn) dbi false) ()
|
return (db_drop (rawtxn_of_txn txn) dbi false) ()
|
||||||
|
|
||||||
let with_ro_db ?sync ?metasync ?parent ?flags ?name t ~f =
|
let with_ro_db ?nosync ?nometasync ?parent ?flags ?name t ~f =
|
||||||
create_ro_txn ?sync ?metasync ?parent t >>= fun txn ->
|
create_ro_txn ?nosync ?nometasync ?parent t >>= fun txn ->
|
||||||
opendb ?flags ?name txn >>= fun db ->
|
opendb ?flags ?name txn >>= fun db ->
|
||||||
match f txn db with
|
match f txn db with
|
||||||
| exception exn ->
|
| exception exn ->
|
||||||
@ -434,8 +434,8 @@ let with_ro_db ?sync ?metasync ?parent ?flags ?name t ~f =
|
|||||||
abort_txn txn ;
|
abort_txn txn ;
|
||||||
Error err
|
Error err
|
||||||
|
|
||||||
let with_rw_db ?sync ?metasync ?parent ?flags ?name t ~f =
|
let with_rw_db ?nosync ?nometasync ?parent ?flags ?name t ~f =
|
||||||
create_rw_txn ?sync ?metasync ?parent t >>= fun txn ->
|
create_rw_txn ?nosync ?nometasync ?parent t >>= fun txn ->
|
||||||
opendb ?flags ?name txn >>= fun db ->
|
opendb ?flags ?name txn >>= fun db ->
|
||||||
match f txn db with
|
match f txn db with
|
||||||
| exception exn ->
|
| exception exn ->
|
||||||
|
8
vendors/ocaml-lmdb/src/lmdb.mli
vendored
8
vendors/ocaml-lmdb/src/lmdb.mli
vendored
@ -112,11 +112,11 @@ val set_mapsize : t -> int64 -> (unit, error) result
|
|||||||
type _ txn
|
type _ txn
|
||||||
|
|
||||||
val create_rw_txn :
|
val create_rw_txn :
|
||||||
?sync:bool -> ?metasync:bool ->
|
?nosync:bool -> ?nometasync:bool ->
|
||||||
?parent:rw txn -> t -> (rw txn, error) result
|
?parent:rw txn -> t -> (rw txn, error) result
|
||||||
|
|
||||||
val create_ro_txn :
|
val create_ro_txn :
|
||||||
?sync:bool -> ?metasync:bool ->
|
?nosync:bool -> ?nometasync:bool ->
|
||||||
?parent:_ txn -> t -> (ro txn, error) result
|
?parent:_ txn -> t -> (ro txn, error) result
|
||||||
|
|
||||||
val get_txn_id : _ txn -> int
|
val get_txn_id : _ txn -> int
|
||||||
@ -147,13 +147,13 @@ val db_flags : _ txn -> db -> (flag_open list, error) result
|
|||||||
val db_drop : _ txn -> db -> (unit, error) result
|
val db_drop : _ txn -> db -> (unit, error) result
|
||||||
|
|
||||||
val with_ro_db :
|
val with_ro_db :
|
||||||
?sync:bool -> ?metasync:bool ->
|
?nosync:bool -> ?nometasync:bool ->
|
||||||
?parent:_ txn -> ?flags:flag_open list ->
|
?parent:_ txn -> ?flags:flag_open list ->
|
||||||
?name:string -> t -> f:(ro txn -> db -> ('a, error) result) ->
|
?name:string -> t -> f:(ro txn -> db -> ('a, error) result) ->
|
||||||
('a, error) result
|
('a, error) result
|
||||||
|
|
||||||
val with_rw_db :
|
val with_rw_db :
|
||||||
?sync:bool -> ?metasync:bool ->
|
?nosync:bool -> ?nometasync:bool ->
|
||||||
?parent:rw txn -> ?flags:flag_open list ->
|
?parent:rw txn -> ?flags:flag_open list ->
|
||||||
?name:string -> t -> f:(rw txn -> db -> ('a, error) result) ->
|
?name:string -> t -> f:(rw txn -> db -> ('a, error) result) ->
|
||||||
('a, error) result
|
('a, error) result
|
||||||
|
Loading…
Reference in New Issue
Block a user