Use WriteConcern/SAFE by default
WriteConcern/NORMAL is ridiculously dangerous and most apps simply do not have performance requirements to justify completely ignoring server responses.
This commit is contained in:
parent
e2b6c6e21b
commit
fbd00ee151
3 changed files with 9 additions and 1 deletions
|
|
@ -26,7 +26,7 @@
|
||||||
|
|
||||||
(declare ^:dynamic ^Mongo *mongodb-connection*)
|
(declare ^:dynamic ^Mongo *mongodb-connection*)
|
||||||
(declare ^:dynamic ^DB *mongodb-database*)
|
(declare ^:dynamic ^DB *mongodb-database*)
|
||||||
(def ^:dynamic ^WriteConcern *mongodb-write-concern* WriteConcern/NORMAL)
|
(def ^:dynamic ^WriteConcern *mongodb-write-concern* WriteConcern/SAFE)
|
||||||
|
|
||||||
|
|
||||||
;;
|
;;
|
||||||
|
|
@ -84,6 +84,11 @@
|
||||||
(def ^:dynamic *mongodb-database* db))
|
(def ^:dynamic *mongodb-database* db))
|
||||||
|
|
||||||
|
|
||||||
|
(defn set-write-concern!
|
||||||
|
[wc]
|
||||||
|
(def ^:dynamic *mongodb-write-concern* wc))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
(defprotocol Countable
|
(defprotocol Countable
|
||||||
(count [this] "Returns size of the object"))
|
(count [this] "Returns size of the object"))
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@
|
||||||
|
|
||||||
(use-fixtures :each purge-people-collection purge-docs-collection purge-things-collection purge-libraries-collection)
|
(use-fixtures :each purge-people-collection purge-docs-collection purge-things-collection purge-libraries-collection)
|
||||||
|
|
||||||
|
(monger.core/set-write-concern! WriteConcern/SAFE)
|
||||||
|
|
||||||
;;
|
;;
|
||||||
;; insert
|
;; insert
|
||||||
|
|
|
||||||
|
|
@ -27,6 +27,8 @@
|
||||||
;; Tests
|
;; Tests
|
||||||
;;
|
;;
|
||||||
|
|
||||||
|
(monger.core/set-write-concern! WriteConcern/NORMAL)
|
||||||
|
|
||||||
(deftest insert-large-batches-of-documents-without-object-ids
|
(deftest insert-large-batches-of-documents-without-object-ids
|
||||||
(doseq [n [1000 10000 100000]]
|
(doseq [n [1000 10000 100000]]
|
||||||
(let [collection "things"
|
(let [collection "things"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue