mongo 2.19.3 → 2.20.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +37 -1
- data/Rakefile +81 -172
- data/lib/mongo/cluster/topology/base.rb +16 -0
- data/lib/mongo/cluster.rb +27 -1
- data/lib/mongo/collection/view/iterable.rb +1 -0
- data/lib/mongo/collection.rb +4 -2
- data/lib/mongo/config.rb +2 -2
- data/lib/mongo/error/transactions_not_supported.rb +34 -0
- data/lib/mongo/error.rb +1 -0
- data/lib/mongo/grid/fs_bucket.rb +6 -0
- data/lib/mongo/monitoring/event/secure.rb +1 -1
- data/lib/mongo/operation/shared/executable.rb +43 -27
- data/lib/mongo/operation/shared/response_handling.rb +23 -25
- data/lib/mongo/retryable/base_worker.rb +28 -3
- data/lib/mongo/retryable/read_worker.rb +16 -14
- data/lib/mongo/retryable/write_worker.rb +11 -8
- data/lib/mongo/retryable.rb +2 -2
- data/lib/mongo/server/app_metadata/environment.rb +64 -9
- data/lib/mongo/server/app_metadata.rb +5 -4
- data/lib/mongo/server/description/features.rb +1 -0
- data/lib/mongo/server/pending_connection.rb +19 -6
- data/lib/mongo/server_selector/base.rb +32 -6
- data/lib/mongo/session/server_session/dirtyable.rb +52 -0
- data/lib/mongo/session/server_session.rb +3 -0
- data/lib/mongo/session/session_pool.rb +12 -18
- data/lib/mongo/session.rb +32 -0
- data/lib/mongo/socket/ssl.rb +22 -1
- data/lib/mongo/uri.rb +0 -4
- data/lib/mongo/version.rb +1 -5
- data/mongo.gemspec +9 -18
- data/spec/atlas/atlas_connectivity_spec.rb +4 -4
- data/spec/faas/ruby-sam-app/Gemfile +9 -0
- data/spec/faas/ruby-sam-app/mongodb/Gemfile +4 -0
- data/spec/faas/ruby-sam-app/mongodb/app.rb +149 -0
- data/spec/faas/ruby-sam-app/template.yaml +48 -0
- data/spec/integration/client_side_encryption/corpus_spec.rb +10 -2
- data/spec/integration/client_side_encryption/range_explicit_encryption_prose_spec.rb +3 -0
- data/spec/integration/retryable_reads_errors_spec.rb +196 -31
- data/spec/integration/retryable_writes_errors_spec.rb +156 -0
- data/spec/integration/sdam_error_handling_spec.rb +2 -0
- data/spec/lite_spec_helper.rb +0 -10
- data/spec/mongo/cluster_spec.rb +36 -0
- data/spec/mongo/collection/view/aggregation_spec.rb +6 -1
- data/spec/mongo/collection/view/explainable_spec.rb +2 -0
- data/spec/mongo/collection_crud_spec.rb +2 -1
- data/spec/mongo/operation/insert_spec.rb +1 -1
- data/spec/mongo/retryable/write_worker_spec.rb +39 -0
- data/spec/mongo/server/app_metadata/environment_spec.rb +135 -0
- data/spec/mongo/server/app_metadata_spec.rb +12 -2
- data/spec/mongo/server/connection_spec.rb +26 -0
- data/spec/mongo/session/session_pool_spec.rb +1 -16
- data/spec/mongo/session_transaction_spec.rb +15 -0
- data/spec/mongo/uri_spec.rb +0 -9
- data/spec/runners/crud/test.rb +0 -8
- data/spec/runners/crud.rb +1 -1
- data/spec/runners/transactions/test.rb +12 -3
- data/spec/runners/unified/assertions.rb +16 -3
- data/spec/runners/unified/crud_operations.rb +12 -0
- data/spec/runners/unified/support_operations.rb +3 -5
- data/spec/runners/unified/test.rb +8 -1
- data/spec/spec_tests/data/client_side_encryption/explain.yml +2 -2
- data/spec/spec_tests/data/client_side_encryption/fle2v2-BypassQueryAnalysis.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Compact.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-CreateCollection.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-DecryptExistingData.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Delete.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-EncryptedFields-vs-EncryptedFieldsMap.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-EncryptedFields-vs-jsonSchema.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-EncryptedFieldsMap-defaults.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-FindOneAndUpdate.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-InsertFind-Indexed.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-InsertFind-Unindexed.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-MissingKey.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-NoEncryption.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Date-Aggregate.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Date-Correctness.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Date-Delete.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Date-FindOneAndUpdate.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Date-InsertFind.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Date-Update.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Decimal-Aggregate.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Decimal-Correctness.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Decimal-Delete.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Decimal-FindOneAndUpdate.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Decimal-InsertFind.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Decimal-Update.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DecimalPrecision-Aggregate.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DecimalPrecision-Correctness.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DecimalPrecision-Delete.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DecimalPrecision-FindOneAndUpdate.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DecimalPrecision-InsertFind.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DecimalPrecision-Update.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Double-Aggregate.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Double-Correctness.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Double-Delete.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Double-FindOneAndUpdate.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Double-InsertFind.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Double-Update.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DoublePrecision-Aggregate.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DoublePrecision-Correctness.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DoublePrecision-Delete.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DoublePrecision-FindOneAndUpdate.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DoublePrecision-InsertFind.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-DoublePrecision-Update.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Int-Aggregate.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Int-Correctness.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Int-Delete.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Int-FindOneAndUpdate.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Int-InsertFind.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Int-Update.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Long-Aggregate.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Long-Correctness.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Long-Delete.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Long-FindOneAndUpdate.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Long-InsertFind.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-Long-Update.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Range-WrongType.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-Update.yml +1 -0
- data/spec/spec_tests/data/client_side_encryption/fle2v2-validatorAndPartialFieldExpression.yml +2 -1
- data/spec/spec_tests/data/connection_string/invalid-uris.yml +0 -10
- data/spec/spec_tests/data/connection_string/valid-options.yml +13 -0
- data/spec/spec_tests/data/crud_unified/aggregate-write-readPreference.yml +2 -0
- data/spec/spec_tests/data/crud_unified/db-aggregate-write-readPreference.yml +2 -0
- data/spec/spec_tests/data/crud_unified/find-test-all-options.yml +348 -0
- data/spec/spec_tests/data/index_management/createSearchIndex.yml +5 -3
- data/spec/spec_tests/data/index_management/createSearchIndexes.yml +7 -4
- data/spec/spec_tests/data/index_management/dropSearchIndex.yml +2 -1
- data/spec/spec_tests/data/index_management/listSearchIndexes.yml +13 -7
- data/spec/spec_tests/data/index_management/updateSearchIndex.yml +2 -1
- data/spec/spec_tests/data/retryable_writes/unified/bulkWrite-serverErrors.yml +3 -6
- data/spec/spec_tests/data/retryable_writes/unified/insertOne-serverErrors.yml +3 -6
- data/spec/spec_tests/data/run_command_unified/runCommand.yml +319 -0
- data/spec/spec_tests/data/sessions_unified/driver-sessions-dirty-session-errors.yml +351 -0
- data/spec/spec_tests/data/unified/valid-pass/poc-crud.yml +1 -1
- data/spec/spec_tests/data/unified/valid-pass/poc-retryable-writes.yml +7 -7
- data/spec/spec_tests/data/unified/valid-pass/poc-sessions.yml +3 -4
- data/spec/spec_tests/data/unified/valid-pass/poc-transactions-convenient-api.yml +1 -1
- data/spec/spec_tests/data/unified/valid-pass/poc-transactions-mongos-pin-auto.yml +1 -1
- data/spec/spec_tests/data/unified/valid-pass/poc-transactions.yml +3 -3
- data/spec/spec_tests/run_command_unified_spec.rb +13 -0
- data/spec/spec_tests/sdam_unified_spec.rb +2 -0
- data/spec/spec_tests/transactions_unified_spec.rb +2 -1
- data/spec/support/certificates/atlas-ocsp-ca.crt +89 -77
- data/spec/support/certificates/atlas-ocsp.crt +117 -122
- data/spec/support/certificates/retrieve-atlas-cert +1 -1
- data/spec/support/constraints.rb +6 -0
- data/spec/support/ocsp +1 -1
- data/spec/support/recording_logger.rb +27 -0
- metadata +1245 -1298
- checksums.yaml.gz.sig +0 -0
- data/spec/shared/LICENSE +0 -20
- data/spec/shared/bin/get-mongodb-download-url +0 -17
- data/spec/shared/bin/s3-copy +0 -45
- data/spec/shared/bin/s3-upload +0 -69
- data/spec/shared/lib/mrss/child_process_helper.rb +0 -80
- data/spec/shared/lib/mrss/cluster_config.rb +0 -231
- data/spec/shared/lib/mrss/constraints.rb +0 -378
- data/spec/shared/lib/mrss/docker_runner.rb +0 -295
- data/spec/shared/lib/mrss/eg_config_utils.rb +0 -51
- data/spec/shared/lib/mrss/event_subscriber.rb +0 -210
- data/spec/shared/lib/mrss/lite_constraints.rb +0 -238
- data/spec/shared/lib/mrss/server_version_registry.rb +0 -113
- data/spec/shared/lib/mrss/session_registry.rb +0 -69
- data/spec/shared/lib/mrss/session_registry_legacy.rb +0 -60
- data/spec/shared/lib/mrss/spec_organizer.rb +0 -179
- data/spec/shared/lib/mrss/utils.rb +0 -37
- data/spec/shared/share/Dockerfile.erb +0 -330
- data/spec/shared/share/haproxy-1.conf +0 -16
- data/spec/shared/share/haproxy-2.conf +0 -17
- data/spec/shared/shlib/config.sh +0 -27
- data/spec/shared/shlib/distro.sh +0 -74
- data/spec/shared/shlib/server.sh +0 -416
- data/spec/shared/shlib/set_env.sh +0 -169
- data/spec/spec_tests/data/cmap/pool-clear-interrupt-immediately.yml +0 -49
- data/spec/support/faas/app/aws_lambda/mongodb/Gemfile.lock +0 -19
- data.tar.gz.sig +0 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1a641cd6128fd246b0ac9999f00167631548206573a22989968f2a7a132bc0ae
|
4
|
+
data.tar.gz: d5526d1ca34219ac644191f1e2c7177877c70063cc5a97992379e8e86065d0ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c23fd9abff5c29517b2cf0c0094bedfbbe667a96f2494b36e6465d8bbfbe113cd08f05e72d15b6db17ef35a211c4aaa040c20dc99eb65417c3c3690b7712c59
|
7
|
+
data.tar.gz: 54ffbc332168455337aa4de863db0ca179084a35c271e9f21dbfe2425556bd00e02b2fd46a5c2581aa15d5e9a11b84d9a0c231889774adb129f2ad38b997f4f4
|
data/README.md
CHANGED
@@ -5,7 +5,43 @@ MongoDB Ruby Driver
|
|
5
5
|
|
6
6
|
The officially supported Ruby driver for [MongoDB](https://www.mongodb.org/).
|
7
7
|
|
8
|
-
The Ruby driver supports Ruby 2.
|
8
|
+
The Ruby driver supports Ruby 2.7-3.3 and JRuby 9.3-9.4.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Install via RubyGems, either via the command-line for ad-hoc uses:
|
13
|
+
|
14
|
+
$ gem install mongo
|
15
|
+
|
16
|
+
Or via a Gemfile for more general use:
|
17
|
+
|
18
|
+
gem 'mongo'
|
19
|
+
|
20
|
+
### Release Integrity
|
21
|
+
|
22
|
+
Each release of the MongoDB Ruby driver after version 2.20.0 has been automatically built and signed using the team's GPG key.
|
23
|
+
|
24
|
+
To verify the driver's gem file:
|
25
|
+
|
26
|
+
1. [Download the GPG key](https://pgp.mongodb.com/ruby-driver.asc).
|
27
|
+
2. Import the key into your GPG keyring with `gpg --import ruby-driver.asc`.
|
28
|
+
3. Download the gem file (if you don't already have it). You can download it from RubyGems with `gem fetch mongo`, or you can download it from the [releases page](https://github.com/mongodb/mongo-ruby-driver/releases) on GitHub.
|
29
|
+
4. Download the corresponding detached signature file from the [same release](https://github.com/mongodb/mongo-ruby-driver/releases). Look at the bottom of the release that corresponds to the gem file, under the 'Assets' list, for a `.sig` file with the same version number as the gem you wish to install.
|
30
|
+
5. Verify the gem with `gpg --verify mongo-X.Y.Z.gem.sig mongo-X.Y.Z.gem` (replacing `X.Y.Z` with the actual version number).
|
31
|
+
|
32
|
+
You are looking for text like "Good signature from "MongoDB Ruby Driver Release Signing Key <packaging@mongodb.com>" in the output. If you see that, the signature was found to correspond to the given gem file.
|
33
|
+
|
34
|
+
(Note that other output, like "This key is not certified with a trusted signature!", is related to *web of trust* and depends on how strongly you, personally, trust the `ruby-driver.asc` key that you downloaded from us. To learn more, see https://www.gnupg.org/gph/en/manual/x334.html)
|
35
|
+
|
36
|
+
### Why not use RubyGems' gem-signing functionality?
|
37
|
+
|
38
|
+
RubyGems' own gem signing is problematic, most significantly because there is no established chain of trust related to the keys used to sign gems. RubyGems' own documentation admits that "this method of signing gems is not widely used" (see https://guides.rubygems.org/security/). Discussions about this in the RubyGems community have been off-and-on for more than a decade, and while a solution will eventually arrive, we have settled on using GPG instead for the following reasons:
|
39
|
+
|
40
|
+
1. Many of the other driver teams at MongoDB are using GPG to sign their product releases. Consistency with the other teams means that we can reuse existing tooling for our own product releases.
|
41
|
+
2. GPG is widely available and has existing tools and procedures for dealing with web of trust (though they are admittedly quite arcane and intimidating to the uninitiated, unfortunately).
|
42
|
+
|
43
|
+
Ultimately, most users do not bother to verify gems, and will not be impacted by our choice of GPG over RubyGems' native method.
|
44
|
+
|
9
45
|
|
10
46
|
## Documentation
|
11
47
|
|
data/Rakefile
CHANGED
@@ -2,17 +2,12 @@
|
|
2
2
|
# rubocop:todo all
|
3
3
|
|
4
4
|
require 'bundler'
|
5
|
-
require 'bundler/gem_tasks'
|
6
5
|
require 'rspec/core/rake_task'
|
7
|
-
# TODO move the mongo require into the individual tasks that actually need it
|
8
|
-
require 'mongo'
|
9
6
|
|
10
7
|
ROOT = File.expand_path(File.join(File.dirname(__FILE__)))
|
11
8
|
|
12
9
|
$: << File.join(ROOT, 'spec/shared/lib')
|
13
10
|
|
14
|
-
require 'mrss/spec_organizer'
|
15
|
-
|
16
11
|
CLASSIFIERS = [
|
17
12
|
[%r,^mongo/server,, :unit_server],
|
18
13
|
[%r,^mongo,, :unit],
|
@@ -33,18 +28,67 @@ RUN_PRIORITY = %i(
|
|
33
28
|
spec spec_sdam_integration
|
34
29
|
)
|
35
30
|
|
36
|
-
tasks = Rake.application.instance_variable_get('@tasks')
|
37
|
-
tasks['release:do'] = tasks.delete('release')
|
38
|
-
|
39
31
|
RSpec::Core::RakeTask.new(:spec) do |t|
|
40
32
|
#t.rspec_opts = "--profile 5" if ENV['CI']
|
41
33
|
end
|
42
34
|
|
43
35
|
task :default => ['spec:prepare', :spec]
|
44
36
|
|
37
|
+
# stands in for the Bundler-provided `build` task, which builds the
|
38
|
+
# gem for this project. Our release process builds the gems in a
|
39
|
+
# particular way, in a GitHub action. This task is just to help remind
|
40
|
+
# developers of that fact.
|
41
|
+
task :build do
|
42
|
+
abort <<~WARNING
|
43
|
+
`rake build` does nothing in this project. The gem must be built via
|
44
|
+
the `Driver Release` action on GitHub, which is triggered manually when
|
45
|
+
a new release is ready.
|
46
|
+
WARNING
|
47
|
+
end
|
48
|
+
|
49
|
+
# `rake version` is used by the deployment system so get the release version
|
50
|
+
# of the product beng deployed. It must do nothing more than just print the
|
51
|
+
# product version number.
|
52
|
+
#
|
53
|
+
# See the mongodb-labs/driver-github-tools/ruby/publish Github action.
|
54
|
+
desc "Print the current value of Mongo::VERSION"
|
55
|
+
task :version do
|
56
|
+
require 'mongo/version'
|
57
|
+
|
58
|
+
puts Mongo::VERSION
|
59
|
+
end
|
60
|
+
|
61
|
+
# overrides the default Bundler-provided `release` task, which also
|
62
|
+
# builds the gem. Our release process assumes the gem has already
|
63
|
+
# been built (and signed via GPG), so we just need `rake release` to
|
64
|
+
# push the gem to rubygems.
|
65
|
+
task :release do
|
66
|
+
require 'mongo/version'
|
67
|
+
|
68
|
+
if ENV['GITHUB_ACTION'].nil?
|
69
|
+
abort <<~WARNING
|
70
|
+
`rake release` must be invoked from the `Driver Release` GitHub action,
|
71
|
+
and must not be invoked locally. This ensures the gem is properly signed
|
72
|
+
and distributed by the appropriate user.
|
73
|
+
|
74
|
+
Note that it is the `rubygems/release-gem@v1` step in the `Driver Release`
|
75
|
+
action that invokes this task. Do not rename or remove this task, or the
|
76
|
+
release-gem step will fail. Reimplement this task with caution.
|
77
|
+
|
78
|
+
mongo-#{Mongo::VERSION}.gem was NOT pushed to RubyGems.
|
79
|
+
WARNING
|
80
|
+
end
|
81
|
+
|
82
|
+
system 'gem', 'push', "mongo-#{Mongo::VERSION}.gem"
|
83
|
+
end
|
84
|
+
|
85
|
+
task :mongo do
|
86
|
+
require 'mongo'
|
87
|
+
end
|
88
|
+
|
45
89
|
namespace :spec do
|
46
90
|
desc 'Creates necessary user accounts in the cluster'
|
47
|
-
task :
|
91
|
+
task prepare: :mongo do
|
48
92
|
$: << File.join(File.dirname(__FILE__), 'spec')
|
49
93
|
|
50
94
|
require 'support/utils'
|
@@ -53,7 +97,7 @@ namespace :spec do
|
|
53
97
|
end
|
54
98
|
|
55
99
|
desc 'Waits for sessions to be available in the deployment'
|
56
|
-
task :
|
100
|
+
task wait_for_sessions: :mongo do
|
57
101
|
$: << File.join(File.dirname(__FILE__), 'spec')
|
58
102
|
|
59
103
|
require 'support/utils'
|
@@ -77,7 +121,7 @@ namespace :spec do
|
|
77
121
|
end
|
78
122
|
|
79
123
|
desc 'Prints configuration used by the test suite'
|
80
|
-
task :
|
124
|
+
task config: :mongo do
|
81
125
|
$: << File.join(File.dirname(__FILE__), 'spec')
|
82
126
|
|
83
127
|
# Since this task is usually used for troubleshooting of test suite
|
@@ -90,6 +134,8 @@ namespace :spec do
|
|
90
134
|
end
|
91
135
|
|
92
136
|
def spec_organizer
|
137
|
+
require 'mrss/spec_organizer'
|
138
|
+
|
93
139
|
Mrss::SpecOrganizer.new(
|
94
140
|
root: ROOT,
|
95
141
|
classifiers: CLASSIFIERS,
|
@@ -109,15 +155,31 @@ namespace :spec do
|
|
109
155
|
end
|
110
156
|
end
|
111
157
|
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
158
|
+
desc 'Build and validate the evergreen config'
|
159
|
+
task eg: %w[ eg:build eg:validate ]
|
160
|
+
|
161
|
+
# 'eg' == 'evergreen', but evergreen is too many letters for convenience
|
162
|
+
namespace :eg do
|
163
|
+
desc 'Builds the .evergreen/config.yml file from the templates'
|
164
|
+
task :build do
|
165
|
+
ruby '.evergreen/update-evergreen-configs'
|
166
|
+
end
|
167
|
+
|
168
|
+
desc 'Validates the .evergreen/config.yml file'
|
169
|
+
task :validate do
|
170
|
+
system 'evergreen validate --project mongo-ruby-driver .evergreen/config.yml'
|
117
171
|
end
|
118
|
-
end
|
119
172
|
|
120
|
-
|
173
|
+
desc 'Updates the evergreen executable to the latest available version'
|
174
|
+
task :update do
|
175
|
+
system 'evergreen get-update --install'
|
176
|
+
end
|
177
|
+
|
178
|
+
desc 'Runs the current branch as an evergreen patch'
|
179
|
+
task :patch do
|
180
|
+
system 'evergreen patch --uncommitted --project mongo-ruby-driver --browse --auto-description --yes'
|
181
|
+
end
|
182
|
+
end
|
121
183
|
|
122
184
|
desc "Generate all documentation"
|
123
185
|
task :docs => 'docs:yard'
|
@@ -131,157 +193,4 @@ namespace :docs do
|
|
131
193
|
end
|
132
194
|
end
|
133
195
|
|
134
|
-
|
135
|
-
|
136
|
-
# Some require data files, available from the drivers team. See the comments above each task for details."
|
137
|
-
namespace :benchmark do
|
138
|
-
desc "Run the driver benchmark tests."
|
139
|
-
|
140
|
-
namespace :micro do
|
141
|
-
desc "Run the common driver micro benchmarking tests"
|
142
|
-
|
143
|
-
namespace :flat do
|
144
|
-
desc "Benchmarking for flat bson documents."
|
145
|
-
|
146
|
-
# Requirement: A file in Mongo::Benchmarking::DATA_PATH, called flat_bson.json.
|
147
|
-
task :encode do
|
148
|
-
puts "MICRO BENCHMARK:: FLAT:: ENCODE"
|
149
|
-
Mongo::Benchmarking::Micro.run(:flat, :encode)
|
150
|
-
end
|
151
|
-
|
152
|
-
# Requirement: A file in Mongo::Benchmarking::DATA_PATH, called flat_bson.json.
|
153
|
-
task :decode do
|
154
|
-
puts "MICRO BENCHMARK:: FLAT:: DECODE"
|
155
|
-
Mongo::Benchmarking::Micro.run(:flat, :decode)
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
|
-
namespace :deep do
|
160
|
-
desc "Benchmarking for deep bson documents."
|
161
|
-
|
162
|
-
# Requirement: A file in Mongo::Benchmarking::DATA_PATH, called deep_bson.json.
|
163
|
-
task :encode do
|
164
|
-
puts "MICRO BENCHMARK:: DEEP:: ENCODE"
|
165
|
-
Mongo::Benchmarking::Micro.run(:deep, :encode)
|
166
|
-
end
|
167
|
-
|
168
|
-
# Requirement: A file in Mongo::Benchmarking::DATA_PATH, called deep_bson.json.
|
169
|
-
task :decode do
|
170
|
-
puts "MICRO BENCHMARK:: DEEP:: DECODE"
|
171
|
-
Mongo::Benchmarking::Micro.run(:deep, :decode)
|
172
|
-
end
|
173
|
-
end
|
174
|
-
|
175
|
-
namespace :full do
|
176
|
-
desc "Benchmarking for full bson documents."
|
177
|
-
|
178
|
-
# Requirement: A file in Mongo::Benchmarking::DATA_PATH, called full_bson.json.
|
179
|
-
task :encode do
|
180
|
-
puts "MICRO BENCHMARK:: FULL:: ENCODE"
|
181
|
-
Mongo::Benchmarking::Micro.run(:full, :encode)
|
182
|
-
end
|
183
|
-
|
184
|
-
# Requirement: A file in Mongo::Benchmarking::DATA_PATH, called full_bson.json.
|
185
|
-
task :decode do
|
186
|
-
puts "MICRO BENCHMARK:: FULL:: DECODE"
|
187
|
-
Mongo::Benchmarking::Micro.run(:full, :decode)
|
188
|
-
end
|
189
|
-
end
|
190
|
-
end
|
191
|
-
|
192
|
-
namespace :single_doc do
|
193
|
-
desc "Run the common driver single-document benchmarking tests"
|
194
|
-
task :command do
|
195
|
-
puts "SINGLE DOC BENCHMARK:: COMMAND"
|
196
|
-
Mongo::Benchmarking::SingleDoc.run(:command)
|
197
|
-
end
|
198
|
-
|
199
|
-
# Requirement: A file in Mongo::Benchmarking::DATA_PATH, called TWEET.json.
|
200
|
-
task :find_one do
|
201
|
-
puts "SINGLE DOC BENCHMARK:: FIND ONE BY ID"
|
202
|
-
Mongo::Benchmarking::SingleDoc.run(:find_one)
|
203
|
-
end
|
204
|
-
|
205
|
-
# Requirement: A file in Mongo::Benchmarking::DATA_PATH, called SMALL_DOC.json.
|
206
|
-
task :insert_one_small do
|
207
|
-
puts "SINGLE DOC BENCHMARK:: INSERT ONE SMALL DOCUMENT"
|
208
|
-
Mongo::Benchmarking::SingleDoc.run(:insert_one_small)
|
209
|
-
end
|
210
|
-
|
211
|
-
# Requirement: A file in Mongo::Benchmarking::DATA_PATH, called LARGE_DOC.json.
|
212
|
-
task :insert_one_large do
|
213
|
-
puts "SINGLE DOC BENCHMARK:: INSERT ONE LARGE DOCUMENT"
|
214
|
-
Mongo::Benchmarking::SingleDoc.run(:insert_one_large)
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
namespace :multi_doc do
|
219
|
-
desc "Run the common driver multi-document benchmarking tests"
|
220
|
-
|
221
|
-
# Requirement: A file in Mongo::Benchmarking::DATA_PATH, called TWEET.json.
|
222
|
-
task :find_many do
|
223
|
-
puts "MULTI DOCUMENT BENCHMARK:: FIND MANY"
|
224
|
-
Mongo::Benchmarking::MultiDoc.run(:find_many)
|
225
|
-
end
|
226
|
-
|
227
|
-
# Requirement: A file in Mongo::Benchmarking::DATA_PATH, called SMALL_DOC.json.
|
228
|
-
task :bulk_insert_small do
|
229
|
-
puts "MULTI DOCUMENT BENCHMARK:: BULK INSERT SMALL"
|
230
|
-
Mongo::Benchmarking::MultiDoc.run(:bulk_insert_small)
|
231
|
-
end
|
232
|
-
|
233
|
-
# Requirement: A file in Mongo::Benchmarking::DATA_PATH, called LARGE_DOC.json.
|
234
|
-
task :bulk_insert_large do
|
235
|
-
puts "MULTI DOCUMENT BENCHMARK:: BULK INSERT LARGE"
|
236
|
-
Mongo::Benchmarking::MultiDoc.run(:bulk_insert_large)
|
237
|
-
end
|
238
|
-
|
239
|
-
# Requirement: A file in Mongo::Benchmarking::DATA_PATH, called GRIDFS_LARGE.
|
240
|
-
task :gridfs_upload do
|
241
|
-
puts "MULTI DOCUMENT BENCHMARK:: GRIDFS UPLOAD"
|
242
|
-
Mongo::Benchmarking::MultiDoc.run(:gridfs_upload)
|
243
|
-
end
|
244
|
-
|
245
|
-
# Requirement: A file in Mongo::Benchmarking::DATA_PATH, called GRIDFS_LARGE.
|
246
|
-
task :gridfs_download do
|
247
|
-
puts "MULTI DOCUMENT BENCHMARK:: GRIDFS DOWNLOAD"
|
248
|
-
Mongo::Benchmarking::MultiDoc.run(:gridfs_download)
|
249
|
-
end
|
250
|
-
end
|
251
|
-
|
252
|
-
namespace :parallel do
|
253
|
-
desc "Run the common driver paralell ETL benchmarking tests"
|
254
|
-
|
255
|
-
# Requirement: A directory in Mongo::Benchmarking::DATA_PATH, called LDJSON_MULTI,
|
256
|
-
# with the files used in this task.
|
257
|
-
task :import do
|
258
|
-
puts "PARALLEL ETL BENCHMARK:: IMPORT"
|
259
|
-
Mongo::Benchmarking::Parallel.run(:import)
|
260
|
-
end
|
261
|
-
|
262
|
-
# Requirement: A directory in Mongo::Benchmarking::DATA_PATH, called LDJSON_MULTI,
|
263
|
-
# with the files used in this task.
|
264
|
-
# Requirement: Another directory in "#{Mongo::Benchmarking::DATA_PATH}/LDJSON_MULTI"
|
265
|
-
# called 'output'.
|
266
|
-
task :export do
|
267
|
-
puts "PARALLEL ETL BENCHMARK:: EXPORT"
|
268
|
-
Mongo::Benchmarking::Parallel.run(:export)
|
269
|
-
end
|
270
|
-
|
271
|
-
# Requirement: A directory in Mongo::Benchmarking::DATA_PATH, called GRIDFS_MULTI,
|
272
|
-
# with the files used in this task.
|
273
|
-
task :gridfs_upload do
|
274
|
-
puts "PARALLEL ETL BENCHMARK:: GRIDFS UPLOAD"
|
275
|
-
Mongo::Benchmarking::Parallel.run(:gridfs_upload)
|
276
|
-
end
|
277
|
-
|
278
|
-
# Requirement: A directory in Mongo::Benchmarking::DATA_PATH, called GRIDFS_MULTI,
|
279
|
-
# with the files used in this task.
|
280
|
-
# Requirement: Another directory in "#{Mongo::Benchmarking::DATA_PATH}/GRIDFS_MULTI"
|
281
|
-
# called 'output'.
|
282
|
-
task :gridfs_download do
|
283
|
-
puts "PARALLEL ETL BENCHMARK:: GRIDFS DOWNLOAD"
|
284
|
-
Mongo::Benchmarking::Parallel.run(:gridfs_download)
|
285
|
-
end
|
286
|
-
end
|
287
|
-
end
|
196
|
+
load 'profile/driver_bench/rake/tasks.rake'
|
@@ -211,6 +211,22 @@ module Mongo
|
|
211
211
|
end
|
212
212
|
end
|
213
213
|
|
214
|
+
# Compares each server address against the list of patterns.
|
215
|
+
#
|
216
|
+
# @param [ Array<String> ] patterns the URL suffixes to compare
|
217
|
+
# each server against.
|
218
|
+
#
|
219
|
+
# @return [ true | false ] whether any of the addresses match any of
|
220
|
+
# the patterns or not.
|
221
|
+
#
|
222
|
+
# @api private
|
223
|
+
def server_hosts_match_any?(patterns)
|
224
|
+
server_descriptions.any? do |addr_spec, _desc|
|
225
|
+
addr, _port = addr_spec.split(/:/)
|
226
|
+
patterns.any? { |pattern| addr.end_with?(pattern) }
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
214
230
|
private
|
215
231
|
|
216
232
|
# Validates and/or transforms options as necessary for the topology.
|
data/lib/mongo/cluster.rb
CHANGED
@@ -157,7 +157,7 @@ module Mongo
|
|
157
157
|
# @sdam_flow_lock covers just the sdam flow. Note it does not apply
|
158
158
|
# to @topology replacements which are done under @update_lock.
|
159
159
|
@sdam_flow_lock = Mutex.new
|
160
|
-
Session::SessionPool.
|
160
|
+
@session_pool = Session::SessionPool.new(self)
|
161
161
|
|
162
162
|
if seeds.empty? && load_balanced?
|
163
163
|
raise ArgumentError, 'Load-balanced clusters with no seeds are prohibited'
|
@@ -186,6 +186,8 @@ module Mongo
|
|
186
186
|
recreate_topology(topology, opening_topology)
|
187
187
|
end
|
188
188
|
|
189
|
+
possibly_warn_about_compatibility!
|
190
|
+
|
189
191
|
if load_balanced?
|
190
192
|
# We are required by the specifications to produce certain SDAM events
|
191
193
|
# when in load-balanced topology.
|
@@ -1082,6 +1084,30 @@ module Mongo
|
|
1082
1084
|
Monitoring::Event::TopologyChanged.new(previous_topology, @topology)
|
1083
1085
|
)
|
1084
1086
|
end
|
1087
|
+
|
1088
|
+
COSMOSDB_HOST_PATTERNS = %w[ .cosmos.azure.com ]
|
1089
|
+
COSMOSDB_LOG_MESSAGE = 'You appear to be connected to a CosmosDB cluster. ' \
|
1090
|
+
'For more information regarding feature compatibility and support please visit ' \
|
1091
|
+
'https://www.mongodb.com/supportability/cosmosdb'
|
1092
|
+
|
1093
|
+
DOCUMENTDB_HOST_PATTERNS = %w[ .docdb.amazonaws.com .docdb-elastic.amazonaws.com ]
|
1094
|
+
DOCUMENTDB_LOG_MESSAGE = 'You appear to be connected to a DocumentDB cluster. ' \
|
1095
|
+
'For more information regarding feature compatibility and support please visit ' \
|
1096
|
+
'https://www.mongodb.com/supportability/documentdb'
|
1097
|
+
|
1098
|
+
# Compares the server hosts with address suffixes of known services
|
1099
|
+
# that provide limited MongoDB API compatibility, and warns about them.
|
1100
|
+
def possibly_warn_about_compatibility!
|
1101
|
+
if topology.server_hosts_match_any?(COSMOSDB_HOST_PATTERNS)
|
1102
|
+
log_info COSMOSDB_LOG_MESSAGE
|
1103
|
+
return
|
1104
|
+
end
|
1105
|
+
|
1106
|
+
if topology.server_hosts_match_any?(DOCUMENTDB_HOST_PATTERNS)
|
1107
|
+
log_info DOCUMENTDB_LOG_MESSAGE
|
1108
|
+
return
|
1109
|
+
end
|
1110
|
+
end
|
1085
1111
|
end
|
1086
1112
|
end
|
1087
1113
|
|
@@ -162,6 +162,7 @@ module Mongo
|
|
162
162
|
let: options[:let],
|
163
163
|
limit: limit,
|
164
164
|
allow_disk_use: options[:allow_disk_use],
|
165
|
+
allow_partial_results: options[:allow_partial_results],
|
165
166
|
read: read,
|
166
167
|
read_concern: options[:read_concern] || read_concern,
|
167
168
|
batch_size: batch_size,
|
data/lib/mongo/collection.rb
CHANGED
@@ -339,7 +339,9 @@ module Mongo
|
|
339
339
|
# inserted or updated documents where the clustered index key value
|
340
340
|
# matches an existing value in the index.
|
341
341
|
# - *:name* -- Optional. A name that uniquely identifies the clustered index.
|
342
|
-
# @option opts [ Hash ] :collation The collation to use
|
342
|
+
# @option opts [ Hash ] :collation The collation to use when creating the
|
343
|
+
# collection. This option will not be sent to the server when calling
|
344
|
+
# collection methods.
|
343
345
|
# @option opts [ Hash ] :encrypted_fields Hash describing encrypted fields
|
344
346
|
# for queryable encryption.
|
345
347
|
# @option opts [ Integer ] :expire_after Number indicating
|
@@ -788,7 +790,7 @@ module Mongo
|
|
788
790
|
def insert_one(document, opts = {})
|
789
791
|
QueryCache.clear_namespace(namespace)
|
790
792
|
|
791
|
-
client.
|
793
|
+
client.with_session(opts) do |session|
|
792
794
|
write_concern = if opts[:write_concern]
|
793
795
|
WriteConcern.get(opts[:write_concern])
|
794
796
|
else
|
data/lib/mongo/config.rb
CHANGED
@@ -16,7 +16,7 @@ module Mongo
|
|
16
16
|
|
17
17
|
# When this flag is off, an aggregation done on a view will be executed over
|
18
18
|
# the documents included in that view, instead of all documents in the
|
19
|
-
# collection. When this flag is on, the view
|
19
|
+
# collection. When this flag is on, the view filter is ignored.
|
20
20
|
option :broken_view_aggregate, default: true
|
21
21
|
|
22
22
|
# When this flag is set to false, the view options will be correctly
|
@@ -24,7 +24,7 @@ module Mongo
|
|
24
24
|
option :broken_view_options, default: true
|
25
25
|
|
26
26
|
# When this flag is set to true, the update and replace methods will
|
27
|
-
# validate the
|
27
|
+
# validate the parameters and raise an error if they are invalid.
|
28
28
|
option :validate_update_replace, default: false
|
29
29
|
|
30
30
|
# Set the configuration options.
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Copyright (C) 2019-2020 MongoDB Inc.
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
16
|
+
|
17
|
+
module Mongo
|
18
|
+
class Error
|
19
|
+
# Transactions are not supported by the cluster. There might be the
|
20
|
+
# following reasons:
|
21
|
+
# - topology is standalone
|
22
|
+
# - topology is replica set and server version is < 4.0
|
23
|
+
# - topology is sharded and server version is < 4.2
|
24
|
+
#
|
25
|
+
# @param [ String ] reason The reason why transactions are no supported.
|
26
|
+
#
|
27
|
+
# @since 2.7.0
|
28
|
+
class TransactionsNotSupported < Error
|
29
|
+
def initialize(reason)
|
30
|
+
super("Transactions are not supported for the cluster: #{reason}")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/mongo/error.rb
CHANGED
@@ -217,6 +217,7 @@ require 'mongo/error/missing_service_id'
|
|
217
217
|
require 'mongo/error/server_api_conflict'
|
218
218
|
require 'mongo/error/server_api_not_supported'
|
219
219
|
require 'mongo/error/server_not_usable'
|
220
|
+
require 'mongo/error/transactions_not_supported'
|
220
221
|
require 'mongo/error/unknown_payload_type'
|
221
222
|
require 'mongo/error/unmet_dependency'
|
222
223
|
require 'mongo/error/unsupported_option'
|
data/lib/mongo/grid/fs_bucket.rb
CHANGED
@@ -58,7 +58,7 @@ module Mongo
|
|
58
58
|
# According to Command Monitoring spec,for hello/legacy hello commands
|
59
59
|
# when speculativeAuthenticate is present, their commands AND replies
|
60
60
|
# MUST be redacted from the events.
|
61
|
-
# See https://github.com/mongodb/specifications/blob/master/source/command-monitoring/command-monitoring.rst#security
|
61
|
+
# See https://github.com/mongodb/specifications/blob/master/source/command-logging-and-monitoring/command-logging-and-monitoring.rst#security
|
62
62
|
true
|
63
63
|
else
|
64
64
|
false
|
@@ -15,6 +15,8 @@
|
|
15
15
|
# See the License for the specific language governing permissions and
|
16
16
|
# limitations under the License.
|
17
17
|
|
18
|
+
require 'mongo/error'
|
19
|
+
|
18
20
|
module Mongo
|
19
21
|
module Operation
|
20
22
|
|
@@ -30,40 +32,42 @@ module Mongo
|
|
30
32
|
session&.materialize_if_needed
|
31
33
|
unpin_maybe(session, connection) do
|
32
34
|
add_error_labels(connection, context) do
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
if session
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
35
|
+
check_for_network_error do
|
36
|
+
add_server_diagnostics(connection) do
|
37
|
+
get_result(connection, context, options).tap do |result|
|
38
|
+
if session
|
39
|
+
if session.in_transaction? &&
|
40
|
+
connection.description.load_balancer?
|
41
|
+
then
|
42
|
+
if session.pinned_connection_global_id
|
43
|
+
unless session.pinned_connection_global_id == connection.global_id
|
44
|
+
raise(
|
45
|
+
Error::InternalDriverError,
|
46
|
+
"Expected operation to use connection #{session.pinned_connection_global_id} but it used #{connection.global_id}"
|
47
|
+
)
|
48
|
+
end
|
49
|
+
else
|
50
|
+
session.pin_to_connection(connection.global_id)
|
51
|
+
connection.pin
|
45
52
|
end
|
46
|
-
else
|
47
|
-
session.pin_to_connection(connection.global_id)
|
48
|
-
connection.pin
|
49
53
|
end
|
50
|
-
end
|
51
54
|
|
52
|
-
|
53
|
-
|
55
|
+
if session.snapshot? && !session.snapshot_timestamp
|
56
|
+
session.snapshot_timestamp = result.snapshot_timestamp
|
57
|
+
end
|
54
58
|
end
|
55
|
-
end
|
56
59
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
60
|
+
if result.has_cursor_id? &&
|
61
|
+
connection.description.load_balancer?
|
62
|
+
then
|
63
|
+
if result.cursor_id == 0
|
64
|
+
connection.unpin
|
65
|
+
else
|
66
|
+
connection.pin
|
67
|
+
end
|
64
68
|
end
|
69
|
+
process_result(result, connection)
|
65
70
|
end
|
66
|
-
process_result(result, connection)
|
67
71
|
end
|
68
72
|
end
|
69
73
|
end
|
@@ -144,6 +148,18 @@ module Mongo
|
|
144
148
|
connection.server.scan_semaphore.signal
|
145
149
|
end
|
146
150
|
end
|
151
|
+
|
152
|
+
NETWORK_ERRORS = [
|
153
|
+
Error::SocketError,
|
154
|
+
Error::SocketTimeoutError
|
155
|
+
].freeze
|
156
|
+
|
157
|
+
def check_for_network_error
|
158
|
+
yield
|
159
|
+
rescue *NETWORK_ERRORS
|
160
|
+
session&.dirty!
|
161
|
+
raise
|
162
|
+
end
|
147
163
|
end
|
148
164
|
end
|
149
165
|
end
|