-
Notifications
You must be signed in to change notification settings - Fork 86
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reduce risk of losing data due to garbage collection or restarts (#2252)
* Make persistence garbage collection more conservative. Previously, we would delete all data from consensus storage up to the decided view, with each new decide. In the case where we miss a decide event, this can cause us to delete the associated data (e.g. DA, VID proposals) from a view that we never actually moved to archival storage. This in turn makes it much harder to use any guarantees from consensus about certain nodes posessing certain data after a decide, because we are garbage collecting such data. One particularly bad case is about DA nodes. Consensus guarantees that some honest DA nodes will see every DA proposal. However, if those nodes all restart at the same time shortly after seeing a DA proposal, they may miss the corresonding quorum proposal and decide. Then, when they restart, they may end up garbage collecting that DA proposal before anyone realizes that it did get decided, and now no one has the data. The new technique is more conservative. We only garbage collect specific views or ranges of views for which we know we have successfully processed all decide events. Other data, whether it is for views that never decided or for views where we missed a decide (we cannot immediately tell the difference) will be retained indefinitely. This ensures we never lose data before it is archived, and allows us to manually rebuild an incomplete archive after it is discovered. It also enables us to implement a catchup data source that pulls from this store of undecided, un-garbage-collected data, so that the archive can automatically rebuild itself. Of course, indefinitely retaining data which may not even have been decided is undesirable. The next commit will add pruning, so that all data is deleted after a certain number of views, even if we never archived it. Then the guarantee will be: we can always recover a complete archive, based on the guarantees of consensus, as long as recover completes within a certain (configurable) time period. * Implement pruning for old, undecided consensus data * Implement provider traits for consensus persistence * Regression test for deadlock * Use consensus storage as fetching provider when running query service * Remove dyn-clone, which is no longer necessary * Bump query service * Better configurability for consensus storage GC Add target, minimum retentions and target usage, like the archival pruner. This allows us to take full advantage of the storage space if we have it, keeping data around for longer, while still ensuring we keep it around long *enough* even if we are low on space. * Log return value of background tasks * Update lock file * Tag query service * Update lock file
- Loading branch information
Showing
17 changed files
with
1,369 additions
and
283 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
sequencer/api/migrations/postgres/V401__archive_provider.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-- Add information needed for consensus storage to act as a provider for archive recovery. | ||
|
||
-- Add payload hash to DA proposal, since the query service requests missing payloads by hash. | ||
ALTER TABLE da_proposal | ||
ADD COLUMN payload_hash VARCHAR; | ||
CREATE INDEX da_proposal_payload_hash_idx ON da_proposal (payload_hash); | ||
|
||
-- Add payload hash to VID share, since the query service requests missing VID common by payload | ||
-- hash. | ||
ALTER TABLE vid_share | ||
ADD COLUMN payload_hash VARCHAR; | ||
CREATE INDEX vid_share_payload_hash_idx ON vid_share (payload_hash); | ||
|
||
-- Add QC storage, since the query service requires missing leaves to be fetched alongside a QC with | ||
-- that leaf hash. | ||
CREATE TABLE quorum_certificate ( | ||
view BIGINT PRIMARY KEY, | ||
leaf_hash VARCHAR NOT NULL, | ||
data BYTEA NOT NULL | ||
); | ||
CREATE INDEX quorum_certificate_leaf_hash_idx ON quorum_certificate (leaf_hash); |
21 changes: 21 additions & 0 deletions
21
sequencer/api/migrations/sqlite/V201__archive_provider.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
-- Add information needed for consensus storage to act as a provider for archive recovery. | ||
|
||
-- Add payload hash to DA proposal, since the query service requests missing payloads by hash. | ||
ALTER TABLE da_proposal | ||
ADD COLUMN payload_hash VARCHAR; | ||
CREATE INDEX da_proposal_payload_hash_idx ON da_proposal (payload_hash); | ||
|
||
-- Add payload hash to VID share, since the query service requests missing VID common by payload | ||
-- hash. | ||
ALTER TABLE vid_share | ||
ADD COLUMN payload_hash VARCHAR; | ||
CREATE INDEX vid_share_payload_hash_idx ON vid_share (payload_hash); | ||
|
||
-- Add QC storage, since the query service requires missing leaves to be fetched alongside a QC with | ||
-- that leaf hash. | ||
CREATE TABLE quorum_certificate ( | ||
view BIGINT PRIMARY KEY, | ||
leaf_hash VARCHAR NOT NULL, | ||
data BLOB NOT NULL | ||
); | ||
CREATE INDEX quorum_certificate_leaf_hash_idx ON quorum_certificate (leaf_hash); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.