Skip to content

Commit

Permalink
Disable PostgreSQL JIT and parallel workers in middle
Browse files Browse the repository at this point in the history
They are known to have problems with the int arrays.

See #1045
  • Loading branch information
joto committed Jul 26, 2020
1 parent 79cd536 commit 0e47aab
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/middle-pgsql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -554,6 +554,14 @@ void middle_pgsql_t::start()
}

if (m_append) {
// Disable JIT and parallel workers as they are known to cause
// problems when accessing the intarrays.
// Update pg_settings instead of using SET because it does not yield
// errors on older versions of Postgres where the settings are not
// implemented.
m_db_connection.set_config("jit_above_cost", "-1");
m_db_connection.set_config("max_parallel_workers_per_gather", "0");

// Prepare queries for updating dependent objects
for (auto &table : m_tables) {
if (!table.m_prepare_intarray.empty()) {
Expand Down
8 changes: 8 additions & 0 deletions src/pgsql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ pg_result_t pg_conn_t::query(ExecStatusType expect,
return query(expect, sql.c_str());
}

void pg_conn_t::set_config(char const *setting, char const *value) const
{
auto const sql =
"UPDATE pg_settings SET setting = '{}' WHERE name = '{}'"_format(
setting, value);
query(PGRES_TUPLES_OK, sql);
}

void pg_conn_t::exec(char const *sql) const { query(PGRES_COMMAND_OK, sql); }

void pg_conn_t::exec(std::string const &sql) const
Expand Down
2 changes: 2 additions & 0 deletions src/pgsql.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ class pg_conn_t

pg_result_t query(ExecStatusType expect, std::string const &sql) const;

void set_config(char const *setting, char const *value) const;

void exec(char const *sql) const;

void exec(std::string const &sql) const;
Expand Down

0 comments on commit 0e47aab

Please sign in to comment.