[MXS-4290] Maxscale masking filter returns parsing error on SELECT with very long WHERE Created: 2022-09-13  Updated: 2022-11-18  Resolved: 2022-09-14

Status: Closed
Project: MariaDB MaxScale
Component/s: Filter
Affects Version/s: 6.4.1
Fix Version/s: 6.4.3, 22.08.2

Type: Bug Priority: Major
Reporter: Yakov Kushnirsky Assignee: Johan Wikman
Resolution: Fixed Votes: 0
Labels: None

Attachments: File sql_where.sql    

 Description   

SELECT that has WHERE with ~1173 elements fails if masking filter is configured:
Error : (conn=65) The statement could not be fully parsed and will hence be rejected (masking filter)
...
reducing WHERE makes the error gone. It seems no documented limitations, which this SQL violates.



 Comments   
Comment by Johan Wikman [ 2022-09-14 ]

By default the sqlite3 parser used by MaxScale has a recursion depth of 1000. This means e.g. that the maximum number of comparisons in a WHERE clause is 1000. The limit has now been raised to 25000, which is far more than needed by the statement in this issue.
There has to be a limit, as otherwise a WHERE clause with a sufficient number of comparisons will cause a stack overflow and MaxScale crash.

Comment by Johan Wikman [ 2022-09-22 ]

The limit will be lowered to 4096, which is still more than enough for the case in this issue. Originally it was changed to 25000, which is fine in a regular Linux environment. However, if MaxScale is running in a constrained container environment, with an expression depth of 25000 a pathological statement may cause MaxScale to run out of memory and crash. 4096 seems like a good compromise.

Generated at Thu Feb 08 04:27:34 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.