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

consolidate: purge jobids without files before starting the consolidation #1056

Merged
merged 5 commits into from
Mar 9, 2022

Conversation

pstorz
Copy link
Member

@pstorz pstorz commented Jan 25, 2022

Thank you for contributing to the Bareos Project!

The consolidation job now purges jobs without files from the jobid list before starting the consolidation. This makes sure that jobs without are cleaned up before and consolidation of jobs that do not have any files is never tried.

Also, the current postgresql query code reacts to an PGRES_FATAL_ERROR either by exiting the daemon (if exit on fatal is set) or by simply returning a normal error returning the error string from the database.

Please check

  • Short description and the purpose of this PR is present above this paragraph
  • 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
  • Separate commit for this PR in the CHANGELOG.md, PR number referenced is same
  • Commit descriptions are understandable and well formatted
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
  • git status should not report modifications in the source tree after building and testing
Tests
  • Decision taken that a system- or unittest is required (if not, then remove this paragraph)
  • The decision towards a systemtest is reasonable compared to a unittest
  • Testname matches exactly what is being tested
  • Output of the test leads quickly to the origin of the fault

@bruno-at-bareos bruno-at-bareos self-assigned this Jan 26, 2022
Copy link
Contributor

@bruno-at-bareos bruno-at-bareos left a comment

Choose a reason for hiding this comment

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

Answer the question about sending the code in case of exit on fatal.
Changelog Commit needed.

@pstorz pstorz added the nobuild label Jan 26, 2022
Copy link
Contributor

@bruno-at-bareos bruno-at-bareos left a comment

Choose a reason for hiding this comment

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

I let one suggestion open.

core/src/console/console.cc Outdated Show resolved Hide resolved
@pstorz pstorz force-pushed the dev/pstorz/master/sql-fatal-error-logging branch from 76b2a6c to f9592a7 Compare February 9, 2022 14:42
@pstorz pstorz removed the nobuild label Feb 10, 2022
@pstorz pstorz changed the title postgresql: print PQerrorMessage() in case of PGRES_FATAL_ERROR consolidate: purge jobids without files before starting the consolidation Feb 11, 2022
@pstorz pstorz force-pushed the dev/pstorz/master/sql-fatal-error-logging branch from 8098589 to 4c3dc77 Compare February 14, 2022 13:30
@bruno-at-bareos bruno-at-bareos force-pushed the dev/pstorz/master/sql-fatal-error-logging branch from 4c17c41 to 5680781 Compare February 16, 2022 16:55
Copy link
Contributor

@bruno-at-bareos bruno-at-bareos left a comment

Choose a reason for hiding this comment

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

Let see if last modification build and tests pass.

Copy link
Contributor

@bruno-at-bareos bruno-at-bareos left a comment

Choose a reason for hiding this comment

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

Everything reviewed, tested, and build correctly.
Nice work.

{
db_list_ctx deleted_jobids;
std::string query{
"DELETE FROM Job where (JobFiles=0 OR PurgedFiles=1) AND JobID in ("};
Copy link
Member

Choose a reason for hiding this comment

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

do we really want to implicitly purge jobs when their files were purged?
I don't think that's right.

Copy link
Member

Choose a reason for hiding this comment

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

also, just doing an SQL DELETE will potentially leave stale records in tables JobMedia, Log, basefiles, PathVisibility, NDMPJobEnvironment, JobStats and RestoreObject.

Copy link
Member

Choose a reason for hiding this comment

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

I guess we need to determine the list and then do whatever"delete jobid=XXX" would be doing.

arogge
arogge previously requested changes Feb 21, 2022
{
db_list_ctx deleted_jobids;
std::string query{
"DELETE FROM Job where (JobFiles=0 OR PurgedFiles=1) AND JobID in ("};
Copy link
Member

Choose a reason for hiding this comment

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

also, just doing an SQL DELETE will potentially leave stale records in tables JobMedia, Log, basefiles, PathVisibility, NDMPJobEnvironment, JobStats and RestoreObject.

if (!SqlQueryWithHandler(query.c_str(), DbDeleteListHandler,
&deleted_jobids)) {
Jmsg(jcr, M_ERROR, 0,
"Deleting jobids with no files from list %s failed : ERR=%s\n",
Copy link
Member

Choose a reason for hiding this comment

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

shouldn't it be "Purging" instead of "Deleting"?

{
db_list_ctx deleted_jobids;
std::string query{
"DELETE FROM Job where (JobFiles=0 OR PurgedFiles=1) AND JobID in ("};
Copy link
Member

Choose a reason for hiding this comment

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

I guess we need to determine the list and then do whatever"delete jobid=XXX" would be doing.

@arogge arogge self-assigned this Feb 24, 2022
@arogge arogge force-pushed the dev/pstorz/master/sql-fatal-error-logging branch 2 times, most recently from e044bb8 to 3327e62 Compare March 7, 2022 14:48
pstorz and others added 4 commits March 7, 2022 15:57
in case of PGRES_FATAL_ERROR
Verify that empty jobs are purged before consolidation starts.
This patch refactors functions to purge files and jobs and to upgrade
copy jobs to backup jobs so they can be called without an UaContext.
Previously empty jobs (i.e. those with JobFiles == 0) were left
untouched by consolidation. This change now adds functionality that will
identify these jobs and purge them so the result looks like they had
been consolidated, too.
@arogge arogge force-pushed the dev/pstorz/master/sql-fatal-error-logging branch from 3327e62 to c6306fa Compare March 7, 2022 14:59
@arogge arogge force-pushed the dev/pstorz/master/sql-fatal-error-logging branch from 4a167a4 to 538697d Compare March 7, 2022 17:13
@pstorz pstorz merged commit 9472579 into master Mar 9, 2022
@arogge arogge deleted the dev/pstorz/master/sql-fatal-error-logging branch March 9, 2022 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants