I have an application that:
- Uses an embedded RavenDB database
- With the Monotonic read option
- With static indexes
I've noticed that when the application starts up, the indexes are all temporarily stale even if they weren't stale when the application shutdown (cleanly) the previous run.
For example, I run the app, insert 10 records, and wait for the indexes to be up to date. I query it and see the results I expect. Then I close the app, start it again, and query, and I get no results. A second later the indexes have updated and I can now get results back. If I repeat this, sometimes I get 10 results, sometimes 0 results, sometimes 2 results.
My assumption was that when querying an index at time T, I would always see "at least as consistent" results at T + 1. However if the server restarts during this time I seem to see less consistent results at T + 1. This isn't eventual consistency, it's eventual inconsistency! :)
My questions are:
- Was my assumption wrong/stupid?
- Is there a way to prevent this from happening?
- Is this behavior just a starting up thing, or could this potentially happen at any time? For example, could I render 10 results, then on refresh 0 results, and then again 10 results the next refresh just because Raven decided it wanted to re-index everything?