On this page本页内容
MongoDB 3.4 Released Nov 29, 2016
MongoDB 3.4 is now available. Key features include linearizable read concerns, views, and collation.
OpsManager 3.4 is also available. See the Ops Manager documentation and the Ops Manager release notes for more information.
Issues fixed:
Issues fixed:
Issues fixed:
Note
Fixed issues include those that resolve the following Common Vulnerabilities and Exposures (CVEs):
Issues fixed:
Issues fixed:
Issues fixed:
Issues fixed:
Issues fixed:
Issues fixed:
syncSourceHost field to replSetGetStatus output.Issues fixed:
Issues fixed:
mongod to start when unable to reach LDAP server.Issues fixed:
Issues fixed:
mongo host/db connect string.admin.system.users.Issues fixed:
Issues fixed:
Issues fixed:
Issues fixed:
setParameterIssues fixed:
$geoWithin in aggregation pipeline after $lookup and $unwind returns incorrect results.Issues fixed:
mongos can segfault in getMore on views with find batchSize of 0.Issues fixed:
$objectToArray to convert an object to an array of key, value pairs.$arrayToObject to convert an array of pairs to an object.Issues fixed:
mongos crash.$ne should respect collection’s default collation.Issues fixed:
Issues fixed:
readConcern: majority reads on replica set protocolVersion 0 (pv0).mongos may incorrectly return empty result set.$match pipeline stages can combine incorrectly to produce incorrect results.Starting in 3.4, sharded cluster components (shards, config servers, mongos instances) recognize their membership in a sharded cluster, including the name of the sharded cluster, the location of the config servers.
To support this awareness:
shardsvr RequirementFor a 3.4 sharded cluster, mongod instances for the shards must explicitly specify its role as a shardsvr, either via the configuration file setting sharding.clusterRole or via the command line option --shardsvr.
The balancer process has moved from the mongos to the primary member of the config server replica set. Associated with this change:
"balancer" lock, using a process id named "ConfigServer", which is never released.balancerStart command and updates the 3.4 mongo shell method sh.startBalancer() to wrap the new command. A 3.2 or earlier mongo shell method sh.startBalancer() is incompatible with a 3.4 sharded cluster.balancerStop command and updates the 3.4 mongo shell method sh.stopBalancer() to wrap the new command. A 3.2 or earlier mongo shell method sh.stopBalancer() is incompatible with a 3.4 sharded cluster.balancerStatus command.mongo shell method sh.getBalancerHost(). A 3.2 or earlier mongo shell method sh.getBalancerHost() is incompatible with a 3.4 sharded cluster.mongos:sharding.chunkSize configuration file setting and --chunkSize command-line optionsharding.autoSplit configuration file setting and --noAutoSplit command-line optionStarting in MongoDB 3.4:
secondaryThrottle is false for all chunk migrations. The balancer does not wait for replication to a secondary and instead continues with the next document.3.4 sharded clusters no longer support the use of mirrored (SCCC)
mongod instances as config servers. The use of SCCC config servers, deprecated in the 3.2 release, is no longer valid. Instead, deploy your config servers as a replica set (CSRS).
To upgrade your sharded cluster to version 3.4, the config servers must be running as a replica set.
To convert your existing config servers from SCCC to CSRS, see the Upgrade Config Servers to Replica Set.
MongoDB 3.4 introduces Zones, which supersedes tag-aware sharding available in earlier versions.
To support zones, MongoDB introduces the following commands and mongo shell helpers:
| Commands | mongo Shell Methods |
|---|---|
addShardToZone |
sh.addShardToZone() |
removeShardFromZone |
sh.removeShardFromZone() |
updateZoneKeyRange |
majority Write Concern¶A new replica set configuration setting writeConcernMajorityJournalDefault determines whether an acknowledgement for a write concern of majority returns after the majority of the voting members apply the write in memory or to the on-disk journal if the j option is unspecified in the write concern.
A new replica set configuration setting settings.catchUpTimeoutMillis defines the time limit for a newly elected primary to catch up with the other replica set members that may have more recent writes.
MongoDB 3.4 introduces a read concern level of "linearizable" to read data that reflects all successful writes issued with a "majority" and acknowledged prior to the start of the read operation. Linearizable read concern guarantees only apply if read operations specify a query filter that uniquely identifies a single document.
Linearizable read concern is available for all MongoDB supported storage engines.
Combined with "majority" write concern, "linearizable" read concern enables multiple threads to perform reads and writes on a single document as if a single thread performed these operations in real time; that is, the corresponding schedule for these reads and writes is considered linearizable.
Reads with linearizable read concern may be significantly slower than reads with "majority" or "local" read concerns. Always use maxTimeMS with linearizable read concern, in case a majority of data bearing members are unavailable. For example:例如:
For more information on read concern, including operations that support read concerns, see Read Concern.
For details, see Initial Sync and renameCollection.
replSetGetStatus command to accept the optional initialSync: 1 in the command to report on initial sync status and progress if run on the secondary:
3.4 adds support for the decimal128 format with the new decimal data type. The decimal128 format supports numbers with up to 34 decimal digits (i.e. significant digits) and an exponent range of −6143 to +6144.
To support the format, the mongo shell adds the NumberDecimal wrapper.
When performing comparisons among different numerical types, MongoDB performs comparison on the exact stored numerical values without first converting values to a common type.
Unlike the double data type, which only stores an approximation of the decimal values, the decimal data type stores the exact value. For example, a decimal NumberDecimal("9.99") has a precise value of 9.99 where as a double 9.99 would have an approximate value of 9.9900000000000002131628....
To test for decimal type, use the $type operator with the literal "decimal" or 19.
To use the new decimal data type with a MongoDB driver, an upgrade to a driver version that supports the feature is necessary.
3.4 introduces a stage to the aggregation pipeline that allows for recursive search.
| Stage | |
|---|---|
$graphLookup |
Performs a recursive search on a collection. To each output document, adds a new array field that contains the traversal results of the recursive search for that document. |
See also参阅
Faceted search allows for the categorization of documents into classifications. For example, given a collection of inventory documents, you may want to classify items by a single category, such as by the price range, or by multiple categories, such as by price range as well as separately by the departments.
3.4 introduces stages to the aggregation pipeline that allow for faceted search.
| Stage | |
|---|---|
$bucket |
Categorizes or groups incoming documents into buckets that represent a range of values for a specified expression. |
$bucketAuto |
Categorizes or groups incoming documents into specified number of buckets that represent a range of values for a specified expression. MongoDB automatically determines the bucket boundaries. |
$facet |
Processes multiple pipelines on the input documents and outputs a document that contains the results of these pipelines. By specifying facet-related stages ($bucket, $bucketAuto, and $sortByCount) in these pipelines, $facet allows for multi-faceted search. |
$sortByCount |
Categorizes or groups incoming documents by a specified expression to compute the count for each group. Output documents are sorted in descending order by the count. |
3.4 introduces stages to the aggregation pipeline that faciliate replacing documents as well as adding new fields.
| Stage | |
|---|---|
$addFields |
Adds new fields to documents. The stage outputs documents that contains all existing fields from the input documents as well as the newly added fields. |
$replaceRoot |
Replaces a document with the specified document. You can specify a document embedded in the input document to promote the embedded document to the top level. |
3.4 introduces a new stage to the aggregation pipeline that faciliate counting document.
| Stage | |
|---|---|
$count |
Returns a document that contains a count of the number of documents input to the stage. |
| Operator | |
|---|---|
$in |
Returns a boolean that indicates if a specified value is in an array. |
$indexOfArray |
Searches an array for an occurrence of a specified value and returns the array index (zero-based) of the first occurrence. |
$range |
Returns an array whose elements are a generated sequence of numbers. |
$reverseArray |
Returns an output array whose elements are those of the input array but in reverse order. |
$reduce |
Takes an array as input and applies an expression to each element in the array to return the final result of the expression. |
$zip |
Returns an output array where each element is itself an array, consisting of elements in the corresponding array index position from the input arrays. |
| Operator | |
|---|---|
$indexOfBytes |
Searches a string for an occurrence of a substring and returns the UTF-8 byte index (zero-based) of the first occurrence. |
$indexOfCP |
Searches a string for an occurrence of a substring and returns the UTF-8 code point index (zero-based) of the first occurrence. |
$split |
Splits a string by a specified delimiter into string components and returns an array of the string components. |
$strLenBytes |
Returns the number of UTF-8 bytes for a string. |
$strLenCP |
Returns the number of UTF-8 code points for a string. |
$substrBytes |
Returns the substring of a string. The substring starts with the character at the specified UTF-8 byte index (zero-based) in the string for the length specified. |
$substrCP |
Returns the substring of a string. The substring starts with the character at the specified UTF-8 code point index (zero-based) in the string for the length specified. |
| Operator | |
|---|---|
$switch |
Evaluates, in sequential order, the case expressions of the specified branches to enter the first branch for which the case expression evaluates to true. |
| Operator | |
|---|---|
$isoDayOfWeek |
Returns the ISO 8601 weekday number, ranging from 1 (for Monday) to 7 (for Sunday). |
$isoWeek |
Returns the ISO 8601 week number, which can range from 1 to 53. Week numbers start at 1 with the week (Monday through Sunday) that contains the year’s first Thursday. |
$isoWeekYear |
Returns the ISO 8601 year number, where the year starts with the Monday of week 1 (ISO 8601) and ends with the Sundays of the last week (ISO 8601). |
| Operator | |
|---|---|
$collStats |
Returns statistics regarding a collection or view. |
| Operator | |
|---|---|
$type |
Returns a string which specifies the BSON Types of the argument. |
$project stage adds support for field exclusion in the output document. Previously, you could only exclude the _id field in the stage. If you specify the exclusion of a field or fields,
To allow for language-specific rules for string comparison, MongoDB 3.4 introduces collation to its query language and indexes.
The following operations support collation:
| Commands | mongo Shell Methods |
|---|---|
create |
|
createIndexes [1] |
db.collection.createIndex() [1] |
aggregate |
db.collection.aggregate() |
distinct |
db.collection.distinct() |
findAndModify |
|
find |
cursor.collation() to specify collation for db.collection.find() |
mapReduce |
db.collection.mapReduce() |
delete |
|
update |
|
shardCollection |
|
count |
|
Individual update, replace, and delete operations in db.collection.bulkWrite(). |
For details, see Collation.
| [1] | (1, 2) Some index types do not support collation. See Collation and Unsupported Index Types for details. |
MongoDB 3.4 adds support for creating read-only views from existing collections or other views. To specify or define a view, MongoDB 3.4 introduces:
viewOn and pipeline options to the existing create command:
or if specifying a default collation for the view:
mongo shell helper db.createView():
For more information on creating views, see Views.
MongoDB 3.4 adds support for rolling transition to internal authentication for replica sets and sharded clusters. For details, see security.transitionToAuth setting and --transitionToAuth command line option for mongod and mongos.
The privileges of the following built-in roles no longer apply to the local and config databases:
readAnyDatabase |
Starting in 3.4, to provide read privileges on the local database, create a user in the admin database with read role in the local database. See also clusterManager and clusterMonitor role for access to the config and local databases. |
readWriteAnyDatabase |
Starting in 3.4, to provide readWrite privileges on the local database, create a user in the admin database with readWrite role in the local database. See also clusterManager and clusterMonitor role for access to the config and local databases. |
userAdminAnyDatabase |
|
dbAdminAnyDatabase |
Starting in 3.4, to provide dbAdmin privileges on the local database, create a user in the admin database with dbAdmin role in the local database. See also clusterManager and clusterMonitor role for access to the config and local databases. |
Correspondingly, the following built-in roles include additional read and write privileges on local and config databases:
mongoreplay¶MongoDB introduces mongoreplay, a workload capture and analysis tool that replaces mongosniff. You can use mongoreplay to inspect and record commands sent to a MongoDB instance, and then replay the commands back onto another host at a later time.
mongoreplay is available for Linux and macOS.
MongoDB 3.4 includes the following enhancements:
systemd support in distributions.diagnosticDataCollectionDirectorySizeMB default size to 200 megabytes from 100 megabytes.WiredTiger internal cache. Both the WiredTiger Storage Engine internal cache and the inMemory Storage Engine maximum memory size can accept floating-point values.find(), aggregate(), listIndexes, and listCollections operations return a maximum of 16 megabytes per batch.db.currentOp and the database profiler report the same basic diagnostic information for all CRUD operations, including the following:
aggregatecountdeletedistinctfind (OP_QUERY and command)findAndModifygetMore (OP_GET_MORE and command)insertmapReduceupdateThese operations are also included in the logging of slow queries (see slowOpThresholdMs for more information about slow query logging).
mongo shell adds support for marshalling fields of type javascript and javascriptWithScope to JavaScript functions. See --disableJavaScriptProtection.mongod instance presents a certificate signed with a CA trusted by the operating system, the mongo shell will connect without any errors. Previously, the mongo shell exited with an error that it could not validate the certificate.mongo shell and mongod or mongos.
See configuration net.compression.compressors setting as well as the --networkMessageCompressors option for mongod, mongos, and the mongo shell.
For earlier MongoDB Enterprise versions that support Ubuntu 16.04 POWER/PPC64LE:
Due to a lock elision bug present in older versions of the glibc package on Ubuntu 16.04 for POWER, you must upgrade the glibc package to at least glibc 2.23-0ubuntu5 before running MongoDB. Systems with older versions of the glibc package will experience database server crashes and misbehavior due to random memory corruption, and are unsuitable for production deployments of MongoDB
The following summarizes the supported architecture for the latest version of MongoDB products:
| Product | x86_64/amd64 | s390x | POWER8 (little endian) | ARMv8-A |
|---|---|---|---|---|
| MongoDB 3.4 | ✓ | MongoDB Enterprise only | MongoDB Enterprise only | ✓ |
| BI Connector | ✓ | ✓ | ✓ | |
| Compass | ✓ | |||
| Spark Connector | ✓ | |||
| Ops Manager | ✓ | |||
| Automation Agent | ✓ | ✓ | ||
| Monitoring Agent | ✓ | ✓ | ||
| Backup Agent | ✓ | ✓ |
For details, refer to the individual documentation for the products.
MongoDB Enterprise adds support for log redaction for use in conjunction with MongoDB’s encrypted storage engine. Log redaction prevents potentially sensitive information from being written to the diagnostic log; however, diagnostics on redacted logs may be more difficult due to the lack of data related to a log event.
To enable log redaction, see the security.redactClientLogData setting and the --redactClientLogData option for mongod.
MongoDB Enterprise supports the use of Lightweight Directory Access Protocol (LDAP) service to authorize (i.e. determine access) a user authenticated via one of the following authentication mechanism:
For more information, see LDAP Authorization.
mongoldap¶MongoDB Enterprise provides a new tool mongoldap for testing your MongoDB LDAP configuration options against a running LDAP server or set of servers. When configuring options related to LDAP authentication, you can use mongoldap to ensure that the authentication operation works as expected.
MongoDB 3.4 supports binding to an LDAP server via operating system libraries. This allows Linux and Windows MongoDB 3.4 servers to use an LDAP server for authentication.
Linux MongoDB deployments continue to support binding via saslauthd.
Some changes can affect compatibility and may require user actions. For a detailed list of compatibility changes, see Compatibility Changes in MongoDB 3.4.
If you need guidance on upgrading to 3.4, MongoDB offers major version upgrade services to help ensure a smooth transition without interruption to your MongoDB application.
List of known issues in the 3.4.0 release:
protocolVersion: 0 cannot properly support "majority" read concern.Symbol, which is deprecated, is not supported and may lead to undefined behavior.mongos may incorrectly return empty result set.