consolidate: purge jobids without files before starting the consolidation#1056
consolidate: purge jobids without files before starting the consolidation#1056
Conversation
bruno-at-bareos
left a comment
There was a problem hiding this comment.
Answer the question about sending the code in case of exit on fatal.
Changelog Commit needed.
bruno-at-bareos
left a comment
There was a problem hiding this comment.
I let one suggestion open.
76b2a6c to
f9592a7
Compare
8098589 to
4c3dc77
Compare
4c17c41 to
5680781
Compare
bruno-at-bareos
left a comment
There was a problem hiding this comment.
Let see if last modification build and tests pass.
bruno-at-bareos
left a comment
There was a problem hiding this comment.
Everything reviewed, tested, and build correctly.
Nice work.
core/src/cats/sql_get.cc
Outdated
| { | ||
| db_list_ctx deleted_jobids; | ||
| std::string query{ | ||
| "DELETE FROM Job where (JobFiles=0 OR PurgedFiles=1) AND JobID in ("}; |
There was a problem hiding this comment.
do we really want to implicitly purge jobs when their files were purged?
I don't think that's right.
There was a problem hiding this comment.
also, just doing an SQL DELETE will potentially leave stale records in tables JobMedia, Log, basefiles, PathVisibility, NDMPJobEnvironment, JobStats and RestoreObject.
There was a problem hiding this comment.
I guess we need to determine the list and then do whatever"delete jobid=XXX" would be doing.
core/src/cats/sql_get.cc
Outdated
| { | ||
| db_list_ctx deleted_jobids; | ||
| std::string query{ | ||
| "DELETE FROM Job where (JobFiles=0 OR PurgedFiles=1) AND JobID in ("}; |
There was a problem hiding this comment.
also, just doing an SQL DELETE will potentially leave stale records in tables JobMedia, Log, basefiles, PathVisibility, NDMPJobEnvironment, JobStats and RestoreObject.
core/src/cats/sql_get.cc
Outdated
| 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", |
There was a problem hiding this comment.
shouldn't it be "Purging" instead of "Deleting"?
core/src/cats/sql_get.cc
Outdated
| { | ||
| db_list_ctx deleted_jobids; | ||
| std::string query{ | ||
| "DELETE FROM Job where (JobFiles=0 OR PurgedFiles=1) AND JobID in ("}; |
There was a problem hiding this comment.
I guess we need to determine the list and then do whatever"delete jobid=XXX" would be doing.
e044bb8 to
3327e62
Compare
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.
3327e62 to
c6306fa
Compare
4a167a4 to
538697d
Compare
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
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
Source code quality
bareos-check-sources --since-mergedoes not report any problemsgit statusshould not report modifications in the source tree after building and testingTests