DPIclimate / DPIclimate/broker
Device mappings may overlap
- Dominant language
- Python
- Stars
- 3
- Forks
- 3
- Avg merge
- 3m
- Merged PRs (30d)
- 1
Description
If a new device mapping is created for a currently mapped logical device, the current and new device mapping rows may overlap.
A mapping object with a start time is provided to the insert_mapping function. The start time will likely be some small fraction of a second in the past because it was set by the caller.
insert_mapping calls _end_mapping for the logical device, and _end_mapping sets the end time of the current mapping to now(). This is likely slightly after the start time for the new mapping given to insert_mapping.
So when insert_mapping is finished, the previous mapping may have an end time slightly later than the start time of the current mapping.
_end_mapping (and end_mapping) should take an optional datetime object to use for the end time, and insert_mapping could pass the start time of the new mapping in.
This might also be useful for unit tests, allowing them to end mappings at specific times.
It probably isn't a bad bug as long as we usually use the start times of mappings in queries. The end time is more like a flag value to say a row is not a current mapping. Also, the chance of getting a message or some other signal that causes a query that happens right on a mapping change boundary is slim.
Contributor guide
No contributing guide indexed for this repository
Research direction
Locate insert_mapping, _end_mapping, and end_mapping, then read their existing callers and unit tests. Verify how mapping start and end times are compared, and confirm that the previous mapping ends at the new mapping's start time without breaking current-mapping behavior. Add coverage for explicit end times, including the insert_mapping boundary case.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100