Skip to content

duplicated qpid in logs when pg_stat_sql_plans.explain=true #27

@legrandlegrand

Description

@legrandlegrand

This appears with
pgbench -c20 -t5 (a kind of query storm ...)
on my MSYS2 (windows 10), but not on linux ...

It also appears in native pg_stat_statements as described here

https://www.postgresql-archive.org/pg-stat-statements-duplicated-external-query-texts-with-MSY2-td6140505.html

In fact, in pgss_store, the query is written in external query text file, before taking the EXCLUSIVE
lock ...

	/* Append new query text to file with only shared lock held */
	stored = qtext_store( query, query_len,
						 &query_offset, &gc_count);

in case of query storm, to prevent this, there should be no action between first hash_search and exclusive lock promotion ...
removing this action (forcing usage of the qtext_store reserved for gc cases under exclusive lock ) seems to help a lot for this issue, but should slow other tests cases (with many distincts queries for exemple).

Ideal solution would be to move this part after hash entry creation, outside exclusive lock,
query length and offset being updated with counters (but this is a big change).

Metadata

Metadata

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions