Going in MongoDB 4.2
There's a lot going into MongoDB 4.2, like on-demand materialized views, pipeline powered updates and distributed transactions. And as we cleared the way for those new features, so we moved on and various commands and features that were previously deprecated are now completely removed. For the TL;DR team, we'll reduce it to a quick checklist:
- Use MMAPv1?
- You'll need to migrate to WiredTiger.
- Use SSL options in scripts and config files?
- You'll need to use TLS versions of the SSL options as we modernize the naming.
- Use eval to run scripts on the server?
- Use transactions to get a similar effect.
- Use group or geoNear commands?
- Use the aggregation framework instead.
- Use maxScan in your finds?
- Migrate to using maxTimeMS.
- Use copyDatabase or cloneDatabase?
- Use mongodump and mongorestore to emulate the feature.
- Use repairDatabase?
- Check out the compact and reIndex commands.
And don't forget to read the 4.2 release notes, or read on for the essential details.
MMAPv1 goes away completely
Deprecated in MongoDB 4.0, the MMAPv1 storage engine and all its related flags and options are removed in MongoDB 4.2. If you are still using MMAPv1 and you've made it to MongoDB 4.0, this means that you must migrate to WiredTiger before moving to MongoDB 4.2; there is no way to migrate MMAPv1 data directly into MongoDB 4.2. As well as removing the storage engine, all the configuration options and command line flags related to MMAPv1 have been removed too.
The MMAPv1 storage engine has served MongoDB well, and we'd like to thank it for its service to databases. Time has, though moved on, and modern demands on databases require a modern storage engine - that's where WiredTiger is shining now.
Practical impacts? All the storage.mmapv1
options in config files are no longer supported. Old MMAPv1 options like newCollectionsUsePowerOf2Sizes
and replIndexPrefetch
have been removed. Further details are in the 4.2 release notes.
We would like to remember MMAPv1 as the storage engine that got us where we are today. Simple, yet powerful, it made the MongoDB you run today possible; this is more a viking funeral, than a feature being removed.
And if you are still running MMAPv1, start making plans to migrate.
SSL is no more, long live TLS
No, we haven't removed SSL encryption, but we have moved to consistently calling it what it is currently called; TLS (Transport Level Security). We deprecated the SSL versions of the options back in 4.0, replacing them with functionally identical TLS commands and options. That includes connection strings though ssl=true will continue working for a while. The new TLS options for mongod
, mongos
and mongo shell are listed in the documentation for MongoDB 4.2. When migrating existing scripts and tools, keep an eye open for the use of the now-removed ssl options.
Eval has left the building
The eval
command itself was deprecated way back at MongoDB 3.0. What's changed in MongoDB 4.2 is that the Mongo shell now will only accept the db.eval
command when working with a 4.0 or earlier server. The eval
command went because it no longer made sense to take a global lock on the server when running a script, blocking all operations on the database. Many uses of eval
used that global lock to ensure consistency on the database as it ran cross collection transactions. Since 4.0, it's been more sensible and effective to use MongoDB's transaction support to get those guarantees without effectively shutting down the server, which is what eval
did.
Other Commands that have left
There's also some commands which are no longer relevant. For example, using group with a collection no longer works. That's because now we recommend using the aggregation framework's $group
stage: it's far more efficient and with the rest of the pipeline framework, more powerful. Another command, geoNear
, is also being removed and users are directed to use aggregation's $geonear
stage. It works slightly differently, so consult the guide to migrating geoNear in the release notes.
The db.copyDatabase
shell command, is still about if you are talking to an older server - it's a wrapper around the copyDB command there. If you are talking to 4.0 or 4.2 though, there's no copyDB
command (deprecated since 4.0) for it to wrap. Similarly, the cloneDatabase
shell command is also no longer supported. You can work around this with mongodump
and mongorestore
if you wish.
Another command that has gone from the underlying server commands and the MongoDB shell is repairDatabase. A compact command has replaced the compaction options of repairDatabase
, reindexing (on a standalone database) is handled by reIndex
on collections. And recovery from an unexpectedly halted database is handled by a --repair
option on mongod. Again, there's notes and links in the release notes on this particular change.
MaxScan is gone
Deprecated in MongoDB 4.2, maxscan
allowed you to limit find queries to a particular number of documents or index keys. It was, though a simplistic limiting metric which had interesting corner cases. Now removed completely in 4.2, replace code that uses it with maxTimeMS, using time taken rather than number of documents as a limit.
And that's it for 4.2's leavers
That's the highlights of what's no longer in 4.2. Now, you can move on to use MongoDB 4.2's new features, use pipelines to power your updates, aggregate to create new updatable views on-demand and get wildcarding with your indexes.