Commit a82fa1c0 authored by Adam Hegyi's avatar Adam Hegyi

Merge branch '342857-fix-segfault-cross-db-modification-check' into 'master'

Workaround PGQuery.parse segfault again

See merge request gitlab-org/gitlab!72166
parents 10c0e556 5ffcdd1f
...@@ -79,8 +79,17 @@ module Database ...@@ -79,8 +79,17 @@ module Database
return if cross_database_context[:transaction_depth_by_db].values.all?(&:zero?) return if cross_database_context[:transaction_depth_by_db].values.all?(&:zero?)
# PgQuery might fail in some cases due to limited nesting:
# https://github.com/pganalyze/pg_query/issues/209
#
# Also, we disable GC while parsing because of https://github.com/pganalyze/pg_query/issues/226
begin
GC.disable
parsed_query = PgQuery.parse(sql) parsed_query = PgQuery.parse(sql)
tables = sql.downcase.include?(' for update') ? parsed_query.tables : parsed_query.dml_tables tables = sql.downcase.include?(' for update') ? parsed_query.tables : parsed_query.dml_tables
ensure
GC.enable
end
return if tables.empty? return if tables.empty?
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment