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

Fix admin index page #390

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

StefanVanDyck
Copy link

@StefanVanDyck StefanVanDyck commented Sep 10, 2024

The admin page was broken on our deployment. (500 internal server error cause by a null-pointer reference)
This was caused by our SOLR not using the default core names: bie and bie-offline.

We are running SOLR 8 in "cloud" mode.
That seems to make the collections use strange core name like bie_shard1_replica_n1, etc.
The table, showing the stats for the cores, was using hardcoded core names however.

This change instead remove all expectations for names and simply loops over all cores returned in the status.
Instead of expecting very specific core names to be present in the status call.

So this does alter the behavior, as now all cores will show up.
But it is safer, because not having a bie or bie-offline core will not prevent the page from loading.

If you prefer, I could alway add some logic to filter cores based on a prefix value, e.g. "bie-"

Copy link
Contributor

@vjrj vjrj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works for me, with solr (so ALA is not affected):

image

and solrcloud:

image

The only think I see is that the swap button/step will fail for solrcloud. I think that this can be addressed in other PR.

BTW I was solving this in a different and "wip" way:

diff --git a/grails-app/services/au/org/ala/bie/IndexService.groovy b/grails-app/services/au/org/ala/bie/IndexService.groovy
index 752f833..74283f4 100644
--- a/grails-app/services/au/org/ala/bie/IndexService.groovy
+++ b/grails-app/services/au/org/ala/bie/IndexService.groovy
@@ -7,6 +7,7 @@ import grails.config.Config
 import grails.core.support.GrailsConfigurationAware
 import org.apache.solr.client.solrj.SolrQuery
 import org.apache.solr.client.solrj.SolrRequest
+import org.apache.solr.client.solrj.request.CollectionAdminRequest
 import org.apache.solr.client.solrj.request.CoreAdminRequest
 import org.apache.solr.client.solrj.response.QueryResponse
 import org.apache.solr.common.SolrDocument
@@ -24,6 +25,7 @@ class IndexService implements GrailsConfigurationAware {
     def offlineSolrClient
     def updatingLiveSolrClient
     def adminSolrClient
+    def grailsApplication
 
     // Configuration
     SolrQuery searchTemplate
@@ -79,18 +81,33 @@ class IndexService implements GrailsConfigurationAware {
     }
 
     def swap() {
-        log.info("Swapping index")
-        CoreAdminRequest car = new CoreAdminRequest()
-        car.setCoreName("bie")
-        car.setOtherCoreName("bie-offline")
-        car.setAction(CoreAdminParams.CoreAdminAction.SWAP)
-        car.process(adminSolrClient.client)
+        boolean usingSolrCloud = grailsApplication.config.getProperty('usingSolrCloud', Boolean, false)
+
+        if (usingSolrCloud) {
+            log.info("Not implemented: Swap index in SolrCloud manually")
+        } else {
+            log.info("Swapping index in Solr standalone mode")
+            CoreAdminRequest car = new CoreAdminRequest()
+            car.setCoreName("bie")
+            car.setOtherCoreName("bie-offline")
+            car.setAction(CoreAdminParams.CoreAdminAction.SWAP)
+            car.process(adminSolrClient.client)
+        }
     }

@StefanVanDyck
Copy link
Author

Hey @vjrj
Thanks for having a look!

So based on your comments, I guess that means the Australian living atlas no longer uses Solr, but Elasticsearch?
That's definitely good to know :)

Have you tried the current swapping code with solrcloud yet?
Haven't looked at that code, but in the end all the other functionality seems to work just fine for use using the normal core names.
Only that status table seemed to be complaining?
So if the swapping simply switches the names used by the bie-index, maybe things just work?

But like I said, I haven't really tried that stuff myself.
Still need to work on having some proper backups of the solr collections before I try that button ;)

@vjrj
Copy link
Contributor

vjrj commented Oct 24, 2024

I’m not sure what is using ALA currently in prod or testing, but traditionally they used a solr for bie, and solrcloud for biocache.

In our portal we use a single solrcloud cluster for both (as you can see in the screenshot).

And I didn't try the swap button because I tested the index query in our prod solrcloud and I imagine it will fail as it calls to a solr swap api command.

@StefanVanDyck
Copy link
Author

Ah I had no idea there was a solr native api for swapping :)
In that case you are most likely absolutely correct about the need for some more development.

Thanks for the info!

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

Successfully merging this pull request may close these issues.

2 participants