-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
94992: backupccl: do not backup or restore stat forecasts r=michae2 a=stevendanna Statistics forecasts are not persisted and are reconstructed on demand from the persisted statistics. As such, they don't need to be included in a backup or restored. This has the additional effect of solving a bug in which we would fail to write statistics into our metadata SST if it included more than 1 forecast since the in-memory forecasts have a 0 statistic_id. Fixes #86806 Epic: none Release note: None Co-authored-by: Steven Danna <[email protected]>
- Loading branch information
Showing
4 changed files
with
139 additions
and
43 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
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 |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# This test that we don't back up forecasts or merged statistics. | ||
# | ||
# This also serves as a regression test for #86806 -- a bug in which 2 | ||
# or more forecsts would break metadata SST writing. | ||
new-cluster name=s | ||
---- | ||
|
||
exec-sql | ||
SET CLUSTER SETTING kv.bulkio.write_metadata_sst.enabled = true; | ||
---- | ||
|
||
# Automatic collection is disabled to avoid flakiness. | ||
exec-sql | ||
SET CLUSTER SETTING sql.stats.automatic_collection.enabled = false; | ||
---- | ||
|
||
exec-sql | ||
CREATE DATABASE db1; | ||
USE db1; | ||
CREATE TABLE tab (a INT PRIMARY KEY, b INT); | ||
INSERT INTO tab VALUES (1, 1), (2, 2), (100, 100); | ||
---- | ||
|
||
# We create 3 statistics manually which is the minimum needed to | ||
# create a forecast and a partial statistic on column A so that a | ||
# merged statistics is also generated. | ||
exec-sql | ||
CREATE STATISTICS __auto__ ON a FROM tab; | ||
CREATE STATISTICS __auto__ ON b FROM tab; | ||
CREATE STATISTICS __auto__ ON a FROM tab; | ||
CREATE STATISTICS __auto__ ON b FROM tab; | ||
CREATE STATISTICS __auto__ ON a FROM tab; | ||
CREATE STATISTICS __auto__ ON b FROM tab; | ||
CREATE STATISTICS partial ON a FROM tab USING EXTREMES; | ||
---- | ||
|
||
query-sql | ||
SELECT count(1) FROM [ SHOW STATISTICS FOR TABLE tab ] | ||
---- | ||
7 | ||
|
||
query-sql | ||
SELECT count(1) FROM [ SHOW STATISTICS FOR TABLE tab WITH FORECAST ] WHERE statistics_name = '__forecast__' | ||
---- | ||
2 | ||
|
||
query-sql | ||
SELECT count(1) FROM [ SHOW STATISTICS FOR TABLE tab WITH MERGE ] WHERE statistics_name = '__merged__' | ||
---- | ||
1 | ||
|
||
exec-sql | ||
BACKUP DATABASE db1 INTO 'nodelocal://0/test/' | ||
---- | ||
|
||
# TODO(ssd): The expectation here is 6 stats rather than 7 because the | ||
# 'partial' stat is not backed up even though it is persisted. I think | ||
# we may want a different API for fetching statistics. | ||
query-sql | ||
SELECT | ||
json_array_length( | ||
crdb_internal.pb_to_json( | ||
'cockroach.ccl.backupccl.StatsTable', | ||
crdb_internal.read_file( | ||
concat( | ||
'nodelocal://0/test/', | ||
(SELECT PATH FROM [SHOW BACKUPS IN 'nodelocal://0/test/']), | ||
'/BACKUP-STATISTICS' | ||
) | ||
) | ||
) | ||
-> 'statistics' | ||
) | ||
---- | ||
6 |