[MCOL-4944] QueryStats Doesn't Automatically Work When Turned On - used to in CS 1.2.5 Created: 2021-12-10  Updated: 2022-01-03  Resolved: 2022-01-03

Status: Closed
Project: MariaDB ColumnStore
Component/s: None
Affects Version/s: 6.1.1
Fix Version/s: 6.2.3

Type: Bug Priority: Major
Reporter: Allen Herrera Assignee: Daniel Lee (Inactive)
Resolution: Fixed Votes: 0
Labels: None

Attachments: File QueryStatsReproduction.bash    
Issue Links:
Relates
relates to MCOL-4821 ColumnStore Engine Monitoring and Met... Open
Sprint: 2021-16

 Description   

QueryStats does not automatically log each query calGetTrace() results like it used to even when enabled. On top of having a undocumented requirement of the cross engine user needing INSERT grant to `infinidb_querystats`.*
partial work around exists by adding to .cnf - init-connect='select calSetTrace(1);'
however init-connect doesnt work for root user

Expected:
When QueryStats is enabled, every query gets logged to infinidb_querystats.querystats without having to run select calSetTrace(1); before

Actual:
Until select calSetTrace(1); is ran, nothing is logged to infinidb_querystats.querystats

Reproduction:

mcsSetConfig QueryStats Enabled Y
systemctl stop mariadb-columnstore
systemctl stop mariadb
systemctl start mariadb
systemctl start mariadb-columnstore
mcsGetConfig -a | grep -i Cross
cej=$(mcsGetConfig CrossEngineSupport User)
pwd=$(mcsGetConfig CrossEngineSupport Password)
host=$(mcsGetConfig CrossEngineSupport Host)
# Make sure you have these grants
# GRANT SELECT,PROCESS ON *.* TO 'cross_engine'@'127.0.0.1';
# GRANT INSERT on `infinidb_querystats`.* TO 'cross_engine'@'127.0.0.1';
mariadb -h $host -u $cej -p$pwd -qse "select * from infinidb_querystats.querystats;"
# Confirm grants are good
# mariadb -h $host -u $cej -p$pwd -e "insert into infinidb_querystats.querystats (queryID)  values (1);"
mariadb -e "CREATE DATABASE IF NOT EXISTS test; USE test; CREATE TABLE IF NOT EXISTS t3 (a int) engine=columnstore;INSERT INTO t3 VALUES(1);INSERT INTO t3 VALUES(2);"
mariadb -h $host -u $cej -p$pwd test -e "SELECT * FROM t3 WHERE a=1;"
mariadb -h $host -u $cej -p$pwd -qse "select * from infinidb_querystats.querystats;"
# Notice queries dont automatically enter infinidb_querystats.querystats until you manually run "select calSetTrace(1);"
# Work around - add to /etc/my.cnf.d/server.cnf - init-connect='select calSetTrace(1);'
# However work around still doesnt work for root user



 Comments   
Comment by Daniel Lee (Inactive) [ 2022-01-03 ]

Build verified: 6.2.3-1 (#3646)

Verified InfiniDB_querystats.querystats contains info once query stats is enabled in the Columnstore.xml file.

MariaDB [mytest]> select count from orders;
----------

count

----------

1500000

----------
1 row in set, 1 warning (0.230 sec)

MariaDB [mytest]> select * from infinidb_querystats.querystats;
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

queryID sessionID host user priority queryType query startTime endTime rows errno phyIO cacheIO blocksTouched CPBlocksSkipped msgInUM msgOutUm maxMemPct blocksChanged numTempFiles tempFileSpace

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

1 3 localhost root LOW SELECT select count from orders 2022-01-03 17:10:11 2022-01-03 17:10:12 1 0 185 189 185 0 23865 1323 0 0 0 0

--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 row in set (0.001 sec)

Generated at Thu Feb 08 02:54:11 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.