Skip to content
Draft
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
23 changes: 23 additions & 0 deletions migrations/0004_separate_activation_and_metadata.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
CREATE TABLE IF NOT EXISTS activation_blobs (
id TEXT NOT NULL PRIMARY KEY,
activation BLOB NOT NULL
) STRICT;

CREATE TABLE IF NOT EXISTS activation_metadata (
id TEXT NOT NULL PRIMARY KEY, -- Can be joined with activation_blobs.id
namespace TEXT,
taskname TEXT NOT NULL DEFAULT "",
status TEXT NOT NULL,
received_at INTEGER NOT NULL DEFAULT 0,
added_at INTEGER NOT NULL,
processing_attempts INTEGER NOT NULL,
processing_deadline_duration INTEGER NOT NULL,
processing_deadline INTEGER,
at_most_once INTEGER NOT NULL DEFAULT 0,
on_attempts_exceeded INTEGER NOT NULL DEFAULT 1, -- 1 is Discard
expires_at INTEGER,
delay_until INTEGER
) STRICT;

CREATE INDEX idx_metadata_status
ON activation_metadata (status, added_at, namespace, id);
8 changes: 8 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,10 @@ async fn main() -> Result<(), Error> {
Err(err) => error!("Failed to run full vacuum on startup: {:?}", err),
}
}
info!("Loading metadata state from sqlite");
store.load_metadata().await?;
info!("Loading metadata complete");

// Get startup time after migrations and vacuum
let startup_time = Utc::now();

Expand Down Expand Up @@ -236,5 +240,9 @@ async fn main() -> Result<(), Error> {
.on_completion(log_task_completion("maintenance_task", maintenance_task))
.await;

info!("Flushing metadata to sqlite");
store.flush_metadata().await?;
info!("Shutdown complete");

Ok(())
}
Loading
Loading