Skip to content

Commit a7d0289

Browse files
committed
chore: do not merge: disable reschedule backoff
1 parent e662b92 commit a7d0289

File tree

35 files changed

+439
-184
lines changed

35 files changed

+439
-184
lines changed

.gitattributes

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
# Prevent from counting in the language statistics
1313
engine/artifacts/** linguist-generated=true
1414
engine/sdks/** linguist-generated=true
15+
engine/sdks/typescript/runner/** linguist-generated=false
16+
engine/sdks/typescript/test-runner/** linguist-generated=false
1517
engine/sdks/schema/** linguist-generated=false
1618

1719
website/public/llms.txt linguist-generated=true

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

engine/packages/api-public/src/actors/get_or_create.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
use anyhow::Result;
2-
use axum::{
3-
http::HeaderMap,
4-
response::{IntoResponse, Response},
5-
};
2+
use axum::response::{IntoResponse, Response};
63
use rivet_api_builder::{
74
ApiError,
85
extract::{Extension, Json, Query},
@@ -77,11 +74,10 @@ pub struct GetOrCreateResponse {
7774
)]
7875
pub async fn get_or_create(
7976
Extension(ctx): Extension<ApiCtx>,
80-
headers: HeaderMap,
8177
Query(query): Query<GetOrCreateQuery>,
8278
Json(body): Json<GetOrCreateRequest>,
8379
) -> Response {
84-
match get_or_create_inner(ctx, headers, query, body).await {
80+
match get_or_create_inner(ctx, query, body).await {
8581
Ok(response) => Json(response).into_response(),
8682
Err(err) => ApiError::from(err).into_response(),
8783
}
@@ -90,7 +86,6 @@ pub async fn get_or_create(
9086
#[tracing::instrument(skip_all)]
9187
async fn get_or_create_inner(
9288
ctx: ApiCtx,
93-
headers: HeaderMap,
9489
query: GetOrCreateQuery,
9590
body: GetOrCreateRequest,
9691
) -> Result<GetOrCreateResponse> {

engine/packages/api-public/src/health.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ async fn fanout_inner(ctx: ApiCtx) -> Result<FanoutResponse> {
8787
}
8888
} else {
8989
// Remote datacenter - HTTP request
90-
match send_health_checks(&ctx, &dc).await {
90+
match send_health_checks(&dc).await {
9191
Ok(response) => DatacenterHealth {
9292
datacenter_label: dc.datacenter_label,
9393
datacenter_name: dc.name.clone(),
@@ -129,7 +129,6 @@ async fn fanout_inner(ctx: ApiCtx) -> Result<FanoutResponse> {
129129

130130
#[tracing::instrument(skip_all)]
131131
async fn send_health_checks(
132-
ctx: &ApiCtx,
133132
dc: &rivet_config::config::topology::Datacenter,
134133
) -> Result<HealthResponse> {
135134
let client = rivet_pools::reqwest::client().await?;

engine/packages/api-public/src/runner_configs/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ pub async fn fetch_serverless_runner_metadata(
114114
});
115115
}
116116

117-
let payload = serde_json::from_str::<ServerlessMetadataPayload>(&body_raw).map_err(|err| {
117+
let payload = serde_json::from_str::<ServerlessMetadataPayload>(&body_raw).map_err(|_| {
118118
ServerlessMetadataError::InvalidResponseJson {
119119
body: body_for_user,
120120
}

engine/packages/epoxy/src/ops/explicit_prepare.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -79,15 +79,8 @@ pub async fn epoxy_explicit_prepare(
7979
let result = match analyze_prepare_responses(&highest_ballot_responses, instance) {
8080
PrepareDecision::Commit(payload) => {
8181
// EPaxos Step 29: Run Commit phase
82-
let result = crate::ops::propose::commit(
83-
ctx,
84-
&config,
85-
replica_id,
86-
&quorum_members,
87-
payload,
88-
false,
89-
)
90-
.await?;
82+
let result =
83+
crate::ops::propose::commit(ctx, &config, replica_id, payload, false).await?;
9184
convert_proposal_result(result)
9285
}
9386
PrepareDecision::Accept(payload) => {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
pub mod get_local;
22
pub mod get_optimistic;
3+
pub mod purge_local;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
use anyhow::*;
2+
use epoxy_protocol::protocol::ReplicaId;
3+
use gas::prelude::*;
4+
5+
use crate::keys;
6+
7+
#[derive(Debug)]
8+
pub struct Input {
9+
pub replica_id: ReplicaId,
10+
pub keys: Vec<Vec<u8>>,
11+
}
12+
13+
#[operation]
14+
pub async fn epoxy_kv_purge_local(ctx: &OperationCtx, input: &Input) -> Result<()> {
15+
ctx.udb()?
16+
.run(|tx| async move {
17+
let tx = tx.with_subspace(keys::subspace(input.replica_id));
18+
19+
for key in &input.keys {
20+
tx.delete(&keys::keys::KvOptimisticCacheKey::new(key.clone()));
21+
}
22+
23+
Ok(())
24+
})
25+
.await?;
26+
27+
Ok(())
28+
}

engine/packages/epoxy/src/ops/propose.rs

Lines changed: 44 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
use anyhow::*;
2+
use base64::Engine;
3+
use base64::engine::general_purpose::STANDARD as BASE64;
24
use epoxy_protocol::protocol::{self, Path, Payload, ReplicaId};
35
use gas::prelude::*;
46
use rivet_api_builder::prelude::*;
@@ -68,15 +70,7 @@ pub async fn epoxy_propose(ctx: &OperationCtx, input: &Input) -> Result<Proposal
6870

6971
match path {
7072
Path::PathFast(protocol::PathFast { payload }) => {
71-
commit(
72-
ctx,
73-
&config,
74-
replica_id,
75-
&quorum_members,
76-
payload,
77-
input.purge_cache,
78-
)
79-
.await
73+
commit(ctx, &config, replica_id, payload, input.purge_cache).await
8074
}
8175
Path::PathSlow(protocol::PathSlow { payload }) => {
8276
run_paxos_accept(
@@ -125,15 +119,7 @@ pub async fn run_paxos_accept(
125119

126120
// EPaxos Step 20
127121
if quorum >= utils::calculate_quorum(quorum_members.len(), utils::QuorumType::Slow) {
128-
commit(
129-
ctx,
130-
&config,
131-
replica_id,
132-
&quorum_members,
133-
payload_for_accepts,
134-
purge_cache,
135-
)
136-
.await
122+
commit(ctx, &config, replica_id, payload_for_accepts, purge_cache).await
137123
} else {
138124
Ok(ProposalResult::ConsensusFailed)
139125
}
@@ -144,7 +130,6 @@ pub async fn commit(
144130
ctx: &OperationCtx,
145131
config: &protocol::ClusterConfig,
146132
replica_id: ReplicaId,
147-
quorum_members: &[ReplicaId],
148133
payload: Payload,
149134
purge_cache: bool,
150135
) -> Result<ProposalResult> {
@@ -183,6 +168,27 @@ pub async fn commit(
183168
}
184169
});
185170

171+
if purge_cache {
172+
let keys = payload
173+
.proposal
174+
.commands
175+
.iter()
176+
.map(replica::utils::extract_key_from_command)
177+
.flatten()
178+
.map(|key| BASE64.encode(key))
179+
.collect::<Vec<_>>();
180+
181+
// Purge optimistic cache for all dcs
182+
if !keys.is_empty() {
183+
let ctx = ctx.clone();
184+
tokio::spawn(async move {
185+
if let Err(err) = purge_optimistic_cache(ctx, keys).await {
186+
tracing::error!(?err, "failed purging optimistic cache");
187+
}
188+
});
189+
}
190+
}
191+
186192
if let Some(cmd_err) = cmd_err {
187193
Ok(ProposalResult::CommandError(cmd_err))
188194
} else {
@@ -325,3 +331,22 @@ async fn send_commits(
325331

326332
Ok(())
327333
}
334+
335+
async fn purge_optimistic_cache(ctx: OperationCtx, keys: Vec<String>) -> Result<()> {
336+
for dc in &ctx.config().topology().datacenters {
337+
let workflow_id = ctx
338+
.workflow(crate::workflows::purger::Input {
339+
replica_id: dc.datacenter_label as u64,
340+
})
341+
.tag("replica_id", dc.datacenter_label as u64)
342+
.unique()
343+
.dispatch()
344+
.await?;
345+
ctx.signal(crate::workflows::purger::Purge { keys: keys.clone() })
346+
.to_workflow_id(workflow_id)
347+
.send()
348+
.await?;
349+
}
350+
351+
Ok(())
352+
}

engine/packages/epoxy/src/replica/message_request.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,16 @@ pub async fn message_request(
150150
value: result.value,
151151
})
152152
}
153+
protocol::RequestKind::KvPurgeRequest(req) => {
154+
// Handle KV purge request
155+
ctx.op(ops::kv::purge_local::Input {
156+
replica_id: current_replica_id,
157+
keys: req.keys.clone(),
158+
})
159+
.await?;
160+
161+
protocol::ResponseKind::KvPurgeResponse
162+
}
153163
};
154164

155165
Ok(protocol::Response { kind })

0 commit comments

Comments
 (0)