Skip to content

Commit 037f9bf

Browse files
craig[bot]miraradevaiskettanehspilchen
committed
138834: kvserver,storeliveness: introduce follower quiescence r=arulajmani,iskettaneh a=miraradeva This commit introduces the ability for followers on inactive ranges to quiesce and stop ticking in Raft. This will allow the CPU utilization of the cluster to decrease by a factor of 2/3 (assuming RF3). Unlike epoch lease quiescence, which also quiesces the leader under certain conditions, store liveness quiescence is much simpler. The conditions to quiesce/unquiesce are: - Quiesce a follower if it hasn't received Raft messages in a certain number of ticks and the follower's store provides store liveness support for the leader's store. - Unquiesce a follower if it hears from store liveness that the follower's store has withdrawn support from the leader's store. Fixes: #133885 Release note: None 140960: sql: deflake TestDropDatabaseDeleteData r=iskettaneh a=iskettaneh This commit deflakes the test by blocking the full reconciliation from starting before we drop the database. This is used to avoid a race condition where the full reconciliation starts after we drop the database, it will ignore the dropped database. Then, there is a race between the SQLWatcher and the GC job where the SQLWatcher might write a zone config of table1 before table2, while the GC queue might not know that this range needs to be split because it has different span config. Release note: None Fixes: #138185 140995: sql: Fix trigger dependency cleanup in legacy schema changer r=spilchen a=spilchen In the legacy schema changer for DROP TABLE, there was special logic to clean up dependencies created by triggers. However, a bug in this logic caused the dependent table’s descriptor to remain unchanged, leaving behind a dangling reference. This commit ensures that the dependent table’s descriptor is correctly updated. Epic: none informs https://github.com/cockroachlabs/support/issues/3174 Release note (bug fix): Fixed a bug where dropping a table with a trigger using the legacy schema changer could leave an orphaned reference in the descriptor. This occurred when two tables were dependent on each other via a trigger, and the table containing the trigger was dropped. Co-authored-by: Mira Radeva <[email protected]> Co-authored-by: Ibrahim Kettaneh <[email protected]> Co-authored-by: Matt Spilchen <[email protected]>
4 parents 04da695 + 18981d3 + c47ef3a + c6a6112 commit 037f9bf

28 files changed

+914
-449
lines changed

docs/generated/metrics/metrics.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@
620620
<tr><td>STORAGE</td><td>rebalancing.writebytespersecond</td><td>Number of bytes written recently per second, considering the last 30 minutes.</td><td>Bytes/Sec</td><td>GAUGE</td><td>BYTES</td><td>AVG</td><td>NONE</td></tr>
621621
<tr><td>STORAGE</td><td>rebalancing.writespersecond</td><td>Number of keys written (i.e. applied by raft) per second to the store, considering the last 30 minutes.</td><td>Keys/Sec</td><td>GAUGE</td><td>COUNT</td><td>AVG</td><td>NONE</td></tr>
622622
<tr><td>STORAGE</td><td>replicas</td><td>Number of replicas</td><td>Replicas</td><td>GAUGE</td><td>COUNT</td><td>AVG</td><td>NONE</td></tr>
623+
<tr><td>STORAGE</td><td>replicas.asleep</td><td>Number of asleep replicas. Similarly to quiesced replicas, asleep replicas do not tick in Raft.</td><td>Replicas</td><td>GAUGE</td><td>COUNT</td><td>AVG</td><td>NONE</td></tr>
623624
<tr><td>STORAGE</td><td>replicas.leaders</td><td>Number of raft leaders</td><td>Raft Leaders</td><td>GAUGE</td><td>COUNT</td><td>AVG</td><td>NONE</td></tr>
624625
<tr><td>STORAGE</td><td>replicas.leaders_invalid_lease</td><td>Number of replicas that are Raft leaders whose lease is invalid</td><td>Replicas</td><td>GAUGE</td><td>COUNT</td><td>AVG</td><td>NONE</td></tr>
625626
<tr><td>STORAGE</td><td>replicas.leaders_not_fortified</td><td>Number of replicas that are not fortified Raft leaders</td><td>Replicas</td><td>GAUGE</td><td>COUNT</td><td>AVG</td><td>NONE</td></tr>
@@ -844,6 +845,7 @@
844845
<tr><td>STORAGE</td><td>storage.write-amplification</td><td>Running measure of write-amplification.<br/><br/>Write amplification is measured as the ratio of bytes written to disk relative to the logical<br/>bytes present in sstables, over the life of a store. This metric is a running average<br/>of the write amplification as tracked by Pebble.</td><td>Ratio of bytes written to logical bytes</td><td>GAUGE</td><td>COUNT</td><td>AVG</td><td>NONE</td></tr>
845846
<tr><td>STORAGE</td><td>storage.write-stall-nanos</td><td>Total write stall duration in nanos</td><td>Nanoseconds</td><td>GAUGE</td><td>NANOSECONDS</td><td>AVG</td><td>NONE</td></tr>
846847
<tr><td>STORAGE</td><td>storage.write-stalls</td><td>Number of instances of intentional write stalls to backpressure incoming writes</td><td>Events</td><td>GAUGE</td><td>COUNT</td><td>AVG</td><td>NONE</td></tr>
848+
<tr><td>STORAGE</td><td>storeliveness.callbacks.processing_duration</td><td>Duration of support withdrawal callback processing</td><td>Duration</td><td>HISTOGRAM</td><td>NANOSECONDS</td><td>AVG</td><td>NONE</td></tr>
847849
<tr><td>STORAGE</td><td>storeliveness.heartbeat.failures</td><td>Number of Store Liveness heartbeats that failed to be sent out by the Store Liveness Support Manager</td><td>Heartbeats</td><td>COUNTER</td><td>COUNT</td><td>AVG</td><td>NON_NEGATIVE_DERIVATIVE</td></tr>
848850
<tr><td>STORAGE</td><td>storeliveness.heartbeat.successes</td><td>Number of Store Liveness heartbeats sent out by the Store Liveness Support Manager</td><td>Heartbeats</td><td>COUNTER</td><td>COUNT</td><td>AVG</td><td>NON_NEGATIVE_DERIVATIVE</td></tr>
849851
<tr><td>STORAGE</td><td>storeliveness.message_handle.failures</td><td>Number of incoming Store Liveness messages that failed to be handled by the Store Liveness Support Manager</td><td>Messages</td><td>COUNTER</td><td>COUNT</td><td>AVG</td><td>NON_NEGATIVE_DERIVATIVE</td></tr>

pkg/ccl/logictestccl/testdata/logic_test/triggers

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4030,4 +4030,54 @@ drop_trigger
40304030
statement ok
40314031
CREATE OR REPLACE FUNCTION f() RETURNS TRIGGER LANGUAGE PLpgSQL AS $$ BEGIN RETURN NEW; END $$;
40324032

4033+
# ==============================================================================
4034+
# Test that descriptor backreferences are cleaned up
4035+
# ==============================================================================
4036+
4037+
subtest ensure_back_ref_cleanup
4038+
4039+
statement ok
4040+
create table listings_balance (c1 int);
4041+
4042+
# Create a function that references listings_balance
4043+
statement ok
4044+
create or replace function update_listing_balance()
4045+
returns TRIGGER language PLpgSQL AS
4046+
$$
4047+
BEGIN
4048+
INSERT INTO listings_balance VALUES (1);
4049+
RETURN NEW;
4050+
END
4051+
$$;
4052+
4053+
statement ok
4054+
CREATE TABLE transaction_entries (c1 int);
4055+
4056+
# Create a trigger that references listings_balance through the trigger function.
4057+
statement ok
4058+
create trigger tr AFTER INSERT OR UPDATE ON transaction_entries FOR EACH ROW execute function update_listing_balance();
4059+
4060+
# Force the legacy schema change for the drop table. We will save the original
4061+
# DSC setting so that it be reset properly.
4062+
let $use_decl_sc
4063+
SHOW use_declarative_schema_changer
4064+
4065+
statement ok
4066+
SET use_declarative_schema_changer = off;
4067+
4068+
# This should cleanup the dependency in listings_balance.
4069+
statement ok
4070+
DROP TABLE transaction_entries;
4071+
4072+
# Reinstate original DSC setting
4073+
statement ok
4074+
SET use_declarative_schema_changer = $use_decl_sc;
4075+
4076+
statement ok
4077+
DROP FUNCTION update_listing_balance ;
4078+
4079+
# Sanity to verify the dependency no longer exists.
4080+
statement ok
4081+
drop table listings_balance cascade;
4082+
40334083
subtest end

pkg/kv/kvserver/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ go_library(
7878
"replica_split_load.go",
7979
"replica_sst_snapshot_storage.go",
8080
"replica_store_liveness.go",
81+
"replica_store_liveness_sleep.go",
8182
"replica_tscache.go",
8283
"replica_write.go",
8384
"replicate_queue.go",

0 commit comments

Comments
 (0)