Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable PostgreSQL JIT and parallel workers in middle #1256

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion src/middle-pgsql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,12 @@ middle_query_pgsql_t::middle_query_pgsql_t(
std::string const &conninfo, std::shared_ptr<node_ram_cache> const &cache,
std::shared_ptr<node_persistent_cache> const &persistent_cache)
: m_sql_conn(conninfo), m_cache(cache), m_persistent_cache(persistent_cache)
{}
{
// Disable JIT and parallel workers as they are known to cause
// problems when accessing the intarrays.
m_sql_conn.set_config("jit_above_cost", "-1");
m_sql_conn.set_config("max_parallel_workers_per_gather", "0");
}

void middle_pgsql_t::start()
{
Expand All @@ -554,6 +559,11 @@ void middle_pgsql_t::start()
}

if (m_append) {
// Disable JIT and parallel workers as they are known to cause
// problems when accessing the intarrays.
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
11 changes: 11 additions & 0 deletions src/pgsql.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ 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
{
// Update pg_settings instead of using SET because it does not yield
// errors on older versions of PostgreSQL where the settings are not
// implemented.
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