Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions app/Jobs/ProcessFleetArrival.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,18 @@ class ProcessFleetArrival implements ShouldQueue
use Queueable;
use SerializesModels;

public int $tries = 3;

public int $timeout = 120;
/**
* Allow several lock-contention retries while a large battle holds the
* destination lock (release delay is 30s; see handle()).
*/
public int $tries = 10;

/**
* Must be >= the destination Cache::lock TTL (600s) so a long battle cannot
* be killed by the queue worker while still holding the lock.
* Issue #363 noted multi-million-unit battles can take 10s+; leave headroom.
*/
public int $timeout = 600;

public function __construct(public int $missionId)
{
Expand Down
7 changes: 3 additions & 4 deletions app/Services/FleetMissionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -713,10 +713,9 @@ public function processDueMissionEventsForMission(FleetMission $mission): void
{
$lockKey = $this->getMissionDestinationLockKey($mission);

// Lock TTL of 180s provides headroom for long-running battles.
// A TTL shorter than the actual processing time risks expiring mid-transaction,
// allowing another worker to enter and observe uncommitted writes.
Cache::lock($lockKey, 180)->block(10, function () use ($mission) {
// Lock TTL must stay >= ProcessFleetArrival::$timeout so a long battle cannot
// outlive the lock and let another worker observe uncommitted writes.
Cache::lock($lockKey, 600)->block(10, function () use ($mission) {
DB::transaction(function () use ($mission) {
$currentTime = (int) Date::now()->timestamp;

Expand Down
4 changes: 3 additions & 1 deletion docker/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ if [ "$role" = "scheduler" ]; then
sleep 60
done
elif [ "$role" = "queue" ]; then
php /var/www/artisan queue:work --queue=fleet-arrivals,default --verbose --no-interaction
# --sleep=0.5 keeps delayed fleet arrivals snappy (default sleep is 3s).
# --timeout=600 matches ProcessFleetArrival::$timeout for large battles.
php /var/www/artisan queue:work --queue=fleet-arrivals,default --sleep=0.5 --timeout=600 --verbose --no-interaction
elif [ "$role" = "reverb" ]; then
php /var/www/artisan reverb:start --host="${REVERB_SERVER_HOST:-0.0.0.0}" --port="${REVERB_SERVER_PORT:-8090}"
elif [ "$role" = "app" ]; then
Expand Down
Loading