Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
biboumi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
88
Issues
88
List
Boards
Labels
Service Desk
Milestones
Merge Requests
7
Merge Requests
7
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
louiz’
biboumi
Commits
d7427fc9
Commit
d7427fc9
authored
Mar 19, 2018
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-connect to postgresql when the connection is lost
fix #3336
parent
8f74d4dd
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
2 deletions
+15
-2
CHANGELOG.rst
CHANGELOG.rst
+3
-0
src/database/postgresql_statement.hpp
src/database/postgresql_statement.hpp
+12
-2
No files found.
CHANGELOG.rst
View file @
d7427fc9
...
...
@@ -8,6 +8,9 @@ Version 8.0
the user customize the address to use when connecting to a server.
See https://lab.louiz.org/louiz/biboumi/issues/3273 for more details.
- Messages id are properly reflected to the sender
- We now properly deal with a PostgreSQL server restart: whenever the
connection is lost with the server, we try to reconnect and re-execute the
query once.
Version 7.2 - 2018-01-24
========================
...
...
src/database/postgresql_statement.hpp
View file @
d7427fc9
...
...
@@ -92,7 +92,7 @@ class PostgresqlStatement: public Statement
private:
private:
bool
execute
()
bool
execute
(
const
bool
second_attempt
=
false
)
{
std
::
vector
<
const
char
*>
params
;
params
.
reserve
(
this
->
params
.
size
());
...
...
@@ -113,8 +113,18 @@ private:
const
char
*
original
=
PQerrorMessage
(
this
->
conn
);
if
(
original
&&
std
::
strlen
(
original
)
>
0
)
log_error
(
"Failed to execute command: "
,
std
::
string
{
original
,
std
::
strlen
(
original
)
-
1
});
if
(
PQstatus
(
this
->
conn
)
!=
CONNECTION_OK
&&
!
second_attempt
)
{
log_info
(
"Trying to reconnect to PostgreSQL server and execute the query again."
);
PQreset
(
this
->
conn
);
return
this
->
execute
(
true
);
}
else
{
log_error
(
"Givin up."
);
return
false
;
}
}
return
true
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment