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

Ensure queue is always < 1000 items. #751

Merged
merged 1 commit into from
Feb 7, 2018
Merged

Ensure queue is always < 1000 items. #751

merged 1 commit into from
Feb 7, 2018

Conversation

f2prateek
Copy link
Contributor

@f2prateek f2prateek commented Feb 7, 2018

Previously we didn't cap the queue, and when we added the limit, we only removed the oldest element, rather than fully shrink the queue.

Hence there are cases where the queue may already be larger than 1000 events, and removing a single element at a time isn't as helpful. Now we delete as many events as required to trim the queue size.

Ref: LIB-210

Previously we didn't cap the queue, and when we added the limit, we only removed the oldest element, rather than fully shrink the queue.

Hence there are cases where the queue may already be larger than 1000 events. Now we delete as many events as required to trim the queue size.

Ref: LIB-210
@codecov-io
Copy link

Codecov Report

Merging #751 into master will increase coverage by 0.25%.
The diff coverage is 100%.

@@            Coverage Diff             @@
##           master     #751      +/-   ##
==========================================
+ Coverage   86.67%   86.92%   +0.25%     
==========================================
  Files          36       36              
  Lines        2581     2616      +35     
  Branches      177      176       -1     
==========================================
+ Hits         2237     2274      +37     
+ Misses        339      337       -2     
  Partials        5        5

@ladanazita
Copy link
Contributor

We should update docs as well since we are dropping events.

Why not have the logic try to flush the queue when it reaches 1000 and fallback to dropping events?

@f2prateek
Copy link
Contributor Author

The queue already flushes when events > flushCount. If we ever get to this state, it's typically because the device has been offline for an extended period and the last 1000-flushCount attempts have failed (by default flush count is 20, that means the last 9980 attempts have failed). I think it's ok to go ahead to removing the events rather than try to flush the queue yet again. Android also does the same.

I'll add a note in the docs - we were already removing these messages before but looks like we didn't document the old behaviour.

@f2prateek
Copy link
Contributor Author

@f2prateek f2prateek merged commit 2aa8a4a into master Feb 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants