MDEV-4991 GTID binlog indexing
In-memory cache for binlog position -> GTID state used by SQL function
binlog_gtid_pos(). The cache is growing when events are written to
binlog file. Configured by (1 is default value):
set @@global.binlog_gtid_pos_cache= N;
N = 0 means no caching is done, the existing cache will be deleted on
FLUSH BINARY LOGS.
N > 0 means keep cache for N last binary log files. On FLUSH BINARY
LOGS the cache is rotated according to current binlog_gtid_pos_cache
value.
The cache is done via GTID array in chronological order and hash
mapping event offsets to the index of last GTID. gtid_state->load() in
gtid_state_from_pos() loads then this array up the mapped index and
keeps only the last GTIDs per each domain (that's how it works
originally).
To indicate "no GTIDs" state hash stores
SIZE_T_MAX. gtid_state_from_pos() returns empty string for that and
NULL for error state.
Testing is done in binlog_hash.test which can compare results of cache
and non-cached algorithms via combinations cache_off/cache_on.
Debug tracing can be used to check cache hits/misses as well as hash
rotation:
mtr --mysqld=--debug=d,binlog:o,/tmp/b.log binlog_hash,cache_on