简体   繁体   中英

Write data to Mongodb

Currently we are using

@collection.update id, c_doc, upsert: true, safe: true

Does setting the safe flag to True confirms that the data is actually written to the slaves and then written or it just confirms that the data is written to primary?

safe = true means that the primary has acknowledged the write. It is not guaranteed to be replicated to slaves yet, nor is it safe to assume it's stored on disk. The documentation at https://github.com/mongodb/mongo-ruby-driver/wiki/Write-Concern explains the different write concerns.

None of the w= options confirm writing to disk, for that you need "fsync=1". But you really should not be using that as it hurts performance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM