Skip to content

Commit fb0aca5

Browse files
committed
store: Improve comments for pruning, rename 'copy' to 'rebuild' internally
1 parent 017671c commit fb0aca5

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

store/postgres/src/relational/prune.rs

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -345,30 +345,29 @@ impl Layout {
345345

346346
/// Remove all data from the underlying deployment that is not needed to
347347
/// respond to queries before block `earliest_block`. The `req` is used
348-
/// to determine which strategy should be used for pruning, copy or
348+
/// to determine which strategy should be used for pruning, rebuild or
349349
/// delete.
350350
///
351351
/// Blocks before `req.final_block` are considered final and it is
352352
/// assumed that they will not be modified in any way while pruning is
353353
/// running.
354354
///
355-
/// The copy strategy implemented here works well for situations in
355+
/// The rebuild strategy implemented here works well for situations in
356356
/// which pruning will remove a large amount of data from the subgraph
357357
/// (say, at least 50%)
358358
///
359-
/// The strategy for `prune_by_copying` is to copy all data that is
360-
/// needed to respond to queries at block heights at or after
361-
/// `earliest_block` to a new table and then to replace the existing
362-
/// tables with these new tables atomically in a transaction. Copying
363-
/// happens in two stages that are performed for each table in turn: we
364-
/// first copy data for final blocks without blocking writes, and then
365-
/// copy data for nonfinal blocks. The latter blocks writes by taking a
366-
/// lock on the row for the deployment in `subgraph_deployment` (via
367-
/// `deployment::lock`) The process for switching to the new tables
368-
/// needs to take the naming of various database objects that Postgres
369-
/// creates automatically into account so that they all have the same
370-
/// names as the original objects to ensure that pruning can be done
371-
/// again without risking name clashes.
359+
/// The strategy for rebuilding is to copy all data that is needed to
360+
/// respond to queries at block heights at or after `earliest_block` to
361+
/// a new table and then to replace the existing tables with these new
362+
/// tables atomically in a transaction. Rebuilding happens in two stages
363+
/// that are performed for each table in turn: we first copy data for
364+
/// final blocks without blocking writes, and then copy data for
365+
/// nonfinal blocks. The latter blocks writes by taking an advisory lock
366+
/// on the deployment (via `deployment::lock`) The process for switching
367+
/// to the new tables needs to take the naming of various database
368+
/// objects that Postgres creates automatically into account so that
369+
/// they all have the same names as the original objects to ensure that
370+
/// pruning can be done again without risking name clashes.
372371
///
373372
/// The reason this strategy works well when a lot (or even the
374373
/// majority) of the data needs to be removed is that in the more
@@ -380,8 +379,8 @@ impl Layout {
380379
/// tables. But a full vacuum takes an `access exclusive` lock which
381380
/// prevents both reads and writes to the table, which means it would
382381
/// also block queries to the deployment, often for extended periods of
383-
/// time. The `prune_by_copying` strategy never blocks reads, it only
384-
/// ever blocks writes.
382+
/// time. The rebuild strategy never blocks reads, it only ever blocks
383+
/// writes.
385384
pub fn prune(
386385
&self,
387386
logger: &Logger,

0 commit comments

Comments
 (0)