The wait is over officially for MongoDB 4.2. Now in it’s second release candidate (rc1), Eliot Horowitz CTO and co-founder MongoDB previewed some of the key features in the keynote at MongoDB World 2019, Newyork. In this article we will be discussing about all the new features of MongoDB 4.2.
Distributed Transactions
MongoDB 4.0 introduced the Multi document transactions for high level transaction support. Now the transaction handling has got lifted up to the next level with Distributed Transactions.MongoDB sharded clusters will be able to handle the transactions. If anyone of the transaction in a shard has failed to commit then the entire transaction will be rollback in all the shards. Initially we had 16 MB size limit on transaction documents which is now lifted we can do now arbitrary transactions.
Large Transactions
Mongodb 4.2 now allows to handle large transactions. Lets see how things actually work behind the scenes, large transactions are written as multiple operations in oplog entries and link them together as a chain.When that particular transaction commits all the operations in the transaction looks visible.When we look into the oplog the transaction has multiple updates each with timestamp(ts) and prevOptime that will help to link all the operations together.
Mutable Shard key values
Before MonogoDB 4.2 a document’s shard key field value is immutable. But after the release of version 4.2 we can update the shard key value in the sharded clusters. We cannot issue the update command directly into the shard but it should be fired in a transaction or as a retryable write.
Client-Side Field-Level Encryption
Ransomware attacks and data breach is so common these days. Data protection at the server level is risk nowadays even though its encrypted. MongoDB brings out an interesting encryption feature where the encryption is handled out of the server. MongoDB 4.2 handles the field level encryption, even the server doesn’t know what fields encrypted. The data encryption and decryption is completely handled in the driver level.
Wildcard Indexes
Previously MongoDB used the text indexes to improve the search for regex queries. There may be scenarios where we need to search a text content that is present in a document on different fields, here text indexes will not help much. MongoDB 4.2 brings out the wildcard indexes where it automatically matches any field or embedded document fields that needed to be queried.
This new release going to make a great impact for those industries who were looking for transactions in the distributed systems.