From ec77c00ef80248e9eceec800082e34547f9aa084 Mon Sep 17 00:00:00 2001 From: dullbananas Date: Thu, 23 May 2024 11:05:35 -0700 Subject: [PATCH] Fix lost separation caused by comment width change (#4739) * Update post_view.rs * Update structs.rs * Update worker.rs * Update worker.rs --- crates/db_views/src/post_view.rs | 2 +- crates/db_views/src/structs.rs | 2 +- crates/federate/src/worker.rs | 8 +++++--- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/db_views/src/post_view.rs b/crates/db_views/src/post_view.rs index 14a9b4f81..afb0f435f 100644 --- a/crates/db_views/src/post_view.rs +++ b/crates/db_views/src/post_view.rs @@ -652,7 +652,7 @@ impl<'a> PostQuery<'a> { pool: &mut DbPool<'_>, ) -> Result>, Error> { // first get one page for the most popular community to get an upper bound for the page end for - // the real query the reason this is needed is that when fetching posts for a single + // the real query. the reason this is needed is that when fetching posts for a single // community PostgreSQL can optimize the query to use an index on e.g. (=, >=, >=, >=) and // fetch only LIMIT rows but for the followed-communities query it has to query the index on // (IN, >=, >=, >=) which it currently can't do at all (as of PG 16). see the discussion diff --git a/crates/db_views/src/structs.rs b/crates/db_views/src/structs.rs index b37abab37..350e4cad4 100644 --- a/crates/db_views/src/structs.rs +++ b/crates/db_views/src/structs.rs @@ -113,7 +113,7 @@ pub struct PostReportView { } /// currently this is just a wrapper around post id, but should be seen as opaque from the client's -/// perspective stringified since we might want to use arbitrary info later, with a P prepended to +/// perspective. stringified since we might want to use arbitrary info later, with a P prepended to /// prevent ossification (api users love to make assumptions (e.g. parse stuff that looks like /// numbers as numbers) about apis that aren't part of the spec #[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)] diff --git a/crates/federate/src/worker.rs b/crates/federate/src/worker.rs index b2d897522..c11c019d6 100644 --- a/crates/federate/src/worker.rs +++ b/crates/federate/src/worker.rs @@ -37,8 +37,8 @@ use tokio_util::sync::CancellationToken; use tracing::{debug, info, trace, warn}; /// Check whether to save state to db every n sends if there's no failures (during failures state is -/// saved after every attempt) This determines the batch size for loop_batch. After a batch ends and -/// SAVE_STATE_EVERY_TIME has passed, the federation_queue_state is updated in the DB. +/// saved after every attempt). This determines the batch size for loop_batch. After a batch ends +/// and SAVE_STATE_EVERY_TIME has passed, the federation_queue_state is updated in the DB. static CHECK_SAVE_STATE_EVERY_IT: i64 = 100; /// Save state to db after this time has passed since the last state (so if the server crashes or is /// SIGKILLed, less than X seconds of activities are resent) @@ -161,7 +161,9 @@ impl InstanceWorker { id } else { // this is the initial creation (instance first seen) of the federation queue for this - // instance skip all past activities: + // instance + + // skip all past activities: self.state.last_successful_id = Some(latest_id); // save here to ensure it's not read as 0 again later if no activities have happened self.save_and_send_state(pool).await?;