The database cache store can read from a read replica and miss fresh writes
Maintainers usually reply within 1 day
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 35/100
Research direction
Start in src/cache/database.rs and read DatabaseStore::get alongside the write and increment paths to see how connection selection works. The issue suggests reading through the write connection or adding an option and documenting it in the cache guide. Done means database cache reads see fresh writes across requests; an open pull request is already linked.
Written by the indexing model from the issue text.
Description
DatabaseStore::get builds its query without use_write_connection(). On a connection with read replicas, a cache read can go to a lagging replica and return None (or an old value) for a key that another request or process has just written. Sticky reads only cover writes made in the same request.
That matters for cache uses that rely on read-after-write across processes: one-time tokens, counters read back after increment, a value written by one request and read by the next. Redis and memory stores don't have this gap, so the same code behaves differently on the database store.
// laravel-rust 0.2.0, src/cache/database.rs
async fn get(&self, key: &str) -> Result<Option<String>> {
let values = self.values()?.filter(col("key").eq(key));
let row = values
.clone()
.select(["value", "expiration"])
.into_query()
// no .use_write_connection()
...
Suggestion
Either read the cache table from the write connection (cache tables are small, and correctness beats offloading), or add a store option such as DatabaseStore::new().read_from_writer(true), and document the behaviour in the cache guide.
Seen on 0.2.0; the same code is on 0.x at 6156f0e.
- Dominant language
- Rust
- Stars
- 847
- Forks
- 174
- Avg merge
- 5h 40m
- Merged PRs (30d)
- 167
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from laravel/rust-framework
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
laravel/rust-framework#864 ·
Maintainers usually reply within 1 day
-
Difficulty 3/5 1-2 days Newbie friendliness 64/100
laravel/rust-framework#876 ·
Maintainers usually reply within 1 day
-
Case-sensitive contains, starts_with and ends_with that match % and _ literally on every databaseOpen
Difficulty 4/5 3-5 days Newbie friendliness 58/100
laravel/rust-framework#874 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
laravel/rust-framework#873 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 58/100
laravel/rust-framework#872 ·
Maintainers usually reply within 1 day
All issues in laravel/rust-framework
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
Commit lockfileOpen
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
rust-lang/socket2#703 · 1 comment ·
Maintainers usually reply within 1 day
-
infra
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
available bug good first issue tooling
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
Nixitov/Riptide-Native#817 ·
Maintainers usually reply within 1 day