Skip to content

Commit

Permalink
graph, store: Add env var GRAPH_STORE_INSERT_EXTRA_COLS
Browse files Browse the repository at this point in the history
  • Loading branch information
lutter committed Feb 3, 2025
1 parent 9d39c9a commit 63ea9d7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions docs/environment-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,9 @@ those.
- `GRAPH_POSTPONE_ATTRIBUTE_INDEX_CREATION`: During the coping of a subgraph
postponing creation of certain indexes (btree, attribute based ones), would
speed up syncing
- `GRAPH_STORE_INSERT_EXTRA_COLS`: Makes it possible to work around bugs in
the subgraph writing code that manifest as Postgres errors saying 'number
of parameters must be between 0 and 65535' Such errors are always
graph-node bugs, but since it is hard to work around them, setting this
variable to something like 10 makes it possible to work around such a bug
while it is being fixed (default: 0)
8 changes: 8 additions & 0 deletions graph/src/env/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ pub struct EnvVarsStore {
/// sufficiently, probably after 2024-12-01
/// Defaults to `false`, i.e. using the new fixed behavior
pub last_rollup_from_poi: bool,
/// Safety switch to increase the number of columns used when
/// calculating the chunk size in `InsertQuery::chunk_size`. This can be
/// used to work around Postgres errors complaining 'number of
/// parameters must be between 0 and 65535' when inserting entities
pub insert_extra_cols: usize,
}

// This does not print any values avoid accidentally leaking any sensitive env vars
Expand Down Expand Up @@ -177,6 +182,7 @@ impl From<InnerStore> for EnvVarsStore {
use_brin_for_all_query_types: x.use_brin_for_all_query_types,
disable_block_cache_for_lookup: x.disable_block_cache_for_lookup,
last_rollup_from_poi: x.last_rollup_from_poi,
insert_extra_cols: x.insert_extra_cols,
}
}
}
Expand Down Expand Up @@ -240,6 +246,8 @@ pub struct InnerStore {
disable_block_cache_for_lookup: bool,
#[envconfig(from = "GRAPH_STORE_LAST_ROLLUP_FROM_POI", default = "false")]
last_rollup_from_poi: bool,
#[envconfig(from = "GRAPH_STORE_INSERT_EXTRA_COLS", default = "0")]
insert_extra_cols: usize,
}

#[derive(Clone, Copy, Debug)]
Expand Down
2 changes: 1 addition & 1 deletion store/postgres/src/relational_queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2327,7 +2327,7 @@ impl<'a> InsertQuery<'a> {
/// into the query
pub fn chunk_size(table: &Table) -> usize {
// We always have one column for the block number/range
let mut count = 1;
let mut count = 1 + ENV_VARS.store.insert_extra_cols;
if table.has_causality_region {
count += 1;
}
Expand Down

0 comments on commit 63ea9d7

Please sign in to comment.