Skip to content

Reconnecting to Mongo after connection drop #38

Open
@tokajuhani

Description

@tokajuhani

output plugin does not reconnecting to Mongo if connection is dropped.
Retry logic stuck in a loop. It will never retry to get connection to Mongo.

Howto reproduce:

  1. Start logstash with a Mongo output plugin
  2. Write something to logstash --> Data is stored to Mongo
  3. Shutdown Mongo (I run Mongo as Service in Windows, so I stop Mongo service)
  4. Write something to logstash
  5. I get error: Failed to send event to MongoDB {:event=>2017-03-08T08:48:00.057Z _________ t4, :exception=>#<Mongo::Error::NoServerAvailable: No server is available matching preference: #<Mongo::ServerSelector::Primary:0x7354 @tag_sets=[], @options=:database=>"admin"},@server_selection_timeout=30>>,
  6. Start Mongo service
  7. Same error occurs again and again

I have no experience of Ruby.
but if this is called only once:

def register
   Mongo::Logger.logger = @logger
   conn = Mongo::Client.new(@uri)
   @db = conn.use(@database)
 end # def register

Maybe conn = Mongo::Client.new(@uri) and @db = conn.use(@database) should be called if connection is dropped in def receive(event) function.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions