8000 fix: idx cache inconsistency by ellie · Pull Request #2231 · atuinsh/atuin · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: idx cache inconsistency #2231

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 3, 2024
Merged
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
19 changes: 10 additions & 9 deletions crates/atuin-client/src/record/sqlite_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,15 +219,16 @@ impl Store for SqliteStore {
idx: RecordIdx,
limit: u64,
) -> Result<Vec<Record<EncryptedData>>> {
let res =
sqlx::query("select * from store where idx >= ?1 and host = ?2 and tag = ?3 limit ?4")
.bind(idx as i64)
.bind(host.0.as_hyphenated().to_string())
.bind(tag)
.bind(limit as i64)
.map(Self::query_row)
.fetch_all(&self.pool)
.await?;
let res = sqlx::query(
"select * from store where idx >= ?1 and host = ?2 and tag = ?3 order by idx asc limit ?4",
)
.bind(idx as i64)
.bind(host.0.as_hyphenated().to_string())
.bind(tag)
.bind(limit as i64)
.map(Self::query_row)
.fetch_all(&self.pool)
.await?;

Ok(res)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/atuin-server-postgres/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ impl Database for Postgres {
"insert into store_idx_cache
(user_id, host, tag, idx)
values ($1, $2, $3, $4)
on conflict(user_id, host, tag) do update set idx = $4
on conflict(user_id, host, tag) do update set idx = greatest(idx, $4)
",
)
.bind(user.id)
Expand Down
Loading
0