Never close db connection

Reviewed By: jvillard

Differential Revision: D6231432

fbshipit-source-id: a33f57d
master
Martino Luca 7 years ago committed by Facebook Github Bot
parent b07269ab71
commit a57a6078bc

@ -38,8 +38,6 @@ WHERE
let merge ~db_file =
(* no need to wrap all the individual table merges in a single transaction (to batch writes)
because we open the table with synchronous=OFF *)
let main_db = ResultsDatabase.get_database () in
SqliteUtils.check_sqlite_error ~fatal:true
~log:(Printf.sprintf "attaching database '%s'" db_file)
@ -69,4 +67,3 @@ let merge_buck_flavors_results infer_deps_file =
List.iter ~f:one_line lines
| Error error ->
L.internal_error "Couldn't read deps file '%s': %s" infer_deps_file error

@ -103,13 +103,10 @@ let db_close () =
let new_database_connection () =
(* we always want at most one connection alive throughout the lifetime of the module *)
db_close () ;
let db = Sqlite3.db_open ~mode:`NO_CREATE ~cache:`PRIVATE ~mutex:`FULL database_fullpath in
Sqlite3.busy_timeout db 10_000 ;
(* Higher level of "synchronous" are only useful to guarantee that the db will not be corrupted if the machine crashes for some reason before the data has been actually written to disk. We do not need this kind of guarantee for infer results as one can always rerun infer if interrupted. *)
SqliteUtils.exec db ~log:"synchronous=OFF" ~stmt:"PRAGMA synchronous=OFF" ;
SqliteUtils.exec db ~log:"synchronous=NORMAL" ~stmt:"PRAGMA synchronous=NORMAL" ;
database := Some db ;
List.iter ~f:(fun callback -> callback db) !new_db_callbacks
let () = Epilogues.register "closing results database" ~f:db_close

@ -78,4 +78,3 @@ let db_close db =
(Printf.sprintf "closing: %s (%s)"
(Sqlite3.errcode db |> Sqlite3.Rc.to_string)
(Sqlite3.errmsg db)))

Loading…
Cancel
Save