MongoDB 3.6
Features and their Benefits
2
Who is David Murphy
David Murphy● XXXXXX
● Sessions● Change Streams● Retryable Writes● Security and Improvements● Major changes for Arrays● A better Balancer● Better Time Management● PSMDB 3.6●
Agenda
Sessions - What and Why
What did MongoDB <2.4 do for connections?
And MongoDB 2.4-3.4 connections?
Connections Evolved in 3.6 (Sessions)
Why a sessionDid you ever need to do a lot of writes, then had a step down in middle?How complicated was it to “resume” where you left off?How sure where you when using $inc that the value was updated or not?
Sessions allow us to:★ Resume where we left off★ Have a new connections resume a session and ask for the GetLastError★ Have confidence in what was or was not completed
Change Streams vs. OpLog
What is an Oplog?● Used by Replication to Record all changes to data
○ Drop Collection and similar command are single operations○ Multi-Drop or Multi-Update create one person per document changed
● Circular Buffer Collection○ Specific Size, can never be more or less○ Removes old operation when it writes a new one○ Not indexes on timestamp
● Never Directly replicated● Create a single mutex across all database, as this is a server-wide
change log● Uses tailable cursor to let drive get check the new events
What is a ChangeStream?● Lists changes like Oplog
○ Changes are persisted to other nodes, unlike Oplog● Can show the full document changes within a small margin● Can be filtered to just display what you need● Is shard capable● Only for one namespace at a time● Election safe, and more stable than Oplog for Hadoop and Elasticsearch
type connectors● Reduces / Prevents rollback possibilities that plagues tailable cursors and
the Oplog in the past
Considerations● Typically used with .watch() function in many drivers● Not fit for large numbers of namespaces as the overhead gets very
expensive. Stick to <500-1000 streams● No “all” namespace change stream possible● fullDocument is a fuzzy few which might not have been the document
when the operation occurred. ○ 16MB limit applies to changeStream document, fullDocument must be smaller
● Use filter to avoid unneeded network overhead● Busy sharded system might not be able to keep up● Set maxAwaitTimeMS if you think you might not always have a write in
every second.
What's in a Write? Safe Retrying it.
Sessions and WritesSessions allow you to reconnect to existing work and retry or resume an operation, so why are we here?
These retries depend on a few things
● 3.6 Drive● Server Running 3.6 Feature Compatibility Version● Replication● A non 0 writeConcern
It also only retries after serverSelectionTimeoutMS is expired
Typically 30s so may need tuning
Security Matters!
Bind IP
Now defaults to localhost not 0.0.0.0
This means for sharding and replica-set you MUST set it to your 10.X or public addresses.
User Restrictions
Also called CIDR white listing MongoDB can finally limit hosts allowed to use usernames.
Security Improvements
Arrays and Objects get a facelift
18
Non-Aggregation
arrayFilters
Multi-element Updates
Arrays
$arrayToObject
$objectToArray
$mergeObjects
Changes
Date$dateFromString$dateFromParts$dateToParts
General$hint$comment$$REMOVE
MongoDB Balancer - Turbo Mode
20
Math for number of concurrent maximum chunk moves:
((Number of Shards) / 2) - 0|1
-1 if shard count is not even
If you have
2 shards 1 move at a time
3 shards 1 move at a time
4 shards 1-2 moves at a time (usually 2)
Parallel Balancer
Times and Clocks in 3.6
22
Oplog now containing WT for wall time and it user to keep things ordered.
This is powered by something called a “Lamport Clock”, its rather complex but you can and should read up on it.
For now it gives you something called Causal Consistency between shards and nodes. But more importantly it are core starting point toward real multi-document transactions!
Cluster Time
Percona Server for MongoDB 3.6
24
RocksDB
Is now deprecated, you can force its usage in PSMDB 3.6, but we encourage you not to.
It is not compatible with some of the new timestamp-based features in 3.6, and so even if you force it by following the manual, it will not allows these features.
IF YOU ARE on MongoRocks, we strongly encourage you to move to WiredTiger prior to upgrading to 3.6.
Changes in PSMDB
25
Rate the Session
Thank You!