Skip to content

Commit 4582ab9

Browse files
jamisCopilot
andauthored
MONGOID-3381 MONGOID-3640 Remove support for server versions 3.6 and 4.0 (#2986)
* working toward removing 3.6 and 4.0 server support * another test updated * database_spec.rb * more specs * another test * moar * map/reduce * and moar * more specs * more specs * more specs * cleaning up references to old server versions * more specs and stuff * removing references to 4.0 and older * removing 4.0/4.2 constraints * more shenanigans * mmapv1 references * module was removed * copilot feedback * fix typo Co-authored-by: Copilot <[email protected]> * avoid pulling the entire cursor into memory unnecessarily * remove test for checking mmapv1 behavior * correctly identify/mock connections without session support * fail commands are well-supported now; also sync sdam specs * fail commands are still required * accidentally deleted something * bump spec/shared * Remove unused FCV axis, and DB versions * try and fix flaky test by bringing it in sync with specifications repo * correctly interpret $$lte as "less than OR EQUAL TO" * skip failing spec (caused by RUBY-3781) --------- Co-authored-by: Copilot <[email protected]>
1 parent c06cc5d commit 4582ab9

File tree

184 files changed

+886
-6852
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

184 files changed

+886
-6852
lines changed

.evergreen/config.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -804,22 +804,6 @@ axes:
804804
variables:
805805
MONGODB_VERSION: "4.2"
806806
CRYPT_SHARED_VERSION: "6.0.5"
807-
- id: "4.0"
808-
display_name: "4.0"
809-
variables:
810-
MONGODB_VERSION: "4.0"
811-
- id: "3.6"
812-
display_name: "3.6"
813-
variables:
814-
MONGODB_VERSION: "3.6"
815-
816-
- id: fcv
817-
display_name: FCV
818-
values:
819-
- id: '3.4'
820-
display_name: '3.4'
821-
variables:
822-
FCV: '3.4'
823807

824808
- id: "topology"
825809
display_name: Topology

.evergreen/config/axes.yml.erb

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -29,22 +29,6 @@ axes:
2929
variables:
3030
MONGODB_VERSION: "4.2"
3131
CRYPT_SHARED_VERSION: "6.0.5"
32-
- id: "4.0"
33-
display_name: "4.0"
34-
variables:
35-
MONGODB_VERSION: "4.0"
36-
- id: "3.6"
37-
display_name: "3.6"
38-
variables:
39-
MONGODB_VERSION: "3.6"
40-
41-
- id: fcv
42-
display_name: FCV
43-
values:
44-
- id: '3.4'
45-
display_name: '3.4'
46-
variables:
47-
FCV: '3.4'
4832

4933
- id: "topology"
5034
display_name: Topology

lib/mongo/auth/conversation_base.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def speculative_auth_document
5353

5454
# @return [ Protocol::Message ] The message to send.
5555
def build_message(connection, auth_source, selector)
56-
if connection && connection.features.op_msg_enabled?
56+
if connection
5757
selector = selector.dup
5858
selector[Protocol::Msg::DATABASE_IDENTIFIER] = auth_source
5959
cluster_time = connection.mongos? && connection.cluster_time

lib/mongo/auth/stringprep.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
module Mongo
2222
module Auth
2323
# This namespace contains all behavior related to string preparation
24-
# (RFC 3454). It's used to implement SCRAM-SHA-256 authentication,
25-
# which is available in MongoDB server versions 4.0 and later.
24+
# (RFC 3454). It's used to implement SCRAM-SHA-256 authentication.
2625
#
2726
# @since 2.6.0
2827
# @api private

lib/mongo/bulk_write.rb

Lines changed: 4 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,6 @@ def base_spec(operation_id, session)
217217
end
218218

219219
def execute_operation(name, values, connection, context, operation_id, result_combiner, session, txn_num = nil)
220-
validate_collation!(connection)
221-
validate_array_filters!(connection)
222220
validate_hint!(connection)
223221

224222
unpin_maybe(session, connection) do
@@ -234,13 +232,9 @@ def execute_operation(name, values, connection, context, operation_id, result_co
234232
end
235233
end
236234
end
237-
# With OP_MSG (3.6+ servers), the size of each section in the message
235+
# The size of each section in the message
238236
# is independently capped at 16m and each bulk operation becomes
239237
# its own section. The size of the entire bulk write is limited to 48m.
240-
# With OP_QUERY (pre-3.6 servers), the entire bulk write is sent as a
241-
# single document and is thus subject to the 16m document size limit.
242-
# This means the splits differ between pre-3.6 and 3.6+ servers, with
243-
# 3.6+ servers being able to split less.
244238
rescue Error::MaxBSONSize, Error::MaxMessageSize => e
245239
raise e if values.size <= 1
246240
unpin_maybe(session, connection) do
@@ -297,33 +291,19 @@ def update_many(documents, connection, context, operation_id, session, txn_num)
297291

298292
private
299293

300-
def validate_collation!(connection)
301-
if op_combiner.has_collation? && !connection.features.collation_enabled?
302-
raise Error::UnsupportedCollation.new
303-
end
304-
end
305-
306-
def validate_array_filters!(connection)
307-
if op_combiner.has_array_filters? && !connection.features.array_filters_enabled?
308-
raise Error::UnsupportedArrayFilters.new
309-
end
310-
end
311-
312294
def validate_hint!(connection)
313295
if op_combiner.has_hint?
314296
if !can_hint?(connection) && write_concern && !write_concern.acknowledged?
315297
raise Error::UnsupportedOption.hint_error(unacknowledged_write: true)
316-
elsif !connection.features.update_delete_option_validation_enabled?
317-
raise Error::UnsupportedOption.hint_error
318298
end
319299
end
320300
end
321301

322302
# Loop through the requests and check if each operation is allowed to send
323303
# a hint for each operation on the given server version.
324304
#
325-
# For the following operations, the client can send a hint for servers >= 4.2
326-
# and for the rest, the client can only send it for 4.4+:
305+
# For the following operations, the client can send a hint for all supported
306+
# server versions, and for the rest, the client can only send it for 4.4+:
327307
# - updateOne
328308
# - updateMany
329309
# - replaceOne
@@ -333,13 +313,12 @@ def validate_hint!(connection)
333313
# @return [ true | false ] Whether the request is able to send hints for
334314
# the current server version.
335315
def can_hint?(connection)
336-
gte_4_2 = connection.server.description.server_version_gte?('4.2')
337316
gte_4_4 = connection.server.description.server_version_gte?('4.4')
338317
op_combiner.requests.all? do |req|
339318
op = req.keys.first
340319
if req[op].keys.include?(:hint)
341320
if [:update_one, :update_many, :replace_one].include?(op)
342-
gte_4_2
321+
true
343322
else
344323
gte_4_4
345324
end

lib/mongo/bulk_write/unordered_combiner.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ class BulkWrite
2424
#
2525
# @since 2.1.0
2626
class UnorderedCombiner
27-
include Transformable
2827
include Validatable
28+
include Transformable
2929
include Combineable
3030

3131
# Combine the requests in order.

lib/mongo/client.rb

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -230,8 +230,7 @@ def hash
230230
# analogous options present in the URI string.
231231
#
232232
# @option options [ String, Symbol ] :app_name Application name that is
233-
# printed to the mongod logs upon establishing a connection in server
234-
# versions >= 3.4.
233+
# printed to the mongod logs upon establishing a connection
235234
# @option options [ Symbol ] :auth_mech The authentication mechanism to
236235
# use. One of :mongodb_cr, :mongodb_x509, :plain, :scram, :scram256
237236
# @option options [ Hash ] :auth_mech_properties
@@ -308,7 +307,6 @@ def hash
308307
# @option options [ String ] :password The user's password.
309308
# @option options [ String ] :platform Platform information to include in
310309
# the metadata printed to the mongod logs upon establishing a connection
311-
# in server versions >= 3.4.
312310
# @option options [ Hash ] :read The read preference options. The hash
313311
# may have the following items:
314312
# - *:mode* -- read preference specified as a symbol; valid values are
@@ -325,7 +323,7 @@ def hash
325323
# reads are enabled (which is the default). If false, modern retryable
326324
# reads are disabled and legacy retryable reads are enabled.
327325
# @option options [ true | false ] :retry_writes Retry writes once when
328-
# connected to a replica set or sharded cluster versions 3.6 and up.
326+
# connected to a replica set or sharded cluster.
329327
# (Default is true.)
330328
# @option options [ true | false ] :scan Whether to scan all seeds
331329
# in constructor. The default in driver version 2.x is to do so;
@@ -1045,9 +1043,8 @@ def start_session(options = {})
10451043
end
10461044
end
10471045

1048-
# As of version 3.6 of the MongoDB server, a ``$changeStream`` pipeline stage is supported
1049-
# in the aggregation framework. As of version 4.0, this stage allows users to request that
1050-
# notifications are sent for all changes that occur in the client's cluster.
1046+
# Allows users to request that notifications are sent for all changes that
1047+
# occur in the client's cluster.
10511048
#
10521049
# @example Get change notifications for the client's cluster.
10531050
# client.watch([{ '$match' => { operationType: { '$in' => ['insert', 'replace'] } } }])
@@ -1093,7 +1090,6 @@ def start_session(options = {})
10931090
# @option options [ BSON::Timestamp ] :start_at_operation_time Only return
10941091
# changes that occurred at or after the specified timestamp. Any command run
10951092
# against the server will return a cluster time that can be used here.
1096-
# Only recognized by server versions 4.0+.
10971093
# @option options [ Object ] :comment A user-provided
10981094
# comment to attach to this command.
10991095
# @option options [ Boolean ] :show_expanded_events Enables the server to

lib/mongo/collection.rb

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -576,10 +576,8 @@ def aggregate(pipeline, options = {})
576576
View.new(self, {}, options).aggregate(pipeline, options)
577577
end
578578

579-
# As of version 3.6 of the MongoDB server, a ``$changeStream`` pipeline
580-
# stage is supported in the aggregation framework. This stage allows users
581-
# to request that notifications are sent for all changes to a particular
582-
# collection.
579+
# Allows users to request that notifications are sent for all changes
580+
# to a particular collection.
583581
#
584582
# @example Get change notifications for a given collection.
585583
# collection.watch([{ '$match' => { operationType: { '$in' => ['insert', 'replace'] } } }])
@@ -627,7 +625,6 @@ def aggregate(pipeline, options = {})
627625
# @option options [ BSON::Timestamp ] :start_at_operation_time Only return
628626
# changes that occurred at or after the specified timestamp. Any command run
629627
# against the server will return a cluster time that can be used here.
630-
# Only recognized by server versions 4.0+.
631628
# @option options [ Object ] :comment A user-provided
632629
# comment to attach to this command.
633630
# @option options [ Boolean ] :show_expanded_events Enables the server to
@@ -686,7 +683,7 @@ def watch(pipeline = [], options = {})
686683
#
687684
# @deprecated Use #count_documents or estimated_document_count instead. However, note that the
688685
# following operators will need to be substituted when switching to #count_documents:
689-
# * $where should be replaced with $expr (only works on 3.6+)
686+
# * $where should be replaced with $expr
690687
# * $near should be replaced with $geoWithin with $center
691688
# * $nearSphere should be replaced with $geoWithin with $centerSphere
692689
def count(filter = nil, options = {})
@@ -706,7 +703,7 @@ def count(filter = nil, options = {})
706703
#
707704
# @option options :skip [ Integer ] The number of documents to skip.
708705
# @option options :hint [ Hash ] Override default index selection and force
709-
# MongoDB to use a specific index for the query. Requires server version 3.6+.
706+
# MongoDB to use a specific index for the query.
710707
# @option options :limit [ Integer ] Max number of docs to count.
711708
# @option options :max_time_ms [ Integer ] The maximum amount of time to allow the
712709
# command to run.

lib/mongo/collection/view/change_stream.rb

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,6 @@ class View
2727
# that notifications are sent for all changes to a particular collection
2828
# or database.
2929
#
30-
# @note Only available in server versions 3.6 and higher.
31-
# @note ChangeStreams do not work properly with JRuby because of the
32-
# issue documented here: https://github.com/jruby/jruby/issues/4212.
33-
# Namely, JRuby eagerly evaluates #next on an Enumerator in a background
34-
# green thread, therefore calling #next on the change stream will cause
35-
# getMores to be called in a loop in the background.
36-
#
37-
#
3830
# @since 2.5.0
3931
class ChangeStream
4032
include Aggregation::Behavior
@@ -114,7 +106,7 @@ class ChangeStream
114106
# @option options [ BSON::Timestamp ] :start_at_operation_time Only
115107
# return changes that occurred at or after the specified timestamp. Any
116108
# command run against the server will return a cluster time that can
117-
# be used here. Only recognized by server versions 4.0+.
109+
# be used here.
118110
# @option options [ Bson::Document, Hash ] :start_after Similar to :resume_after, this
119111
# option takes a resume token and starts a new change stream returning the first
120112
# notification after the token. This will allow users to watch collections that have been
@@ -340,18 +332,13 @@ def for_collection?
340332
def create_cursor!(timeout_ms = nil)
341333
# clear the cache because we may get a newer or an older server
342334
# (rolling upgrades)
343-
@start_at_operation_time_supported = nil
344-
345335
session = client.get_session(@options)
346336
context = Operation::Context.new(client: client, session: session, view: self, operation_timeouts: timeout_ms ? { operation_timeout_ms: timeout_ms } : operation_timeouts)
347337

348338
start_at_operation_time = nil
349-
start_at_operation_time_supported = nil
350339

351340
@cursor = read_with_retry_cursor(session, server_selector, self, context: context) do |server|
352341
server.with_connection do |connection|
353-
start_at_operation_time_supported = connection.description.server_version_gte?('4.0')
354-
355342
result = send_initial_query(connection, context)
356343

357344
if doc = result.replies.first && result.replies.first.documents.first
@@ -369,7 +356,6 @@ def create_cursor!(timeout_ms = nil)
369356
end
370357

371358
@start_at_operation_time = start_at_operation_time
372-
@start_at_operation_time_supported = start_at_operation_time_supported
373359
end
374360

375361
def pipeline
@@ -405,12 +391,7 @@ def change_doc
405391
# Spec says we need to remove both startAtOperationTime and startAfter if
406392
# either was passed in by user, thus we won't forward them
407393
doc[:resumeAfter] = resume_token
408-
elsif @start_at_operation_time_supported && @start_at_operation_time
409-
# It is crucial to check @start_at_operation_time_supported
410-
# here - we may have switched to an older server that
411-
# does not support operation times and therefore shouldn't
412-
# try to send one to it!
413-
#
394+
elsif @start_at_operation_time
414395
# @start_at_operation_time is already a BSON::Timestamp
415396
doc[:startAtOperationTime] = @start_at_operation_time
416397
else

lib/mongo/collection/view/explainable.rb

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,10 @@ module Explainable
4444
# @example Get the query plan for the query with execution statistics.
4545
# view.explain(verbosity: :execution_stats)
4646
#
47-
# @option opts [ true | false ] :verbose The level of detail
48-
# to return for MongoDB 2.6 servers.
4947
# @option opts [ String | Symbol ] :verbosity The type of information
50-
# to return for MongoDB 3.0 and newer servers. If the value is a
51-
# symbol, it will be stringified and converted from underscore
52-
# style to camel case style (e.g. :query_planner => "queryPlanner").
48+
# to return. If the value is a symbol, it will be stringified and
49+
# converted from underscore style to camel case style
50+
# (e.g. :query_planner => "queryPlanner").
5351
#
5452
# @return [ Hash ] A single document with the query plan.
5553
#
@@ -66,12 +64,10 @@ def explained?
6664
!!options[:explain]
6765
end
6866

69-
# @option opts [ true | false ] :verbose The level of detail
70-
# to return for MongoDB 2.6 servers.
7167
# @option opts [ String | Symbol ] :verbosity The type of information
72-
# to return for MongoDB 3.0 and newer servers. If the value is a
73-
# symbol, it will be stringified and converted from underscore
74-
# style to camel case style (e.g. :query_planner => "queryPlanner").
68+
# to return. If the value is a symbol, it will be stringified and
69+
# converted from underscore style to camel case style
70+
# (e.g. :query_planner => "queryPlanner").
7571
def explain_options(**opts)
7672
explain_limit = limit || 0
7773
# Note: opts will never be nil here.

0 commit comments

Comments
 (0)