Skip to content

Fix read-after-write race in the web cache#240

Merged
thiagoesteves merged 1 commit into
mainfrom
fix/ui-settings-cache-race
Jul 8, 2026
Merged

Fix read-after-write race in the web cache#240
thiagoesteves merged 1 commit into
mainfrom
fix/ui-settings-cache-race

Conversation

@thiagoesteves

@thiagoesteves thiagoesteves commented Jul 7, 2026

Copy link
Copy Markdown
Owner

DeployexWeb.Cache.set/2 was an asynchronous GenServer.cast while get/1 reads the ETS table directly, so a get right after a set could observe the previous value. This surfaced as a flaky UiSettingsTest failure where the setup wrote the cache and the test read a stale entry.

The write is now a synchronous GenServer.call, guaranteeing that any subsequent read observes it.

Risk assessment:

  • Impact: UI settings writes (nav menu toggle) become synchronous. The caller now waits for the cache GenServer, which only does an ETS insert, so the latency is negligible.
  • Blast radius: DeployexWeb.Cache only; the single caller today is Cache.UiSettings.
  • Regression risk: very low. A call can time out if the cache server is overloaded, but it handles rare, tiny writes.
  • Rollback: revert this commit.

Co-Authored-By: Claude Fable 5 noreply@anthropic.com

DeployexWeb.Cache.set/2 was an asynchronous GenServer.cast while get/1
reads the ETS table directly, so a get right after a set could observe
the previous value. This surfaced as a flaky UiSettingsTest failure
where the setup wrote the cache and the test read a stale entry.

The write is now a synchronous GenServer.call, guaranteeing that any
subsequent read observes it.

Risk assessment:
- Impact: UI settings writes (nav menu toggle) become synchronous. The
  caller now waits for the cache GenServer, which only does an ETS
  insert, so the latency is negligible.
- Blast radius: DeployexWeb.Cache only; the single caller today is
  Cache.UiSettings.
- Regression risk: very low. A call can time out if the cache server is
  overloaded, but it handles rare, tiny writes.
- Rollback: revert this commit.
@thiagoesteves thiagoesteves self-assigned this Jul 7, 2026
@thiagoesteves thiagoesteves moved this to In Progress in DeployEx Project Jul 7, 2026
@thiagoesteves thiagoesteves marked this pull request as ready for review July 7, 2026 18:09
@thiagoesteves thiagoesteves merged commit e16ef46 into main Jul 8, 2026
3 checks passed
@thiagoesteves thiagoesteves deleted the fix/ui-settings-cache-race branch July 8, 2026 11:31
@github-project-automation github-project-automation Bot moved this from In Progress to Done in DeployEx Project Jul 8, 2026
thiagoesteves added a commit that referenced this pull request Jul 8, 2026
…guide (#244)

* Update changelog with 0.9.5 entries and document changelog maintenance

Add the missing 0.9.5 entries for the merged PRs: #239, #240, #241 and
#242 as bug fixes, and #237 (CloudWatch log group retention) as an
enhancement. Document the changelog maintenance rules in AGENTS.md so
agents know how to add entries, and remove the outdated note that said
the changelog must not be edited manually.

Risk assessment:
- Impact: documentation only, no runtime behavior changes.
- Blast radius: CHANGELOG.md and AGENTS.md.
- Regression risk: none, docs-only diff.
- Rollback: revert this commit.

* Updated changelog
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant