Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fetch Rows Wrong #849

Closed
qianxiansheng90 opened this issue Jun 19, 2024 · 0 comments · Fixed by #853
Closed

Fetch Rows Wrong #849

qianxiansheng90 opened this issue Jun 19, 2024 · 0 comments · Fixed by #853

Comments

@qianxiansheng90
Copy link

file:perf_schema_events_statements.go

const perfEventsStatementsQuery = `
	SELECT
	    ifnull(SCHEMA_NAME, 'NONE') as SCHEMA_NAME,
	    DIGEST,
	    LEFT(DIGEST_TEXT, %d) as DIGEST_TEXT,
	    COUNT_STAR,
	    SUM_TIMER_WAIT,
	    SUM_ERRORS,
	    SUM_WARNINGS,
	    SUM_ROWS_AFFECTED,
	    SUM_ROWS_SENT,
	    SUM_ROWS_EXAMINED,
	    SUM_CREATED_TMP_DISK_TABLES,
	    SUM_CREATED_TMP_TABLES,
	    SUM_SORT_MERGE_PASSES,
	    SUM_SORT_ROWS,
	    SUM_NO_INDEX_USED
	  FROM (
	    SELECT *
	    FROM performance_schema.events_statements_summary_by_digest
	    WHERE SCHEMA_NAME NOT IN ('mysql', 'performance_schema', 'information_schema')
	      AND LAST_SEEN > DATE_SUB(NOW(), INTERVAL %d SECOND)
	    ORDER BY LAST_SEEN DESC
	  )Q
	  GROUP BY
	    Q.SCHEMA_NAME,
	    Q.DIGEST,
	    Q.DIGEST_TEXT,
	    Q.COUNT_STAR,
	    Q.SUM_TIMER_WAIT,
	    Q.SUM_ERRORS,
	    Q.SUM_WARNINGS,
	    Q.SUM_ROWS_AFFECTED,
	    Q.SUM_ROWS_SENT,
	    Q.SUM_ROWS_EXAMINED,
	    Q.SUM_CREATED_TMP_DISK_TABLES,
	    Q.SUM_CREATED_TMP_TABLES,
	    Q.SUM_SORT_MERGE_PASSES,
	    Q.SUM_SORT_ROWS,
	    Q.SUM_NO_INDEX_USED
	  ORDER BY SUM_TIMER_WAIT DESC
	  LIMIT %d
	`

but fetch

		if err := perfSchemaEventsStatementsRows.Scan(
			&schemaName, &digest, &digestText, &count, &queryTime, &errors, &warnings, &rowsAffected, &rowsSent, &rowsExamined, &tmpTables, &tmpDiskTables, &sortMergePasses, &sortRows, &noIndexUsed,
		); err != nil {
			return err
		}

variable tmpDiskTables must before tmpTables.

cristiangreco added a commit to cristiangreco/mysqld_exporter that referenced this issue Jul 10, 2024
The `perf_schema.eventsstatements` collector was incorrectly exposing
"tmp_tables" as "tmp_disk_tables" and vice versa, due to query result
being scanned in incorrect order.

Closes prometheus#849
cristiangreco added a commit to cristiangreco/mysqld_exporter that referenced this issue Jul 10, 2024
The `perf_schema.eventsstatements` collector was incorrectly exposing
"tmp_tables" as "tmp_disk_tables" and vice versa, due to query result
being scanned in incorrect order.

Closes prometheus#849

Signed-off-by: Cristian Greco <[email protected]>
SuperQ pushed a commit that referenced this issue Aug 27, 2024
The `perf_schema.eventsstatements` collector was incorrectly exposing
"tmp_tables" as "tmp_disk_tables" and vice versa, due to query result
being scanned in incorrect order.

Closes #849

Signed-off-by: Cristian Greco <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant