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

Modifications stored in the cache are lost if database writes fail for markProcessed et al #335

Open
laserval opened this issue Jun 4, 2014 · 0 comments

Comments

@laserval
Copy link
Contributor

laserval commented Jun 4, 2014

Final changes to documents are saved by the markProcessed, markFailed, markDiscarded etc methods. These methods should remove the document from the cache and save it to the database.
It is possible that modifications to documents can be lost entirely if the write to the database fails.

https://github.com/Findwise/Hydra/blob/master/database/src/main/java/com/findwise/hydra/CachingDocumentNIO.java#L121

    DatabaseDocument<T> cached = cache.getDocumentById(d.getID());
    if (cached != null) {
        d.putAll(cached);
        cache.remove(d.getID());
    }
    if (writer.markProcessed(d, stage)) {
        return true;
    }
    return false;

Above, the document is first removed from the cache (if present), then the write is attempted. If the write returns false (i.e. fails), markProcessed returns false as well. This should mean that the document has not been saved and as such you would expect that the document in the cache would still be there.

From the code, it appears this is not the case.

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

No branches or pull requests

1 participant