Skip to content

Dropping Log lines when logBuffer.tryClaim fails to get positive claim value #106

@ayubkhan

Description

@ayubkhan

We are loosing logs using this library. We have tried bufferSizeMegabytes="128" but still can reproduce.

https://github.com/tkowalcz/tjahzi/blob/master/core/src/main/java/pl/tkowalcz/tjahzi/TjahziLogger.java#L35

I have tested this with "LokiAppenderTest.java" after modifying TjahziLogger.java to randomly fix claim=0.
When claim=0, the "LokiAppenderTest.java" test fails after repeatedly printing status logs.

    public TjahziLogger log(long timestamp,
                            LabelSerializer serializedLabels,
                            ByteBuffer line) {
...
        int claim = logBuffer.tryClaim(LOG_MESSAGE_TYPE_ID, requiredSize);
        boolean tryToFail = new Random().nextBoolean();
        if (tryToFail) {
            claim = 0;
        }
        if (claim > 0) {
            putMessageOnRing(

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions