Skip to content

Commit

Permalink
[mysql-5.6][PR] add ability to track per-database applied hlc
Browse files Browse the repository at this point in the history
Summary:
Adds the ability in HybridLogicalClock to maintain per-database applied HLC. The
feature is guarded by a new sysvar 'maintain_database_hlc'.

The database name is extracted from all Table_map_log_event or Query_log_event
in a trx and stored as a set in THD. This gives a list of all databases touched
by this trx. After engine commit, the HLC of the trx is updated as
'applied_hlc' for every database touched by the trx.

We track the per-database applied_hlc as a map (with the key as the database
name and value as applied hlc) per instance.

Per-database applied HLC is exposed as a information schema table
'database_applied_hlc'. On querying this table, we get the map of per-database
applied hlc and populate the result set.

Reference Patch: b90a327

8.0 porting notes:
* 'sys_vars.maintain_database_hlc_basic' MTR test case expanded and
   unified.

Pull Request resolved: #1113
GitHub Author: Vinaykumar Bhat <[email protected]>

Test Plan: Imported from GitHub, without a `Test Plan:` line.

Reviewers: abhinavsharma, luqun, mung, yzha

Reviewed By: luqun

Subscribers: jprahman, zhichengzhu, ritwikyadav, vinaybhat, [email protected]

Differential Revision: https://phabricator.intern.facebook.com/D20131111

Tags: accept2ship, sentinelized

Signature: 20131111:1585091874:333510a653ba487916102f82a7a0bdb25a4b3ffa
  • Loading branch information
bhatvinay authored and Herman Lee committed Mar 26, 2020
1 parent 689407d commit e734faa
Show file tree
Hide file tree
Showing 35 changed files with 1,389 additions and 7 deletions.
1 change: 1 addition & 0 deletions mysql-test/r/dd_is_compatibility_ci.result
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ COLLATION_CHARACTER_SET_APPLICABILITY
COLUMNS
COLUMN_PRIVILEGES
COLUMN_STATISTICS
DATABASE_APPLIED_HLC
ENGINES
EVENTS
FILES
Expand Down
1 change: 1 addition & 0 deletions mysql-test/r/dd_is_compatibility_cs.result
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ COLLATION_CHARACTER_SET_APPLICABILITY
COLUMNS
COLUMN_PRIVILEGES
COLUMN_STATISTICS
DATABASE_APPLIED_HLC
ENGINES
EVENTS
FILES
Expand Down
5 changes: 4 additions & 1 deletion mysql-test/r/information_schema_ci.result
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ COLLATION_CHARACTER_SET_APPLICABILITY
COLUMNS
COLUMN_PRIVILEGES
COLUMN_STATISTICS
DATABASE_APPLIED_HLC
ENGINES
EVENTS
FILES
Expand Down Expand Up @@ -867,7 +868,7 @@ table_schema IN ('mysql', 'information_schema', 'test', 'mysqltest')
AND table_name not like 'ndb%' AND table_name COLLATE utf8_general_ci not like 'innodb_%'
GROUP BY TABLE_SCHEMA;
TABLE_SCHEMA count(*)
information_schema 41
information_schema 43
mysql 31
create table t1 (i int, j int);
create trigger trg1 before insert on t1 for each row
Expand Down Expand Up @@ -2440,6 +2441,7 @@ COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
COLUMNS TABLE_SCHEMA
COLUMN_PRIVILEGES TABLE_SCHEMA
COLUMN_STATISTICS SCHEMA_NAME
DATABASE_APPLIED_HLC DATABASE_NAME
ENGINES ENGINE
EVENTS EVENT_SCHEMA
FILES TABLE_SCHEMA
Expand Down Expand Up @@ -2500,6 +2502,7 @@ COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
COLUMNS TABLE_SCHEMA
COLUMN_PRIVILEGES TABLE_SCHEMA
COLUMN_STATISTICS SCHEMA_NAME
DATABASE_APPLIED_HLC DATABASE_NAME
ENGINES ENGINE
EVENTS EVENT_SCHEMA
FILES TABLE_SCHEMA
Expand Down
5 changes: 4 additions & 1 deletion mysql-test/r/information_schema_cs.result
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ COLLATION_CHARACTER_SET_APPLICABILITY
COLUMNS
COLUMN_PRIVILEGES
COLUMN_STATISTICS
DATABASE_APPLIED_HLC
ENGINES
EVENTS
FILES
Expand Down Expand Up @@ -876,7 +877,7 @@ AND table_name COLLATE utf8_general_ci not like 'innodb_%'
AND table_name COLLATE utf8_general_ci not like 'rocksdb_%'
GROUP BY TABLE_SCHEMA;
TABLE_SCHEMA count(*)
information_schema 42
information_schema 43
mysql 31
create table t1 (i int, j int);
create trigger trg1 before insert on t1 for each row
Expand Down Expand Up @@ -2451,6 +2452,7 @@ COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
COLUMNS TABLE_SCHEMA
COLUMN_PRIVILEGES TABLE_SCHEMA
COLUMN_STATISTICS SCHEMA_NAME
DATABASE_APPLIED_HLC DATABASE_NAME
ENGINES ENGINE
EVENTS EVENT_SCHEMA
FILES TABLE_SCHEMA
Expand Down Expand Up @@ -2513,6 +2515,7 @@ COLLATION_CHARACTER_SET_APPLICABILITY COLLATION_NAME
COLUMNS TABLE_SCHEMA
COLUMN_PRIVILEGES TABLE_SCHEMA
COLUMN_STATISTICS SCHEMA_NAME
DATABASE_APPLIED_HLC DATABASE_NAME
ENGINES ENGINE
EVENTS EVENT_SCHEMA
FILES TABLE_SCHEMA
Expand Down
1 change: 1 addition & 0 deletions mysql-test/r/information_schema_db.result
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ COLLATION_CHARACTER_SET_APPLICABILITY
COLUMNS
COLUMN_PRIVILEGES
COLUMN_STATISTICS
DATABASE_APPLIED_HLC
ENGINES
EVENTS
FILES
Expand Down
3 changes: 3 additions & 0 deletions mysql-test/r/mysqld--help-notwin.result
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,8 @@ The following options may be given as the first argument:
--lz4f-net-compression-level[=#]
Compression level for compressed protocol when lz4f
library is selected.
--maintain-database-hlc
Enable maintaining of max HLC applied per database
--mandatory-roles=name
All the specified roles are always considered granted to
every user and they can't be revoked. Mandatory roles
Expand Down Expand Up @@ -2327,6 +2329,7 @@ long-query-time 10
low-priority-updates FALSE
lower-case-table-names 1
lz4f-net-compression-level 0
maintain-database-hlc FALSE
mandatory-roles
master-info-file master.info
master-info-repository TABLE
Expand Down
3 changes: 3 additions & 0 deletions mysql-test/r/mysqld--help-win.result
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,8 @@ The following options may be given as the first argument:
If set to 1 table names are stored in lowercase on disk
and table names will be case-insensitive. Should be set
to 2 if you are using a case insensitive file system
--maintain-database-hlc
Enable maintaining of max HLC applied per database
--mandatory-roles=name
All the specified roles are always considered granted to
every user and they can't be revoked. Mandatory roles
Expand Down Expand Up @@ -1547,6 +1549,7 @@ log-timestamps UTC
long-query-time 10
low-priority-updates FALSE
lower-case-table-names 1
maintain-database-hlc FALSE
mandatory-roles
master-info-file master.info
master-info-repository TABLE
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/r/mysqlshow_ci.result
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Database: information_schema
| COLUMN_PRIVILEGES |
| COLUMN_STATISTICS |
| COLUMNS |
| DATABASE_APPLIED_HLC |
| ENGINES |
| EVENTS |
| FILES |
Expand Down Expand Up @@ -164,6 +165,7 @@ Database: INFORMATION_SCHEMA
| COLUMN_PRIVILEGES |
| COLUMN_STATISTICS |
| COLUMNS |
| DATABASE_APPLIED_HLC |
| ENGINES |
| EVENTS |
| FILES |
Expand Down
2 changes: 2 additions & 0 deletions mysql-test/r/mysqlshow_cs.result
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ Database: information_schema
| COLUMNS |
| COLUMN_PRIVILEGES |
| COLUMN_STATISTICS |
| DATABASE_APPLIED_HLC |
| ENGINES |
| EVENTS |
| FILES |
Expand Down Expand Up @@ -179,6 +180,7 @@ Database: INFORMATION_SCHEMA
| COLUMNS |
| COLUMN_PRIVILEGES |
| COLUMN_STATISTICS |
| DATABASE_APPLIED_HLC |
| ENGINES |
| EVENTS |
| FILES |
Expand Down
4 changes: 4 additions & 0 deletions mysql-test/suite/funcs_1/r/is_columns_is_ci.result
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def information_schema COLUMN_STATISTICS SCHEMA_NAME 1 NULL NO varchar 64 192 NU
def information_schema COLUMN_STATISTICS TABLE_NAME 2 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) select NULL
def information_schema COLUMN_STATISTICS COLUMN_NAME 3 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) select NULL
def information_schema COLUMN_STATISTICS HISTOGRAM 4 NULL NO json NULL NULL NULL NULL NULL NULL NULL json select NULL
def information_schema DATABASE_APPLIED_HLC DATABASE_NAME 1 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(192) select NULL
def information_schema DATABASE_APPLIED_HLC APPLIED_HLC 2 NO bigint NULL NULL NULL NULL NULL NULL NULL bigint(21) unsigned select NULL
def information_schema ENGINES ENGINE 1 NO varchar 21 64 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NULL
def information_schema ENGINES SUPPORT 2 NO varchar 2 8 NULL NULL NULL utf8 utf8_general_ci varchar(8) select NULL
def information_schema ENGINES COMMENT 3 NO varchar 26 80 NULL NULL NULL utf8 utf8_general_ci varchar(80) select NULL
Expand Down Expand Up @@ -556,6 +558,8 @@ NULL information_schema COLUMNS SRS_ID int NULL NULL NULL NULL int(10) unsigned
3.0000 information_schema COLUMN_STATISTICS TABLE_NAME varchar 64 192 utf8 utf8_bin varchar(64)
3.0000 information_schema COLUMN_STATISTICS COLUMN_NAME varchar 64 192 utf8 utf8_bin varchar(64)
NULL information_schema COLUMN_STATISTICS HISTOGRAM json NULL NULL NULL NULL json
3.0000 information_schema DATABASE_APPLIED_HLC DATABASE_NAME varchar 64 192 utf8 utf8_general_ci varchar(192)
NULL information_schema DATABASE_APPLIED_HLC APPLIED_HLC bigint NULL NULL NULL NULL bigint(21) unsigned
3.0476 information_schema ENGINES ENGINE varchar 21 64 utf8 utf8_general_ci varchar(64)
4.0000 information_schema ENGINES SUPPORT varchar 2 8 utf8 utf8_general_ci varchar(8)
3.0769 information_schema ENGINES COMMENT varchar 26 80 utf8 utf8_general_ci varchar(80)
Expand Down
4 changes: 4 additions & 0 deletions mysql-test/suite/funcs_1/r/is_columns_is_cs.result
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def information_schema COLUMN_STATISTICS SCHEMA_NAME 1 NULL NO varchar 64 192 NU
def information_schema COLUMN_STATISTICS TABLE_NAME 2 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) select NULL
def information_schema COLUMN_STATISTICS COLUMN_NAME 3 NULL NO varchar 64 192 NULL NULL NULL utf8 utf8_bin varchar(64) select NULL
def information_schema COLUMN_STATISTICS HISTOGRAM 4 NULL NO json NULL NULL NULL NULL NULL NULL NULL json select NULL
def information_schema DATABASE_APPLIED_HLC DATABASE_NAME 1 NO varchar 64 192 NULL NULL NULL utf8 utf8_general_ci varchar(192) select NULL
def information_schema DATABASE_APPLIED_HLC APPLIED_HLC 2 NO bigint NULL NULL NULL NULL NULL NULL NULL bigint(21) unsigned select NULL
def information_schema ENGINES ENGINE 1 NO varchar 21 64 NULL NULL NULL utf8 utf8_general_ci varchar(64) select NULL
def information_schema ENGINES SUPPORT 2 NO varchar 2 8 NULL NULL NULL utf8 utf8_general_ci varchar(8) select NULL
def information_schema ENGINES COMMENT 3 NO varchar 26 80 NULL NULL NULL utf8 utf8_general_ci varchar(80) select NULL
Expand Down Expand Up @@ -655,6 +657,8 @@ NULL information_schema COLUMNS SRS_ID int NULL NULL NULL NULL int(10) unsigned
3.0000 information_schema COLUMN_STATISTICS TABLE_NAME varchar 64 192 utf8 utf8_bin varchar(64)
3.0000 information_schema COLUMN_STATISTICS COLUMN_NAME varchar 64 192 utf8 utf8_bin varchar(64)
NULL information_schema COLUMN_STATISTICS HISTOGRAM json NULL NULL NULL NULL json
3.0000 information_schema DATABASE_APPLIED_HLC DATABASE_NAME varchar 64 192 utf8 utf8_general_ci varchar(192)
NULL information_schema DATABASE_APPLIED_HLC APPLIED_HLC bigint NULL NULL NULL NULL bigint(21) unsigned
3.0476 information_schema ENGINES ENGINE varchar 21 64 utf8 utf8_general_ci varchar(64)
4.0000 information_schema ENGINES SUPPORT varchar 2 8 utf8 utf8_general_ci varchar(8)
3.0769 information_schema ENGINES COMMENT varchar 26 80 utf8 utf8_general_ci varchar(80)
Expand Down
46 changes: 46 additions & 0 deletions mysql-test/suite/funcs_1/r/is_tables_is.result
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,29 @@ user_comment
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA information_schema
TABLE_NAME DATABASE_APPLIED_HLC
TABLE_TYPE SYSTEM VIEW
ENGINE NULL
VERSION 10
ROW_FORMAT NULL
TABLE_ROWS #TBLR#
AVG_ROW_LENGTH #ARL#
DATA_LENGTH #DL#
MAX_DATA_LENGTH #MDL#
INDEX_LENGTH #IL#
DATA_FREE #DF#
AUTO_INCREMENT #AI#
CREATE_TIME #CRT#
UPDATE_TIME #UT#
CHECK_TIME #CT#
TABLE_COLLATION NULL
CHECKSUM NULL
CREATE_OPTIONS #CO#
TABLE_COMMENT #TC#
user_comment
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA information_schema
TABLE_NAME ENGINES
TABLE_TYPE SYSTEM VIEW
ENGINE NULL
Expand Down Expand Up @@ -1165,6 +1188,29 @@ user_comment
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA information_schema
TABLE_NAME DATABASE_APPLIED_HLC
TABLE_TYPE SYSTEM VIEW
ENGINE NULL
VERSION 10
ROW_FORMAT NULL
TABLE_ROWS #TBLR#
AVG_ROW_LENGTH #ARL#
DATA_LENGTH #DL#
MAX_DATA_LENGTH #MDL#
INDEX_LENGTH #IL#
DATA_FREE #DF#
AUTO_INCREMENT #AI#
CREATE_TIME #CRT#
UPDATE_TIME #UT#
CHECK_TIME #CT#
TABLE_COLLATION NULL
CHECKSUM NULL
CREATE_OPTIONS #CO#
TABLE_COMMENT #TC#
user_comment
Separator -----------------------------------------------------
TABLE_CATALOG def
TABLE_SCHEMA information_schema
TABLE_NAME ENGINES
TABLE_TYPE SYSTEM VIEW
ENGINE NULL
Expand Down
Loading

0 comments on commit e734faa

Please sign in to comment.