lanedirt / OGameX

Open-source OGame redesign clone built with Laravel 11.x.
https://main.ogamex.dev
MIT License
10 stars 8 forks source link

[BUG] Missions sometimes result in two messages being sent (duplicate processing?) #250

Open lanedirt opened 4 days ago

lanedirt commented 4 days ago

Describe the bug Sometimes when sending a mission the process handler which processes the arriving mission seems to be firing more than once.

To Reproduce Steps to reproduce the behavior:

  1. Send a colony ship on a colonize mission.
  2. Recall the fleet after a few seconds.
  3. Wait for the fleet to come back.
  4. Sometimes the message that says the fleet has returned appears twice. Note: this does not happen always, just in some cases.

Expected behavior The mission process logic to only fire once and thus only one "fleet has returned" message received.

Screenshots

Screenshot 2024-07-01 at 10 43 18

Additional context Not sure yet what the root cause is and why it's not happening always. Might have to do with parallel requests which both trigger the update logic and causing a race condition where two requests are simultaneously processing updates.

Currently planet updates happen on every request. See PlanetService::update() which contains the updateFleetMission() call. Perhaps we will need to refactor the planet update logic to add a locking mechanism or move processing logic to an event queue or similar.