Skip to content

Commit

Permalink
graph, store: Add a temporary way to revert to old behavior for paren…
Browse files Browse the repository at this point in the history
…t ids
  • Loading branch information
lutter committed Apr 25, 2022
1 parent ec14ab8 commit 60cd12c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
8 changes: 8 additions & 0 deletions graph/src/env/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ pub struct EnvVarsStore {
/// Setting this to `0` disables pipelined writes, and writes will be
/// done synchronously.
pub write_queue_size: usize,

/// This is just in case new behavior causes issues. This can be removed
/// once the new behavior has run in the hosted service for a few days
/// without issues.
pub disable_error_for_toplevel_parents: bool,
}

// This does not print any values avoid accidentally leaking any sensitive env vars
Expand Down Expand Up @@ -139,6 +144,7 @@ impl From<InnerStore> for EnvVarsStore {
connection_min_idle: x.connection_min_idle,
connection_idle_timeout: Duration::from_secs(x.connection_idle_timeout_in_secs),
write_queue_size: x.write_queue_size,
disable_error_for_toplevel_parents: x.disable_error_for_toplevel_parents.0,
}
}
}
Expand Down Expand Up @@ -184,4 +190,6 @@ pub struct InnerStore {
connection_idle_timeout_in_secs: u64,
#[envconfig(from = "GRAPH_STORE_WRITE_QUEUE", default = "5")]
write_queue_size: usize,
#[envconfig(from = "GRAPH_DISABLE_ERROR_FOR_TOPLEVEL_PARENTS", default = "false")]
disable_error_for_toplevel_parents: EnvVarBoolean,
}
22 changes: 16 additions & 6 deletions store/postgres/src/relational_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,12 +476,22 @@ impl EntityData {
if key == "g$parent_id" {
match &parent_type {
None => {
// A query that does not have parents
// somehow returned parent ids. We have no
// idea how to deserialize that
return Err(graph::constraint_violation!(
"query unexpectedly produces parent ids"
));
if ENV_VARS.store.disable_error_for_toplevel_parents {
// Only temporarily in case reporting an
// error causes unexpected trouble. Can
// be removed once it's been working for
// a few days
let value =
T::Value::from_column_value(&ColumnType::String, json)?;
out.insert_entity_data("g$parent_id".to_owned(), value);
} else {
// A query that does not have parents
// somehow returned parent ids. We have no
// idea how to deserialize that
return Err(graph::constraint_violation!(
"query unexpectedly produces parent ids"
));
}
}
Some(parent_type) => {
let value = T::Value::from_column_value(parent_type, json)?;
Expand Down

0 comments on commit 60cd12c

Please sign in to comment.