- 快召唤伙伴们来围观吧
- 微博 QQ QQ空间 贴吧
- 文档嵌入链接
- 复制
- 微信扫一扫分享
- 已成功复制到剪贴板
What's New in MongoDB 3.6
为构建反应式实时应用程序而更改流
可重试的写操作,可随时进行写操作
新数据治理控件的带有JSON模式的模式验证
在单个原子更新操作中执行复杂数组操作的完全表达的数组更新
新的安全控制
端到端压缩以创建高效的分布式体系结构
展开查看详情
1 . What’s New in MongoDB 3.6 An overview of new features and enhancements. Adamo Tonete Thursday, May 24th, 2018, at 12:30 PM PDT (UTC-7) / 3:30 PM EDT (UTC-4). 1 © 2018 Percona - COMPANY CONFIDENTIAL
2 .Agenda ● Change streams ● Retryable writes ● Sessions ● Causal consistency ● Schema validation ● Security ● Query enhancements ● Miscellaneous ● Q&A 2 © 2018 Percona - COMPANY CONFIDENTIAL
3 .About me Adamo Tonete ● 10+ years experience on databases. ● Senior Support Engineer ● Based in São Paulo - Brazil 3 © 2018 Percona - COMPANY CONFIDENTIAL
4 .About the release ● 3.6 was announced on Nov 8th, 2017 ● It was the first public version that demonstrated MongoDB was going to have transactions ● A significant security improvement and more than 1k tickets solved in this release ● And a lot more... 4 © 2018 Percona - COMPANY CONFIDENTIAL
5 .Change Stream 5 © 2018 Percona - COMPANY CONFIDENTIAL
6 .Change Streams ● What is ChangeStream and how should we use it? ChangeStream is a feature that notifies application/listeners about changes that has just happened on the database. Resumable across replica-set, shards. 6 © 2018 Percona - COMPANY CONFIDENTIAL
7 .Change Streams What we can captured by change stream: ● Insert ● Delete ● Replace ● Invalidate ● Update 7 © 2018 Percona - COMPANY CONFIDENTIAL
8 .Change Streams foo:PRIMARY> db.foo.watch().pretty() { "_id" : { "_data" : BinData(0,"glsFul0AAAABRmRfaWQAZFsFul0RkbooLbup3ABaEAShVop8GcRExaRR+98mQpN1BA==") }, "operationType" : "insert", "fullDocument" : { "_id" : ObjectId("5b05ba5d1191ba282dbba9dc"), "x" : 2 }, "ns" : { "db" : "adamo", "coll" : "foo" }, "documentKey" : { "_id" : ObjectId("5b05ba5d1191ba282dbba9dc") } } 8 © 2018 Percona - COMPANY CONFIDENTIAL
9 .Change Streams 9 © 2018 Percona - COMPANY CONFIDENTIAL
10 .Change Streams What can be done? Send out emails Create metrics Alerts Similar to triggers 10 © 2018 Percona - COMPANY CONFIDENTIAL
11 .Change Streams Downsides It trusts writeConcern: "majority" so it will take a few milliseconds to receive the stream. Performance is guaranteed until 1,000 streams per instance. If you need more streams, you may notice some performance degradation. However, considering you can have up to 1,000 change streams per instance, it is possible to have 3,000 change streams in a 3-nodes replica-set. 11 © 2018 Percona - COMPANY CONFIDENTIAL
12 .Change Streams More info and examples: https://www.percona.com/blog/2018/03/07/using-mongodb-3-6-change-streams/ 12 © 2018 Percona - COMPANY CONFIDENTIAL
13 .Retryable writes 13 © 2018 Percona - COMPANY CONFIDENTIAL
14 .Retryable writes ● Writes may fail due to network issues, election issues, or any other hardware or communication problems. ● Retryable writes now do have transaction ids that allow the client to check whether the transaction has been applied or not. 14 © 2018 Percona - COMPANY CONFIDENTIAL
15 .Retryable writes Retryable writes will try to re-apply the write when a failure occurs. No more Try Except/catch In the application side. 15 © 2018 Percona - COMPANY CONFIDENTIAL
16 .Retryable writes Considerations ● Drivers must be ready for version 3.6 ● MongoDB server 3.6 is required ● WriteConcern : 1 is the minimum expected ● It does not work with multi line updates/deletes 16 © 2018 Percona - COMPANY CONFIDENTIAL
17 .Retryable writes More info: https://www.percona.com/blog/2018/03/30/mongodb-3-6-retryable-writes-retryable-writes/ 17 © 2018 Percona - COMPANY CONFIDENTIAL
18 .Sessions 18 © 2018 Percona - COMPANY CONFIDENTIAL
19 .Sessions ● Way to reconnect to a previous cursor state. ● Each query has its own session, we can have multiple operations in a session. ● It is possible to list all the sessions from a user and also kill process by its session. 19 © 2018 Percona - COMPANY CONFIDENTIAL
20 .Causal Consistency 20 © 2018 Percona - COMPANY CONFIDENTIAL
21 .Causal Consistency ● Operations may depend on other operations ● We can have independent and causally related operations. What it means; Once an operation is created, the same order will be applied for reads and writes in all the instances. All operations must come from the same thread (session). 21 © 2018 Percona - COMPANY CONFIDENTIAL
22 .Schema validation 22 © 2018 Percona - COMPANY CONFIDENTIAL
23 .Schema validation ● Strict Document Validation ● First version of schema validation was introduced in MongoDB 3.2 It is possible now to ensure a schema for documents and if a field is required or not. 23 © 2018 Percona - COMPANY CONFIDENTIAL
24 .Schema validation test1:PRIMARY> db.createCollection("test", { validator: { $jsonSchema: { bsonType: "object", required: ["x"], properties: { x: { bsonType: "number", description: ”field ‘x’ must be a number" } } } 24 © 2018 Percona - COMPANY CONFIDENTIAL
25 .Schema validation db.createCollection( "test", { validator: { $or: [ { name: { $type: "string" } }, { email: { $regex: /@percona\.com$/ } }, { status: { $in: [ "Active", "Inactive" ] } } ] } } ) 25 © 2018 Percona - COMPANY CONFIDENTIAL
26 .Security 26 © 2018 Percona - COMPANY CONFIDENTIAL
27 .Security A few new improvements on security are: ● The default bindIP is now localhost instead of 0.0.0.0 ● We can restrict users/group to authenticate from a specific IP. ● Similar to 'user'@'192.168.1.10' in mysql! 27 © 2018 Percona - COMPANY CONFIDENTIAL
28 .Security Example of a user creation with authentication restrictions. It is necessary to whiteList the clients ip with a CIDR block notation. 28 © 2018 Percona - COMPANY CONFIDENTIAL
29 .Query enhancements 29 © 2018 Percona - COMPANY CONFIDENTIAL