Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"SolrServerException: No solr server available." in version 1.3.x #7

Closed
fralken opened this issue Jun 18, 2015 · 18 comments
Closed

"SolrServerException: No solr server available." in version 1.3.x #7

fralken opened this issue Jun 18, 2015 · 18 comments

Comments

@fralken
Copy link

fralken commented Jun 18, 2015

Hello, I'm using SolrCLoud with Zookeeper and I'm initializing an AsyncSolrClient like this:

val serversSolr = new CloudSolrServers(
    zkHost = play.Play.application.configuration.getString("solr.zk"),
    defaultCollection = Some(play.Play.application.configuration.getString("solr.collection")))

val solr = AsyncSolrClient.Builder(RoundRobinLB(serversSolr)).build

The first time I execute a call like this:

...
solr.query(myquery)
...

I get the following exception:

org.apache.solr.client.solrj.SolrServerException: No solr server available.
    at io.ino.solrs.AsyncSolrClient.io$ino$solrs$AsyncSolrClient$$loadBalanceQuery(AsyncSolrClient.scala:199) ~[solrs_2.11-1.3.1.jar:1.3.1]
    at io.ino.solrs.AsyncSolrClient.query(AsyncSolrClient.scala:178) ~[solrs_2.11-1.3.1.jar:1.3.1]

If I execute the same query again, everything works fine. Apparently the problem doesn't happen if just after the creation of the AsyncSolrClient I call this:

serversSolr.setAsyncSolrClient(solr)

In version 1.2.0 and previous versions everything works fine.
Thanks

@andreaTP
Copy link

👍

@magro
Copy link
Member

magro commented Jun 18, 2015

Strange: I'd say that this is caused by the warmup queries (see also commit f97c402) - but as it seems you don't set warmupQueries on the CloudSolrServers. Can you please double check that you're not setting warmupQueries?

@andreaTP
Copy link

Confirmed:
warmupQueries is not setted

@magro
Copy link
Member

magro commented Jun 18, 2015

Just looking into this, and I cannot reproduce this (in our application) with the setup code you posted.
What I find really weird is that you write that serversSolr.setAsyncSolrClient(solr) fixes the problem for you - which is already done by AsyncSolrClient.Builder.build: https://github.com/inoio/solrs/blob/master/src/main/scala/io/ino/solrs/AsyncSolrClient.scala#L96

Looking further into this...

@magro
Copy link
Member

magro commented Jun 18, 2015

Btw, does it matter how much time is spent after the creation of the AsyncSolrClient instance before you call solr.query(myquery) the first time?

@magro
Copy link
Member

magro commented Jun 18, 2015

Assuming you have set the log level for "io.ino.solrs" to INFO, (when) do you see the log message "Connected to zookeeper at ", and how does it change if you additionally call serversSolr.setAsyncSolrClient(solr)?

@fralken
Copy link
Author

fralken commented Jun 18, 2015

It doesn't metter how long I wait after creation of AsyncSolrClient and the first call to solr.query(myquery).

Without yhe additional call I have the following log:

[info] play - Application started (Dev)
[info] i.i.s.CloudSolrServers - Connected to zookeeper at ...
[info] i.i.s.CloudSolrServers - Successfully created ZK cluster state watchers at ...
[error] play - Cannot invoke the action, eventually got an error: org.apache.solr.client.solrj.SolrServerException: No solr server available.
...
...
[info] i.i.s.CloudSolrServers - Updated server map: ...

When adding the additional call serversSolr.setAsyncSolrClient(solr)I have:

[info] play - Application started (Dev)
[info] i.i.s.CloudSolrServers - Connected to zookeeper at ... 
[info] i.i.s.CloudSolrServers - Successfully created ZK cluster state watchers at ...
[info] i.i.s.CloudSolrServers - Connected to zookeeper at ...
[info] i.i.s.CloudSolrServers - Updated server map: ...

As you can see, the Connected to zookeeper atappears twice this time, and the first query is succesful.

@fralken
Copy link
Author

fralken commented Jun 18, 2015

Ok, it appears in my code that the AsyncSolrClient is actually initialized just before the first solr.query(). Since I see the "update server map" is scheduled to run after 1 second, that is why I get "no solr servers available". If I force in some ways the initialization of AsyncSolrClient and then wait before the first solr.query(), it works fine.

Maybe it could be convenient in initZkStateReader to invoke updateFromClusterState once before scheduling for execution, so that we are sure the state of the client is consistent as soon as it is created.

@magro
Copy link
Member

magro commented Jun 19, 2015

Thanx for the log extracts! Can you also set the log level for org.apache.solr.common.cloud to INFO, please? It would also be helpful to have timestamps there as well.

Re updateFromClusterState: this is scheduled with initialDelay=0 (https://github.com/inoio/solrs/blob/master/src/main/scala/io/ino/solrs/SolrServers.scala#L139), so it should be invoked right away - only the thread creation time is added. We could also add debug log statements to updateFromClusterState to debug this.

@fralken
Copy link
Author

fralken commented Jun 19, 2015

I agree that initialDelay=0 but for some reason it is not executed as soon as it is scheduled

@fralken
Copy link
Author

fralken commented Jun 19, 2015

I added log level INFO for org.apache.solr.common.cloud...

[info] play - Application started (Dev)
[info] o.a.s.c.c.SolrZkClient - Using default ZkCredentialsProvider
[info] o.a.s.c.c.ConnectionManager - Waiting for client to connect to ZooKeeper
[info] o.a.s.c.c.ConnectionManager - Watcher org.apache.solr.common.cloud.ConnectionManager@2526db49 name:ZooKeeperConnection Watcher:... got event WatchedEvent state:SyncConnected type:None path:null path:null type:None
[info] o.a.s.c.c.ConnectionManager - Client is connected to ZooKeeper
[info] o.a.s.c.c.SolrZkClient - Using default ZkACLProvider
[info] i.i.s.CloudSolrServers - Connected to zookeeper at ...
[info] o.a.s.c.c.ZkStateReader - Updating cluster state from ZooKeeper... 
[info] i.i.s.CloudSolrServers - Successfully created ZK cluster state watchers at ...
[error] play - Cannot invoke the action, eventually got an error: org.apache.solr.client.solrj.SolrServerException: No solr server available.

@andreaTP
Copy link

with akka scheduled jobs are executed asynchronously and execution time is not strongly guaranteed.
Moreover:
https://github.com/akka/akka/blob/67ca6e5dc70509d279a005763a30fb0bd7c871df/akka-actor/src/main/scala/akka/actor/Scheduler.scala#L299

so 0 delay means an interval 0 > T < (1/maxFrequency)

@andreaTP
Copy link

here is the reference (yellow box:
http://doc.akka.io/docs/akka/2.3.4/scala/scheduler.html
)

@fralken
Copy link
Author

fralken commented Jun 19, 2015

In initZkStateReaderyou could initialize the update like this:

  // Now regularly update the server list from ZkStateReader clusterState
  updateFromClusterState(zkStateReader)
  scheduledExecutor.scheduleAtFixedRate(new Runnable {
    override def run(): Unit = updateFromClusterState(zkStateReader)
  }, clusterStateUpdateInterval.toMillis, clusterStateUpdateInterval.toMillis, TimeUnit.MILLISECONDS)

so that the first execution is guaranteed to be synchronus, and then the other are scheduled to be executed starting after the desired interval

magro added a commit that referenced this issue Jun 19, 2015
Scheduler thread creation might take too long as indicated by
issue #7
@magro
Copy link
Member

magro commented Jun 19, 2015

I just changed it like this, its as version 1.3.2 on its way to maven central. Does this work for you?

@fralken
Copy link
Author

fralken commented Jun 19, 2015

Yes, it works. Thanks.

@magro
Copy link
Member

magro commented Jun 19, 2015

Great!

@magro magro closed this as completed Jun 19, 2015
@andreaTP
Copy link

tnx!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants