Skip to content

Commit ba69408

Browse files
danolivoMikhail Rutman
authored andcommitted
Avoid to produce an ERROR during establishing of intra-multimaster psql-connection if it's not really needed. Caused by stress tests when I found dangerous places: some services can send dmq messages to channel, subscribed by another service.
Tags: Multimaster
1 parent ac81027 commit ba69408

File tree

2 files changed

+24
-7
lines changed

2 files changed

+24
-7
lines changed

src/dmq.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1651,7 +1651,7 @@ dmq_push_buffer(DmqDestinationId dest_id, char *stream_name, const void *payload
16511651
res = shm_mq_send(dmq_local.mq_outh, buf.len, buf.data, false);
16521652
pfree(buf.data);
16531653
if (res != SHM_MQ_SUCCESS)
1654-
mtm_log(ERROR, "[DMQ] dmq_push: can't send to queue");
1654+
mtm_log(ERROR, "[DMQ] dmq_push: can't send to queue, status = %d", res);
16551655
}
16561656

16571657
/*

src/mtm_utils.c

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,35 @@ disable_client_timeouts(PGconn *conn)
3333

3434
res = PQexec(conn, "SET statement_timeout = 0");
3535
if (PQresultStatus(res) != PGRES_COMMAND_OK)
36-
mtm_log(ERROR, "failed to set statement_timeout: %s",
36+
{
37+
mtm_log(WARNING, "failed to set statement_timeout: %s",
3738
pchomp(PQerrorMessage(conn)));
39+
return false;
40+
}
3841

3942
res = PQexec(conn, "SET lock_timeout = 0");
4043
if (PQresultStatus(res) != PGRES_COMMAND_OK)
41-
mtm_log(ERROR, "failed to set lock_timeout: %s",
44+
{
45+
mtm_log(WARNING, "failed to set lock_timeout: %s",
4246
pchomp(PQerrorMessage(conn)));
47+
return false;
48+
}
4349

4450
res = PQexec(conn, "SET idle_in_transaction_session_timeout = 0");
4551
if (PQresultStatus(res) != PGRES_COMMAND_OK)
46-
mtm_log(ERROR, "failed to set idle_in_transaction_session_timeout: %s",
52+
{
53+
mtm_log(WARNING, "failed to set idle_in_transaction_session_timeout: %s",
4754
pchomp(PQerrorMessage(conn)));
55+
return false;
56+
}
4857

4958
res = PQexec(conn, "SET idle_session_timeout = 0");
5059
if (PQresultStatus(res) != PGRES_COMMAND_OK)
51-
mtm_log(ERROR, "failed to set idle_session_timeout: %s",
60+
{
61+
mtm_log(WARNING, "failed to set idle_session_timeout: %s",
5262
pchomp(PQerrorMessage(conn)));
63+
return false;
64+
}
5365

5466
return true;
5567
}
@@ -90,7 +102,8 @@ MtmPQconnectPoll(PGconn *conn)
90102
if (status != PGRES_POLLING_OK)
91103
return status;
92104

93-
disable_client_timeouts(conn);
105+
if (!disable_client_timeouts(conn))
106+
status = PGRES_POLLING_FAILED;
94107

95108
return status;
96109
}
@@ -109,7 +122,11 @@ MtmPQconnectdb(const char *conninfo)
109122
if (PQstatus(conn) != CONNECTION_OK)
110123
return conn;
111124

112-
disable_client_timeouts(conn);
125+
if (!disable_client_timeouts(conn))
126+
{
127+
PQfinish(conn);
128+
return NULL;
129+
}
113130

114131
return conn;
115132
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy