Skip to content

Commit 90ce7e3

Browse files
committed
store: Exit with an error if the notification listener loses its connection
Events we listen for are important for the overall correctness of the system; for example, if we miss the assignment event for a subgraph, we will not index it, leaving the user to scratch their head why a newly deployed subgraph is not making progress. Because of this, the safest and most robust thing is to immediately exit the process (with an error) if a notification listener ever loses its db connection. A process supervisor should be used to restart the process as is appropriate for the environment we are running in. Fixes #1279
1 parent 5024a3c commit 90ce7e3

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

store/postgres/src/notification_listener.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,12 +138,14 @@ impl NotificationListener {
138138
.filter_map(|item| match item {
139139
Ok(msg) => Some(msg),
140140
Err(e) => {
141-
warn!(
142-
logger,
143-
"Error receiving message";
144-
"error" => format!("{}", e)
141+
let msg = format!("{}", e);
142+
crit!(logger, "Error receiving message"; "error" => &msg);
143+
eprintln!(
144+
"Connection to Postgres lost while listening for events. \
145+
Aborting to avoid inconsistent state. ({})",
146+
msg
145147
);
146-
None
148+
std::process::exit(1);
147149
}
148150
})
149151
.filter(|notification| notification.channel == channel_name.0)

0 commit comments

Comments
 (0)