MongoDB Padding Clarification -


Looking through the use of MongoDB, a question came up on the following question:

"You After adding them, you can update the documents in a collection, however, these updates may not cause the document to rise. If the update operation causes the document to proceed from its original size If updated, the update operation will fail. "

It seems reasonable, if not completely explained for reasons and it leads me to think, "If I do not want to grow the document, but possibly add more information (ie: pushing for $ array), So what would be wrong with pading the document in my required size? "

Then my base will be fair (for me anyway), till it is correct till reading this piece.

Warning Do not manually padded documents in a cached collection. Applying manual padding to the document in an overlapping collection can break the replica. In addition, padding is not preserved if you sync again the Mongodaby example.

And then it raises my question, "Why is this so?" Or to write this specially:

  1. Why would padding a document in a capped collection in this letter "Brake Replica"?

  2. Is there a small part of the document, explaining the reasons for this? Or is it the "dark magic" of inner workings of the overlapping compilation? (Perhaps "part associated with padding" is not a part)

  3. Or is it very pessimistic and there really is no reason that you can not pad in this way ? (At least in recent versions).

    If anyone can appreciate some of this statement why are true but can be certain.

    Although it isn strictly programming I manual padding technology is considered as the programming technique , and hence the question here left it.

    Why will this document padding a document in the caps collection in "Brake Replication"?

    I think the documentation can be a bit more vigilant here (see) Mangoodybi has no way to know whether the use of the field padding_foobar is manual padding Or the system has important information, so the technique generally works, but

    Warning is: MongoDB < Em> initial replication will always pack the data completely, so when Rnbhik Replica will be unable then you change the size of the document, document later go .

    An example (Note: I will use only the content size here, which is not correct, because area names, type IDs, terminators and string lengths also take place, but it only consolidates the logic ):

      // 1. Insert w / 20 bytes enter 'content' ({"name": "John", "pad": "0000000000000000"}); // 2. Now we are updating, by removing 16 bytes of padding, adding 3 bytes, we now have 7 bytes of "content" update ({"name": "john"}, {$ unset: {" Pad ": 1}, $ set: {" foo ":" bar "}}); // 3. At this point, we can easily move the document again, as long as the original size (/ "name": "zone"}, {$ set: {"Foo" : "Barfobar"}});   

    Now when the initial replication happened after step 2), the document is repeated without padding fields, so there are only 7 bytes of 'content size' on the replication. In that case, the operation in step 3 will fail because it increases before the "original size" of the replication of the document, which does not match the original size of the master's document.

    In other words, the technique is fine if and only when your updated object size is strictly keeping or decreasing, even if you can ensure that your application is in logic (eg, because There is only one update on such a document, sometimes) can only answer a few.

Comments

Popular posts from this blog

c - Mpirun hangs when mpi send and recieve is put in a loop -

python - Apply coupon to a customer's subscription based on non-stripe related actions on the site -

java - Unable to get JDBC connection in Spring application to MySQL -