pgsql: Fix error handling with threads on OOM in ECPG connection logic

Поиск
Список
Период
Сортировка
От Michael Paquier
Тема pgsql: Fix error handling with threads on OOM in ECPG connection logic
Дата
Msg-id E1mPdY5-0008H5-Lv@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix error handling with threads on OOM in ECPG connection logic

An out-of-memory failure happening when allocating the structures to
store the connection parameter keywords and values would mess up with
the set of connections saved, as on failure the pthread mutex would
still be hold with the new connection object listed but free()'d.

Rather than just unlocking the mutex, which would leave the static list
of connections into an inconsistent state, move the allocation for the
structures of the connection parameters before beginning the test
manipulation.  This ensures that the list of connections and the
connection mutex remain consistent all the time in this code path.

This error is unlikely going to happen, but this could mess up badly
with ECPG clients in surprising ways, so backpatch all the way down.

Reported-by: ryancaicse
Discussion: https://postgr.es/m/17186-b4cfd8f0eb4d1dee@postgresql.org
Backpatch-through: 9.6

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/cc057fb315e24b78552f5b7ac05792418042e71b

Modified Files
--------------
src/interfaces/ecpg/ecpglib/connect.c | 71 +++++++++++++++++++----------------
1 file changed, 39 insertions(+), 32 deletions(-)


В списке pgsql-committers по дате отправления:

Предыдущее
От: Amit Kapila
Дата:
Сообщение: pgsql: Doc: Change optional parameters grouping in Create Subscription.
Следующее
От: Amit Kapila
Дата:
Сообщение: pgsql: Fix reorder buffer memory accounting for toast changes.