-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
I think thats all for committer side
alright now we also update checkpoints_hi from committer
- Loading branch information
Showing
12 changed files
with
262 additions
and
4 deletions.
There are no files selected for viewing
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
1 change: 1 addition & 0 deletions
1
crates/sui-indexer/migrations/pg/2024-09-12-213234_watermarks/down.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 @@ | ||
DROP TABLE IF EXISTS watermarks; |
32 changes: 32 additions & 0 deletions
32
crates/sui-indexer/migrations/pg/2024-09-12-213234_watermarks/up.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,32 @@ | ||
CREATE TABLE watermarks | ||
( | ||
-- The table governed by this watermark, i.e `epochs`, `checkpoints`, `transactions`. | ||
entity TEXT NOT NULL, | ||
-- Inclusive upper bound epoch this entity has data for. Committer updates this field. Pruner | ||
-- uses this field for per-entity epoch-level retention, and is mostly useful for pruning | ||
-- unpartitioned tables. | ||
epoch_hi BIGINT NOT NULL, | ||
-- Inclusive lower bound epoch this entity has data for. Pruner updates this field, and uses | ||
-- this field in tandem with `epoch_hi` for per-entity epoch-level retention. This is mostly | ||
-- useful for pruning unpartitioned tables. | ||
epoch_lo BIGINT NOT NULL, | ||
-- Inclusive upper bound checkpoint this entity has data for. Committer updates this field. All | ||
-- data of this entity in the checkpoint must be persisted before advancing this watermark. The | ||
-- committer or ingestion task refers to this on disaster recovery. | ||
checkpoint_hi BIGINT NOT NULL, | ||
-- Inclusive high watermark that the committer advances. For `checkpoints`, this represents the | ||
-- checkpoint sequence number, for `transactions`, the transaction sequence number, etc. | ||
reader_hi BIGINT NOT NULL, | ||
-- Inclusive low watermark that the pruner advances. Data before this watermark is considered | ||
-- pruned by a reader. The underlying data may still exist in the db instance. | ||
reader_lo BIGINT NOT NULL, | ||
-- Updated using the database's current timestamp when the pruner sees that some data needs to | ||
-- be dropped. The pruner uses this column to determine whether to prune or wait long enough | ||
-- that all in-flight reads complete or timeout before it acts on an updated watermark. | ||
timestamp_ms BIGINT NOT NULL, | ||
-- Column used by the pruner to track its true progress. Data at and below this watermark has | ||
-- been truly pruned from the db, and should no longer exist. When recovering from a crash, the | ||
-- pruner will consult this column to determine where to continue. | ||
pruned_lo BIGINT, | ||
PRIMARY KEY (entity) | ||
); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,3 +12,4 @@ pub mod packages; | |
pub mod raw_checkpoints; | ||
pub mod transactions; | ||
pub mod tx_indices; | ||
pub mod watermarks; |
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,49 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use crate::schema::watermarks::{self}; | ||
use diesel::prelude::*; | ||
|
||
/// Represents a row in the `watermarks` table. | ||
#[derive(Queryable, Insertable, Default, QueryableByName)] | ||
#[diesel(table_name = watermarks, primary_key(entity))] | ||
pub struct StoredWatermark { | ||
/// The table name of group of tables governed by this watermark, i.e `epochs`, `checkpoints`, | ||
/// `transactions`. | ||
pub entity: String, | ||
/// Upper bound epoch range to enable per-entity epoch-level retention policy. Committer | ||
/// advances this along with `high`. | ||
pub epoch_hi: i64, | ||
/// Lower bound epoch range to enable per-entity epoch-level retention policy. Pruner advances | ||
/// this. | ||
pub epoch_lo: i64, | ||
pub checkpoint_hi: i64, | ||
/// The inclusive high watermark that the committer advances. | ||
pub reader_hi: i64, | ||
/// The inclusive low watermark that the pruner advances. Data before this watermark is | ||
/// considered pruned. | ||
pub reader_lo: i64, | ||
/// Pruner sets this, and uses this column to determine whether to prune or wait long enough | ||
/// that all in-flight reads complete or timeout before it acts on an updated watermark. | ||
pub timestamp_ms: i64, | ||
/// Pruner updates this, and uses this when recovering from a crash to determine where to | ||
/// continue pruning. Represents the latest watermark pruned, inclusive. | ||
pub pruned_lo: Option<i64>, | ||
} | ||
|
||
impl StoredWatermark { | ||
pub fn from_upper_bound_update( | ||
entity: &str, | ||
epoch_hi: u64, | ||
checkpoint_hi: u64, | ||
reader_hi: u64, | ||
) -> Self { | ||
StoredWatermark { | ||
entity: entity.to_string(), | ||
epoch_hi: epoch_hi as i64, | ||
checkpoint_hi: checkpoint_hi as i64, | ||
reader_hi: reader_hi as i64, | ||
..StoredWatermark::default() | ||
} | ||
} | ||
} |
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.