mirror of
https://github.com/neondatabase/neon.git
synced 2026-01-06 04:52:55 +00:00
## Problem During ingest_benchmark which uses `pgcopydb` ([see](https://github.com/dimitri/pgcopydb))we sometimes had outages. - when PostgreSQL COPY step failed we got a segfault (reported [here](https://github.com/dimitri/pgcopydb/issues/899)) - the root cause was Neon idle_in_transaction_session_timeout is set to 5 minutes which is suboptimal for long-running tasks like project import (reported [here](https://github.com/dimitri/pgcopydb/issues/900)) ## Summary of changes Patch pgcopydb to avoid segfault. override idle_in_transaction_session_timeout and set it to "unlimited"
38 lines
1.1 KiB
Diff
38 lines
1.1 KiB
Diff
diff --git a/src/bin/pgcopydb/copydb.c b/src/bin/pgcopydb/copydb.c
|
|
index d730b03..69a9be9 100644
|
|
--- a/src/bin/pgcopydb/copydb.c
|
|
+++ b/src/bin/pgcopydb/copydb.c
|
|
@@ -44,6 +44,7 @@ GUC dstSettings[] = {
|
|
{ "synchronous_commit", "'off'" },
|
|
{ "statement_timeout", "0" },
|
|
{ "lock_timeout", "0" },
|
|
+ { "idle_in_transaction_session_timeout", "0" },
|
|
{ NULL, NULL },
|
|
};
|
|
|
|
diff --git a/src/bin/pgcopydb/pgsql.c b/src/bin/pgcopydb/pgsql.c
|
|
index 94f2f46..86b9448 100644
|
|
--- a/src/bin/pgcopydb/pgsql.c
|
|
+++ b/src/bin/pgcopydb/pgsql.c
|
|
@@ -3174,11 +3174,18 @@ pgcopy_log_error(PGSQL *pgsql, PGresult *res, const char *context)
|
|
/* errors have already been logged */
|
|
return;
|
|
}
|
|
-
|
|
if (res != NULL)
|
|
{
|
|
char *sqlstate = PQresultErrorField(res, PG_DIAG_SQLSTATE);
|
|
- strlcpy(pgsql->sqlstate, sqlstate, sizeof(pgsql->sqlstate));
|
|
+ if (sqlstate == NULL)
|
|
+ {
|
|
+ // PQresultErrorField returned NULL!
|
|
+ pgsql->sqlstate[0] = '\0'; // Set to an empty string to avoid segfault
|
|
+ }
|
|
+ else
|
|
+ {
|
|
+ strlcpy(pgsql->sqlstate, sqlstate, sizeof(pgsql->sqlstate));
|
|
+ }
|
|
}
|
|
|
|
char *endpoint =
|