snowplow / snowplow/snowplow-java-tracker

Preserve oldest events when event buffer is full

Open
#308 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

category:data_loss type:enhancement
Dominant language
Java
Stars
25
Forks
35
Avg merge
52m
Merged PRs (30d)
1

Description

Related to discussion in PR #305 - event sending retry.

Since v0.10.0, when an event is added to the Emitter, there is an attempt to add it to the event buffer. If it fails because the event buffer is full, an error message is logged, and the event is lost. This means that older events would be prioritised in the event of network connection loss. We assume that eventually dropping events is better than crashing the whole app.

In versions 0.10.0 and 0.11.0, the event buffer capacity is not configurable, and is the default capacity for a LinkedBlockingQueue - Integer.MAX_VALUE. It is likely that the app would run out of memory before buffering this many events. This capacity will be configurable from version 0.12.0.

In the above PR, events that are in the process of being sent are removed from the main event buffer and put into a temporary collection. If the request is successful they're deleted; if not, they should be returned to the event buffer. If the event buffer is now full, there's nowhere for them to go.

Possible solutions are:

  • Counting how many events are currently being sent and in the pending buffer, and saving space for them in the main event buffer.
  • If a request fails, removing the right number of events from the end of the event buffer to make space for the returnees. This could be difficult locks/synchronisation-wise.

We could also complicate things by allowing users to choose a policy for what to do if the network is down and the Emitter is full - as in the Scala tracker.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading PR #305 and the Emitter's event-buffer handling described in this issue. Compare the proposed approaches for failed sends and define the chosen full-buffer policy; done means events being retried are preserved without losing older buffered events or crashing the application.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.