LibreCat / Catmandu-Store-Elasticsearch

https://metacpan.org/release/Catmandu-Store-Elasticsearch
6 stars 5 forks source link

NoNodes error if too many Catmandu::Store::ElasticSearch are created #19

Closed EreMaijala closed 5 years ago

EreMaijala commented 6 years ago

If you have a batch process that creates a new ElasticSearch store frequently, eventually searching using the newly-created store will fail with error "[NoNodes] ** No nodes are available". This is obviously sub-optimal, but it happens easily when you need to do an operation on a set of objects that use the ElasticSearch store internally.

Here is a very simplified sample script to reproduce the problem. On my Ubuntu 16.04.3 LTS box it fails after 1020 iterations.

#!/usr/bin/perl

use Catmandu::Store::ElasticSearch;

for ($i = 0; $i < 10000; $i++) {
    my $store = Catmandu::Store::ElasticSearch->new(
        nodes => ['localhost:9200'],
        index_name => 'test'
    );
    my $results = $store->bag->search(
        query => {
            match => {
                'title' => 'test' . $i
            }
        } ,
        limit => 10
    );
    print "$i\n";
}
nics commented 5 years ago

I'm going to close this ticket becausei don't think it's an issue with the Catmandu store. Probably related to something like connection timeouts. The store just passes settings like these to the underlying driver.