Skip to content

Durable HttpLogShipper does not process all the messages on dispose #394

Description

@alex-netkachov

Describe the bug

The Durable HttpLogShipper does not process all messages upon shutdown.

To Reproduce

  1. Configure the HTTP sync for the console app.
  2. Run the app once a day.
  3. The app logs a few messages and calls await Serilog.Log.CloseAndFlushAsync(); at the end.
  4. The app runs quickly, so the internal timer does not trigger.

The app sends messages every other day but fails to send all of them.

Expected behavior

When await Serilog.Log.CloseAndFlushAsync(); is called, the app should send all logs.

Analysis

The durable sync creates a bookmark file and a buffer file. The bookmark file's content is offset:::buffer file name, e.g., 5776:::C:\Projects\ConsoleApp1\Logs\Buffer-20241005.txt.

CloseAndFlushAsync triggers HttpLogShipper's OnTick method. See here.

This method reads the bookmark file, checks for events in the buffer, updates the bookmark, and exits if no events are found.

The issue occurs when the app runs the next day: the method reads the bookmark file, finds no new events, updates the bookmark, and exits without sending any events.

The following day, the app sends the events for the previous day, causing a delay that increases by one day with each run.

Reproducing this issue is somewhat complex. I’ve set up an Elastic Stack instance, configured the app, retrieved the logs from the problematic server, and run the app several times with a breakpoint in OnTick.

Activity

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

Metadata

Metadata

Labels

bugSomething isn't working

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions