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

bareos-fd-postgres: properly close database connection #1321

Closed
wants to merge 1 commit into from

Conversation

lluuaapp
Copy link
Contributor

This will properly close the database connection after a Postgres WAL backup was made. As far as I could see a call to close() is completely missing in the current code. As the the connection may already been closed I put it in a try/except to ignore all errors that may occur.

On my test system this prevents the PostgreSQL server to log

unexpected EOF on client connection with an open transaction

every backup.

  • Short description and the purpose of this PR is present
  • Your name is present in the AUTHORS file (optional)

If you have any questions or problems, please give a comment in the PR.

Helpful documentation and best practices

Checklist for the reviewer of the PR (will be processed by the Bareos team)

General
  • PR name is meaningful
  • Purpose of the PR is understood
  • Commit descriptions are understandable and well formatted
  • Check backport line
  • Is the PR title usable as CHANGELOG entry?
  • Separate commit for CHANGELOG.md ("update CHANGELOG.md"). The PR number is correct.
Source code quality
  • Source code changes are understandable
  • Variable and function names are meaningful
  • Code comments are correct (logically and spelling)
  • Required documentation changes are present and part of the PR
  • bareos-check-sources --since-merge does not report any problems
Tests
  • Decision taken that a test is required (if not, then remove this paragraph)
  • The choice of the type of test (unit test or systemtest) is reasonable
  • Testname matches exactly what is being tested
  • On a fail, output of the test leads quickly to the origin of the fault

Copy link
Member

@arogge arogge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you very much for taking the time to improve Bareos!

We usually fix things in master and then backport to the release branches. Would you mind changing your PR to target the master branch? We can add a "requires backport" label to the PR (and we can probably handle the backport for you)

Also, if you don't mind - would you rename the existing closeDbConnection() to something reasonable? It isn't really about closing the connection.

Comment on lines +453 to +454
except Exception as e:
pass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not really happy with that. I guess we're only expecting a "connection already closed" exception and thus we should only catch that one.

@lluuaapp
Copy link
Contributor Author

lluuaapp commented Dec 1, 2022

Seems than I can not change the target branch of a PR. I will close this one and create a new one from master -> master.

@lluuaapp lluuaapp closed this Dec 1, 2022
@lluuaapp
Copy link
Contributor Author

lluuaapp commented Dec 1, 2022

This is the new PR: #1326

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants