Skip to content

Commit d109a9c

Browse files
authored
fix(cat-gateway): include follower reaching tip condition in ready endpoint (#2676)
1 parent f8c07b5 commit d109a9c

File tree

3 files changed

+13
-11
lines changed

3 files changed

+13
-11
lines changed

catalyst-gateway/bin/src/cardano/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,7 @@ fn sync_subchain(
295295

296296
// Update flag if this is the first time reaching TIP.
297297
if chain_update.tip && !follower_has_first_reached_tip() {
298+
info!("Follower has reached TIP for the first time");
298299
set_follower_first_reached_tip();
299300
}
300301

catalyst-gateway/bin/src/service/api/health/ready_get.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,9 @@ use crate::{
8585
},
8686
service::{
8787
common::{responses::WithErrorResponses, types::headers::retry_after::RetryAfterOption},
88-
utilities::health::{event_db_is_live, index_db_is_live, set_event_db_liveness},
88+
utilities::health::{
89+
condition_for_started, event_db_is_live, index_db_is_live, set_event_db_liveness,
90+
},
8991
},
9092
};
9193

@@ -143,16 +145,9 @@ pub(crate) async fn endpoint() -> AllResponses {
143145
drop(CassandraSession::wait_until_ready(INDEXING_DB_READY_WAIT_INTERVAL, true).await);
144146
}
145147

146-
let success_response = Responses::NoContent.into();
147-
148-
// Return 204 response if check passed initially.
149-
if index_db_live && event_db_live {
150-
return success_response;
151-
}
152-
153148
// Otherwise, re-check, and return 204 response if all is good.
154-
if index_db_is_live() && event_db_is_live() {
155-
return success_response;
149+
if condition_for_started() {
150+
return Responses::NoContent.into();
156151
}
157152

158153
// Otherwise, return 503 response.

catalyst-gateway/bin/src/service/utilities/health/start.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ use std::sync::atomic::{
55
Ordering::{Acquire, Release},
66
};
77

8+
use tracing::debug;
9+
810
/// Flag to determine if the service has started
911
static STARTED: AtomicBool = AtomicBool::new(false);
1012

@@ -30,7 +32,11 @@ pub(crate) fn set_to_started() {
3032

3133
/// Returns whether the service has started or not.
3234
pub(crate) fn condition_for_started() -> bool {
33-
event_db_is_live() && index_db_is_live() && follower_has_first_reached_tip()
35+
let event_db = event_db_is_live();
36+
let index_db = index_db_is_live();
37+
let follower = follower_has_first_reached_tip();
38+
debug!("Checking if service has started. Event DB: {event_db}, Index DB: {index_db}, Follower: {follower}");
39+
event_db && index_db && follower
3440
}
3541

3642
/// Returns whether the Event DB is live or not.

0 commit comments

Comments
 (0)