To update a driver to its new location, we must find the right grid based on the driver’s previous location. If the new position does not belong to the current grid, we have to remove the driver from the current grid and move/reinsert the user to the correct grid
So we send locationInfo - {old_lat,old_lang,new_lat,new_lang}
from Driver Location Server to QuadTreeServer to update the driver location and move him/her to the right grid
. What happens if the locationInfo is lost due either Driver Location Server going down and communication backend to the QuadServer going down. I understand we will get the updates every 3 seconds but we need all the locationInfo to move the driver to the right grid
otherwise next time the Driver Location Server sends the locationInfo
we will have the same driver in 2 different grid points.
E.g.
- Driver 1 is in
Loc1
which is represented by Grid1 - Driver 1 moves to
Loc2
which is represented by Grid2 - Driver Location Server communicates to Quad Server to move Driver 1 from Grid1 and moved to Grid2
- Driver 1 moves to
Loc3
which is represented by Grid3. - Driver Location Server fails to communicate to QuadGridServer
- Driver 1 moves to
Loc4
which is represented by Grid4. - Driver Location Server communicates to Quad Server to move Driver 1 from Grid3 and moved to Grid4
- Error! - Possible outcome Driver 1 exists on both Grid2 and Grid 4
How should we handle this scenario. Maybe have a cleanup job which is trigger when an error is encountered