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
5 changes: 4 additions & 1 deletion engine/packages/api-public/src/migration/export.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,11 +169,14 @@ pub async fn export(ctx: ApiCtx, actor_id: Id, query: ExportQuery) -> Result<Res
}),
};

// The process's own node id, as every other depot database in this process uses: the depot
// metrics are labelled by it, so a fresh id per export would add a set of series for every
// exported actor until the process restarts.
let depot_db = Db::new(
udb.clone(),
namespace_id,
actor_id.to_string(),
rivet_pools::NodeId::new(),
ctx.pools().node_id(),
)
.with_config(ctx.config().clone());

Expand Down
1 change: 1 addition & 0 deletions engine/packages/engine/tests/actor_v2_2_1_migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ async fn actor_v2_2_1_baseline_migrates_to_current_layout() -> Result<()> {
let migration = pegboard::actor_sqlite::migrate_v1_to_v2(
db.clone(),
standalone_ctx.config().clone(),
standalone_ctx.pools().node_id(),
pegboard::actor_sqlite::MigrateV1ToV2Input {
actor_id: actor.actor_id,
namespace_id: namespace.namespace_id,
Expand Down
9 changes: 7 additions & 2 deletions engine/packages/pegboard/src/actor_sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,13 @@ pub struct MigrateV1ToV2Output {
pub migrated: bool,
}

/// Migrates the actor's v1 SQLite data to the v2 format. `node_id` is the process's own, which
/// labels the depot metrics; a fresh id per migration would add a set of series for every
/// migrated actor until the process restarts.
pub async fn migrate_v1_to_v2(
db: universaldb::Database,
config: rivet_config::Config,
node_id: NodeId,
input: MigrateV1ToV2Input,
) -> Result<MigrateV1ToV2Output> {
let recipient = Recipient {
Expand All @@ -90,14 +94,15 @@ pub async fn migrate_v1_to_v2(
name: input.name,
};

let migrated = maybe_migrate_v1_to_v2(&db, &config, &recipient).await?;
let migrated = maybe_migrate_v1_to_v2(&db, &config, node_id, &recipient).await?;

Ok(MigrateV1ToV2Output { migrated })
}

async fn maybe_migrate_v1_to_v2(
db: &universaldb::Database,
config: &rivet_config::Config,
node_id: NodeId,
recipient: &Recipient,
) -> Result<bool> {
if !crate::actor_kv::sqlite_v1_data_exists(db, recipient.actor_id).await? {
Expand Down Expand Up @@ -143,7 +148,7 @@ async fn maybe_migrate_v1_to_v2(
Arc::new(db.clone()),
recipient.namespace_id,
actor_id.clone(),
NodeId::new(),
node_id,
)
.with_config(config.clone());

Expand Down
1 change: 1 addition & 0 deletions engine/packages/pegboard/src/workflows/actor2/sqlite.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pub async fn migrate_sqlite_v1_to_v2(
actor_sqlite::migrate_v1_to_v2(
db,
ctx.config().clone(),
ctx.pools().node_id(),
actor_sqlite::MigrateV1ToV2Input {
actor_id: input.actor_id,
namespace_id: input.namespace_id,
Expand Down
1 change: 1 addition & 0 deletions engine/packages/pegboard/tests/actor_sqlite_migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ async fn migrate(
pegboard::actor_sqlite::migrate_v1_to_v2(
db.clone(),
rivet_config::Config::from_root(rivet_config::config::Root::default()),
rivet_pools::NodeId::new(),
pegboard::actor_sqlite::MigrateV1ToV2Input {
actor_id,
namespace_id: test_namespace(),
Expand Down
Loading