Skip to content

Commit 1437e92

Browse files
committed
remove reducer_outcome
1 parent 904471b commit 1437e92

4 files changed

Lines changed: 19 additions & 13 deletions

File tree

crates/client-api/src/routes/database.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,7 +311,6 @@ pub async fn call_from_database<S: ControlStateDelegate + NodeDelegate>(
311311
Ok(rcr) => {
312312
let (status, body) = match rcr.outcome {
313313
ReducerOutcome::Committed => (StatusCode::OK, "".into()),
314-
ReducerOutcome::Deduplicated => (StatusCode::OK, "deduplicated".into()),
315314
// 422 = reducer ran but returned Err; the IDC actor uses this to distinguish
316315
// reducer failures from transport errors (which it retries).
317316
ReducerOutcome::Failed(errmsg) => (StatusCode::UNPROCESSABLE_ENTITY, *errmsg),
@@ -351,7 +350,7 @@ fn reducer_outcome_response(
351350
outcome: ReducerOutcome,
352351
) -> (StatusCode, Box<str>) {
353352
match outcome {
354-
ReducerOutcome::Committed | ReducerOutcome::Deduplicated => (StatusCode::OK, "".into()),
353+
ReducerOutcome::Committed => (StatusCode::OK, "".into()),
355354
ReducerOutcome::Failed(errmsg) => {
356355
// TODO: different status code? this is what cloudflare uses, sorta
357356
(StatusCode::from_u16(530).unwrap(), *errmsg)

crates/core/src/host/host_controller.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -165,22 +165,19 @@ pub enum ReducerOutcome {
165165
Committed,
166166
Failed(Box<Box<str>>),
167167
BudgetExceeded,
168-
/// The call was identified as a duplicate via the `st_databases_tx_offset` dedup index
169-
/// and was discarded without running the reducer.
170-
Deduplicated,
171168
}
172169

173170
impl ReducerOutcome {
174171
pub fn into_result(self) -> anyhow::Result<()> {
175172
match self {
176-
Self::Committed | Self::Deduplicated => Ok(()),
173+
Self::Committed => Ok(()),
177174
Self::Failed(e) => Err(anyhow::anyhow!(e)),
178175
Self::BudgetExceeded => Err(anyhow::anyhow!("reducer ran out of energy")),
179176
}
180177
}
181178

182179
pub fn is_err(&self) -> bool {
183-
!matches!(self, Self::Committed | Self::Deduplicated)
180+
!matches!(self, Self::Committed)
184181
}
185182
}
186183

crates/core/src/host/module_host.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -589,7 +589,7 @@ pub fn call_identity_connected(
589589
// then insert into `st_client`,
590590
// but if we crashed in between, we'd be left in an inconsistent state
591591
// where the reducer had run but `st_client` was not yet updated.
592-
ReducerOutcome::Committed | ReducerOutcome::Deduplicated => Ok(()),
592+
ReducerOutcome::Committed => Ok(()),
593593

594594
// If the reducer returned an error or couldn't run due to insufficient energy,
595595
// abort the connection: the module code has decided it doesn't want this client.
@@ -629,7 +629,8 @@ pub struct CallReducerParams {
629629
/// The tuple is `(sender_database_identity, sender_msg_id)`.
630630
/// Before running the reducer, `st_inbound_msg` is consulted:
631631
/// if `sender_msg_id` ≤ the stored last-delivered msg_id for the sender,
632-
/// the call is a duplicate and returns [`ReducerCallError::Deduplicated`].
632+
/// the call is a duplicate and returns the stored committed or failed result
633+
/// without running the reducer again.
633634
/// Otherwise the reducer runs, and the stored msg_id is updated atomically
634635
/// within the same transaction.
635636
pub dedup_sender: Option<(Identity, u64)>,
@@ -1500,9 +1501,9 @@ impl ModuleHost {
15001501
..
15011502
}) => fallback(),
15021503

1503-
// If it succeeded (or was deduplicated), as mentioned above, `st_client` is already updated.
1504+
// If it succeeded, as mentioned above, `st_client` is already updated.
15041505
Ok(ReducerCallResult {
1505-
outcome: ReducerOutcome::Committed | ReducerOutcome::Deduplicated,
1506+
outcome: ReducerOutcome::Committed,
15061507
..
15071508
}) => Ok(()),
15081509
}
@@ -1762,7 +1763,7 @@ impl ModuleHost {
17621763
/// delivery using the `st_inbound_msg` dedup index.
17631764
/// Before invoking the reducer, the receiver checks whether
17641765
/// `sender_msg_id` ≤ the last delivered msg_id for `sender_database_identity`.
1765-
/// If so, the call is a duplicate and [`ReducerOutcome::Deduplicated`] is returned
1766+
/// If so, the call is a duplicate and the stored committed or failed result is returned
17661767
/// without running the reducer.
17671768
/// Otherwise the reducer runs, and the dedup index is updated atomically
17681769
/// within the same transaction.

crates/core/src/host/wasm_common/module_host_actor.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,7 @@ impl<T: WasmInstance> WasmModuleInstance<T> {
487487
res
488488
}
489489

490+
490491
pub fn clear_all_clients(&self) -> anyhow::Result<()> {
491492
self.common.clear_all_clients()
492493
}
@@ -892,7 +893,15 @@ impl InstanceCommon {
892893
s if s == st_inbound_msg_result_status::REDUCER_ERROR => {
893894
ReducerOutcome::Failed(Box::new(stored.result_payload.into()))
894895
}
895-
_ => ReducerOutcome::Deduplicated,
896+
_ => {
897+
log::warn!(
898+
"IDC: unexpected inbound dedup result_status={} for sender {}, msg_id={}",
899+
stored.result_status,
900+
sender_identity,
901+
sender_msg_id
902+
);
903+
ReducerOutcome::Committed
904+
}
896905
};
897906
return (
898907
ReducerCallResult {

0 commit comments

Comments
 (0)