Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

refactor(process_tracker): attempt to identify unintended 5xx in process_tracker (#1359)

Abhishek Marrivagud8adf4c2b542
diff --git a/crates/router/src/core/refunds.rs b/crates/router/src/core/refunds.rs
index 7d9553da16..810e12f462 100644
--- a/crates/router/src/core/refunds.rs
+++ b/crates/router/src/core/refunds.rs
@@ -929,7 +929,7 @@ pub async fn add_refund_sync_task(
.attach_printable_lazy(|| format!("unable to convert into value {:?}", &refund))?;
let task = "SYNC_REFUND";
let process_tracker_entry = storage::ProcessTrackerNew {
- id: format!("{}_{}_{}", runner, task, refund.id),
+ id: format!("{}_{}_{}", runner, task, refund.internal_reference_id),
name: Some(String::from(task)),
tag: vec![String::from("REFUND")],
runner: Some(String::from(runner)),
@@ -947,7 +947,7 @@ pub async fn add_refund_sync_task(
let response = db
.insert_process(process_tracker_entry)
.await
- .change_context(errors::ApiErrorResponse::InternalServerError)
+ .to_duplicate_response(errors::ApiErrorResponse::DuplicateRefundRequest)
.attach_printable_lazy(|| {
format!(
"Failed while inserting task in process_tracker: refund_id: {}",
@@ -970,7 +970,7 @@ pub async fn add_refund_execute_task(
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable_lazy(|| format!("unable to convert into value {:?}", &refund))?;
let process_tracker_entry = storage::ProcessTrackerNew {
- id: format!("{}_{}_{}", runner, task, refund.id),
+ id: format!("{}_{}_{}", runner, task, refund.internal_reference_id),
name: Some(String::from(task)),
tag: vec![String::from("REFUND")],
runner: Some(String::from(runner)),
@@ -988,7 +988,7 @@ pub async fn add_refund_execute_task(
let response = db
.insert_process(process_tracker_entry)
.await
- .change_context(errors::ApiErrorResponse::InternalServerError)
+ .to_duplicate_response(errors::ApiErrorResponse::DuplicateRefundRequest)
.attach_printable_lazy(|| {
format!(
"Failed while inserting task in process_tracker: refund_id: {}",
diff --git a/crates/router/src/scheduler/consumer.rs b/crates/router/src/scheduler/consumer.rs
index 525f1a6492..21f10b46d5 100644
--- a/crates/router/src/scheduler/consumer.rs
+++ b/crates/router/src/scheduler/consumer.rs
@@ -249,11 +249,3 @@ pub async fn consumer_error_handler<E: fmt::Display + fmt::Debug>(
.change_context(errors::ProcessTrackerError::ProcessUpdateFailed)?;
Ok(())
}
-
-pub async fn create_task(
- db: &dyn StorageInterface,
- process_tracker_entry: storage::ProcessTrackerNew,
-) -> CustomResult<(), errors::StorageError> {
- db.insert_process(process_tracker_entry).await?;
- Ok(())
-}