Skip to content

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

@laserval

Description

@laserval

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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions