Skip to content

Commit

Permalink
kv: Add established column to active_range_feeds table.
Browse files Browse the repository at this point in the history
Add `established` column to `active_range_feeds` table.
This column is initialized to the time when the partial range feed
was established.  This allows us to determine, among other things,
whether or not the rangefeed is currently performing a catchup scan
(i.e. it's resolved column is 0), and how long the scan has been running
for.

Release Notes (enterprise): Add established time column
to `crdb_internal.active_range_feeds` virtual table to improve observability
and debugability of rangefeed system.

Release Justification: Low impact observability/debugability improvement.
  • Loading branch information
Yevgeniy Miretskiy committed Mar 10, 2022
1 parent 7fe21a3 commit 3ebd5b9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/kv/kvclient/kvcoord/dist_sender_rangefeed.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ type PartialRangeFeed struct {
StartTS hlc.Timestamp
NodeID roachpb.NodeID
RangeID roachpb.RangeID
EstablishedTime time.Time
LastValueReceived time.Time
Resolved hlc.Timestamp
}
Expand Down Expand Up @@ -262,8 +263,9 @@ func (ds *DistSender) partialRangeFeed(
// Register partial range feed with registry.
active := &activeRangeFeed{
PartialRangeFeed: PartialRangeFeed{
Span: span,
StartTS: startFrom,
Span: span,
StartTS: startFrom,
EstablishedTime: timeutil.Now(),
},
}
rr.ranges.Store(active, nil)
Expand Down
2 changes: 2 additions & 0 deletions pkg/sql/crdb_internal.go
Original file line number Diff line number Diff line change
Expand Up @@ -5248,6 +5248,7 @@ CREATE TABLE crdb_internal.active_range_feeds (
diff BOOL,
node_id INT,
range_id INT,
established INT,
range_start STRING,
range_end STRING,
resolved STRING,
Expand All @@ -5270,6 +5271,7 @@ CREATE TABLE crdb_internal.active_range_feeds (
tree.MakeDBool(tree.DBool(rfCtx.WithDiff)),
tree.NewDInt(tree.DInt(rf.NodeID)),
tree.NewDInt(tree.DInt(rf.RangeID)),
tree.NewDInt(tree.DInt(rf.EstablishedTime.UTC().UnixNano())),
tree.NewDString(keys.PrettyPrint(nil /* valDirs */, rf.Span.Key)),
tree.NewDString(keys.PrettyPrint(nil /* valDirs */, rf.Span.EndKey)),
tree.NewDString(rf.Resolved.AsOfSystemTime()),
Expand Down
2 changes: 2 additions & 0 deletions pkg/sql/logictest/testdata/logic_test/create_statements
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ CREATE TABLE crdb_internal.active_range_feeds (
diff BOOL NULL,
node_id INT8 NULL,
range_id INT8 NULL,
established INT8 NULL,
range_start STRING NULL,
range_end STRING NULL,
resolved STRING NULL,
Expand All @@ -50,6 +51,7 @@ CREATE TABLE crdb_internal.active_range_feeds (
diff BOOL NULL,
node_id INT8 NULL,
range_id INT8 NULL,
established INT8 NULL,
range_start STRING NULL,
range_end STRING NULL,
resolved STRING NULL,
Expand Down

0 comments on commit 3ebd5b9

Please sign in to comment.