## Sentry - Issue: PHP-LARAVEL-1V - URL: https://whisper-money.sentry.io/issues/PHP-LARAVEL-1V ## Root cause `ExchangeRateService::getRates()` skipped the database lookup after `preloadRates()` marked a miss, then used `create()` to cache fetched rates. If another request inserted the same `base_currency` + `date` meanwhile, the unique index threw a duplicate-key exception. ## Fix Use atomic Eloquent `upsert()` for exchange-rate cache writes so concurrent requests converge on one row. Added regression coverage for the preload-miss race path. ## Verification - `php artisan test --compact tests/Feature/ExchangeRateServiceTest.php` - `vendor/bin/pint --dirty --format agent` - `php artisan test --compact --filter="getRates tolerates another request storing rates after preload miss"` |
||
|---|---|---|
| .. | ||
| .pest | ||
| Browser | ||
| Feature | ||
| Performance | ||
| Unit | ||
| Pest.php | ||
| TestCase.php | ||
| bootstrap.php | ||