[sqlsmith] Missing CHECK_FOR_INTERRUPTS in tsquery_rewrite

From: Andreas Seltenreich <seltenreich(at)gmx(dot)de>
To: pgsql-hackers(at)postgresql(dot)org
Subject: [sqlsmith] Missing CHECK_FOR_INTERRUPTS in tsquery_rewrite
Date: 2016-10-30 03:14:45
Message-ID: 8760oasf2y.fsf@credativ.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

testing with sqlsmith yielded an uncancellable backend hogging CPU time.
Gdb showed it was busy in findeq() of tsquery_rewrite.c. This function
appears to have exponential complexity wrt. the size of the involved
tsqueries. The following query runs for 12s on my machine with no way
to cancel it and incrementing the length of the first argument by 1
doubles this time.

select ts_rewrite(
(select string_agg(i::text, '&')::tsquery from generate_series(1,32) g(i)),
(select string_agg(i::text, '&')::tsquery from generate_series(1,19) g(i)),
'foo');

The attached patch adds a CHECK_FOR_INTERRUPTS to make it cancellable.

regards,
Andreas

Attachment Content-Type Size
0001-Add-CHECK_FOR_INTERRUPTS-in-tsquery_rewrite-loop.patch text/x-diff 1001 bytes

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Michael Paquier 2016-10-30 07:04:15 Re: Mention column name in error messages
Previous Message Jim Nasby 2016-10-29 20:31:14 Re: make coverage-html on OS X