ExpediaInc/seyren — pull request #10 by Joholland (2014-08-05 21:26:36+00:00)
Title: Fix Persistance Bugs & Performance Optimizations

Hi,

My team has encountered some issues with Seyren where changes wouldn't "stick". After looking at the code, I identified a race condition between the CheckScheduler and persisting a change from the UI that would cause the "last one in" to win on the state of the check object in Mongo.

The fix is to do a in place atomic update of the check state, instead of pulling the check object, updating state, and saving it.

I went ahead and fixed the persistence logic in all of the areas where data could be clobbered.

While fixing it, I also moved the Mongo code from using the deprecated MongoURI class to the modern MongoClient class. This might actually give a minor performance improvement as MongoClient pools connections.

I also fixed a minor bug on boolean parsing in the mongo mapper, and added indexes for the queries on checks and alerts. This should significantly help performance across the board when you have a large number of checks & alerts.

I suspect there may be other issues as we see deleted checks still alerting on occasion, but this is a start. I'll probably open another pull with additional fixes.