Skip to content
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
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion auction-server/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "auction-server"
version = "0.32.0"
version = "0.32.1"
edition = "2021"
license-file = "license.txt"

Expand Down
5 changes: 4 additions & 1 deletion auction-server/src/kernel/workers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,9 +177,12 @@ pub async fn delete_pg_db_opportunity_history(
delete_threshold_secs: u64,
) -> anyhow::Result<()> {
let threshold = OffsetDateTime::now_utc() - Duration::from_secs(delete_threshold_secs);
// TODO: we filter based on removal_time being not null because some Limo opportunities may be valid longer than the delete threshold.
// However, this makes it so that we don't delete opportunities that are not removed yet, including unremoved ones due to server restarts
// and bugs in the code. As this leads to a low memory leak, we should consider a better way to handle this in the future.
let n_opportunities_deleted = sqlx::query!(
"WITH rows_to_delete AS (
SELECT id FROM opportunity WHERE chain_id = $1 AND creation_time < $2 LIMIT $3
SELECT id FROM opportunity WHERE chain_id = $1 AND creation_time < $2 AND removal_time IS NOT NULL LIMIT $3
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this query is not fast so we should not merge it as we have no index on removal_time (do we?)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Imagine there are opportunities in-memory, then the server gets restarted, now we have some opps in db without removal time which we can safely remove.

) DELETE FROM opportunity WHERE id IN (SELECT id FROM rows_to_delete)",
chain_id,
PrimitiveDateTime::new(threshold.date(), threshold.time()),
Expand Down
Loading