projectblacklight / spotlight

Spotlight enables librarians, curators, and others who are responsible for digital collections to create attractive, feature-rich websites that highlight these collections.
Other
161 stars 65 forks source link

Relational DB and Solr transactions not synchronized #1676

Open sfdi opened 7 years ago

sfdi commented 7 years ago

If Solr is inaccessible when creating an exhibit, Spotlight will (correctly) throw an exception. However, it will still create several records in the relational DB, including records in the spotlight_exhibits and tags tables. Expected behavior would be to roll back the transactions and leave the DB untouched. Exhibit creation should either succeed or fail completely.

To reproduce: Follow instructions given here: https://github.com/projectblacklight/spotlight/wiki/Contributing-to-Spotlight, specifically, from the cloned directory:

$ rake engine_cart:generate
$ cd .internal_test_app
$ rake spotlight:initialize
$ rails s

Note Solr has not been started. If desired, open the sqlite testing db found in /.internal_test_app/db/development.sqlite3 with sqlite3 or similar and verify that the spotlight_exhibits and tags tables are empty.

Open Spotlight in a browser, log in, and attempt to create an exhibit. This will correctly fail with the exception "Connection refused - Unable to connect to Solr instance", which is a Blacklight::Exceptions::ECONNREFUSED exception.

Now, examine the spotlight_exhibits and tags tables; they will hold entries for the exhibit we attempted to create.

As a final note, I have not check all the other tables exhaustively. It may be that other tables were edited as well.

Reproduction carried out on https://github.com/TAMULib/spotlight/tree/master

cbeer commented 7 years ago

I'm not sure it's that simple. I think exhibit creation is succeeding completely, but when you try to visit the exhibit's dashboard, you're getting an error (as, until then, nothing has required solr access). If you then start solr, everything should work fine, no?

I wonder if a better fix is to ensure that the admin dashboard doesn't break without solr? Obviously, though, without Solr available, the user's experience of the site will be highly degraded.

sfdi commented 7 years ago

Yes, booting solr after the creation makes everything ok. I agree with your suggestion about fixing the dashboard to not break without solr; that error is a significant degradation in user experience. Should I create a new issue for that?