Drop overlaps when saving timespans #4830
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There have been new reports of overlapping timespans. I have two vaguely unlikely theories how this could have happened:
(1) the singleton creation of the timespan service fails, there is more than one timespan service, so the merging fails
(2) there are negative durations in reported timespans due to weird request ordering or some unknown bug in the front-end
This PR deals with (2). Before, negative durations were considered interrupted, so new timespans were created in the db, with overlaps. Now, the overlap is detected and the timestamps that overlap into an existing timespan are dropped. Also, a warning is logged in this case (also including the service hash/id, hopefully giving us insights into both theories).
With the insights gained we should also be able to debug where the negative timespans, if any, come from.
URL of deployed dev instance (used for testing):
Steps to test:
Issues: