diff --git a/infer/src/base/MergeResults.ml b/infer/src/base/MergeResults.ml index 53a789b22..1b66d39c4 100644 --- a/infer/src/base/MergeResults.ml +++ b/infer/src/base/MergeResults.ml @@ -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 - diff --git a/infer/src/base/ResultsDatabase.ml b/infer/src/base/ResultsDatabase.ml index 445ff9fba..ae02aabd2 100644 --- a/infer/src/base/ResultsDatabase.ml +++ b/infer/src/base/ResultsDatabase.ml @@ -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 diff --git a/infer/src/base/SqliteUtils.ml b/infer/src/base/SqliteUtils.ml index 6fba6256d..a6213aed5 100644 --- a/infer/src/base/SqliteUtils.ml +++ b/infer/src/base/SqliteUtils.ml @@ -78,4 +78,3 @@ let db_close db = (Printf.sprintf "closing: %s (%s)" (Sqlite3.errcode db |> Sqlite3.Rc.to_string) (Sqlite3.errmsg db))) -