Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5c27bce

Browse files
committed
Clear dangling pointer to avoid bogus EXPLAIN printout in a corner case.
ExecReScanHashJoin will destroy the join's hash table if it expectsthat the inner relation will produce different rows on rescan.Up to now it's not bothered to clear the additional pointer to thathash table that exists in the child HashState node. However, it'spossible for the query to terminate without building a fresh hashtable (this happens if the outer relation is found to be emptyduring the final rescan). So we can end with a dangling pointerto a deleted hash table. That was harmless originally, but since9.0 EXPLAIN ANALYZE has used that pointer to print hash tablestatistics. In debug builds this reproducibly results in garbagestatistics. In non-debug builds there's frequently no ill effects,but in principle one could get wrong EXPLAIN ANALYZE output, orperhaps even a crash if free() has released the hashtable memoryback to the OS.To fix, just make sure we clear the additional pointer when destroyingthe hash table. In problematic cases, EXPLAIN ANALYZE will then printno hashtable statistics (reverting to its pre-9.0 behavior). This isn'tideal, but since the problem manifests only in unusual corner cases,it's hard to justify taking any risks to do better in the backbranches. A follow-on patch will improve matters in HEAD.Konstantin Knizhnik and Tom Lane, per diagnosis by Thomas Munroof a trouble report from Alvaro Herrera.Discussion:https://postgr.es/m/20200323165059.GA24950@alvherre.pgsql
1 parent12fb189 commit5c27bce

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

‎src/backend/executor/nodeHashjoin.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,6 +1336,12 @@ ExecReScanHashJoin(HashJoinState *node)
13361336
else
13371337
{
13381338
/* must destroy and rebuild hash table */
1339+
HashState*hashNode=castNode(HashState,innerPlanState(node));
1340+
1341+
/* for safety, be sure to clear child plan node's pointer too */
1342+
Assert(hashNode->hashtable==node->hj_HashTable);
1343+
hashNode->hashtable=NULL;
1344+
13391345
ExecHashTableDestroy(node->hj_HashTable);
13401346
node->hj_HashTable=NULL;
13411347
node->hj_JoinState=HJ_BUILD_HASHTABLE;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp