Skip to content

Commit 63ea9d7

Browse files
committed
graph, store: Add env var GRAPH_STORE_INSERT_EXTRA_COLS
1 parent 9d39c9a commit 63ea9d7

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

docs/environment-variables.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,3 +266,9 @@ those.
266266
- `GRAPH_POSTPONE_ATTRIBUTE_INDEX_CREATION`: During the coping of a subgraph
267267
postponing creation of certain indexes (btree, attribute based ones), would
268268
speed up syncing
269+
- `GRAPH_STORE_INSERT_EXTRA_COLS`: Makes it possible to work around bugs in
270+
the subgraph writing code that manifest as Postgres errors saying 'number
271+
of parameters must be between 0 and 65535' Such errors are always
272+
graph-node bugs, but since it is hard to work around them, setting this
273+
variable to something like 10 makes it possible to work around such a bug
274+
while it is being fixed (default: 0)

graph/src/env/store.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ pub struct EnvVarsStore {
128128
/// sufficiently, probably after 2024-12-01
129129
/// Defaults to `false`, i.e. using the new fixed behavior
130130
pub last_rollup_from_poi: bool,
131+
/// Safety switch to increase the number of columns used when
132+
/// calculating the chunk size in `InsertQuery::chunk_size`. This can be
133+
/// used to work around Postgres errors complaining 'number of
134+
/// parameters must be between 0 and 65535' when inserting entities
135+
pub insert_extra_cols: usize,
131136
}
132137

133138
// This does not print any values avoid accidentally leaking any sensitive env vars
@@ -177,6 +182,7 @@ impl From<InnerStore> for EnvVarsStore {
177182
use_brin_for_all_query_types: x.use_brin_for_all_query_types,
178183
disable_block_cache_for_lookup: x.disable_block_cache_for_lookup,
179184
last_rollup_from_poi: x.last_rollup_from_poi,
185+
insert_extra_cols: x.insert_extra_cols,
180186
}
181187
}
182188
}
@@ -240,6 +246,8 @@ pub struct InnerStore {
240246
disable_block_cache_for_lookup: bool,
241247
#[envconfig(from = "GRAPH_STORE_LAST_ROLLUP_FROM_POI", default = "false")]
242248
last_rollup_from_poi: bool,
249+
#[envconfig(from = "GRAPH_STORE_INSERT_EXTRA_COLS", default = "0")]
250+
insert_extra_cols: usize,
243251
}
244252

245253
#[derive(Clone, Copy, Debug)]

store/postgres/src/relational_queries.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2327,7 +2327,7 @@ impl<'a> InsertQuery<'a> {
23272327
/// into the query
23282328
pub fn chunk_size(table: &Table) -> usize {
23292329
// We always have one column for the block number/range
2330-
let mut count = 1;
2330+
let mut count = 1 + ENV_VARS.store.insert_extra_cols;
23312331
if table.has_causality_region {
23322332
count += 1;
23332333
}

0 commit comments

Comments
 (0)