Exception: Parse::MongoDB::ExecutionTimeout

Inherits:
StandardError
  • Object
show all
Defined in:
lib/parse/mongodb.rb

Overview

Error raised when MongoDB cancels a query because it exceeded the requested maxTimeMS budget (MongoDB error code 50 / MaxTimeMSExpired). This is the DB-side counterpart to Agent::ToolTimeoutError and is raised by aggregate / find when the driver reports code 50.

Examples:

Handling a DB-level timeout

begin
  Parse::MongoDB.aggregate("Song", pipeline, max_time_ms: 5000)
rescue Parse::MongoDB::ExecutionTimeout => e
  puts "#{e.collection_name} timed out after #{e.max_time_ms}ms"
end

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(collection_name:, max_time_ms:) ⇒ ExecutionTimeout

Returns a new instance of ExecutionTimeout.

Parameters:

  • collection_name (String)

    the MongoDB collection

  • max_time_ms (Integer)

    the budget in milliseconds that was exceeded



132
133
134
135
136
# File 'lib/parse/mongodb.rb', line 132

def initialize(collection_name:, max_time_ms:)
  @max_time_ms = max_time_ms
  @collection_name = collection_name
  super("Query on '#{collection_name}' exceeded max_time_ms=#{max_time_ms}ms — narrow filter or add index")
end

Instance Attribute Details

#collection_nameString (readonly)

Returns the collection that was being queried.

Returns:

  • (String)

    the collection that was being queried



128
129
130
# File 'lib/parse/mongodb.rb', line 128

def collection_name
  @collection_name
end

#max_time_msInteger (readonly)

Returns the maxTimeMS budget that was exceeded.

Returns:

  • (Integer)

    the maxTimeMS budget that was exceeded



126
127
128
# File 'lib/parse/mongodb.rb', line 126

def max_time_ms
  @max_time_ms
end