Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 766195 - app-backup/bacula-9.6.4 through 9.6.7 : Bug in database locking code causes concurrency problems and job failures (patch attached)
Summary: app-backup/bacula-9.6.4 through 9.6.7 : Bug in database locking code causes c...
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Thomas Beierlein
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2021-01-19 20:30 UTC by Phil Stracchino (Unix Ronin)
Modified: 2021-01-24 05:03 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Patch for off-by-one error in Bacula Director 9.6.4 through 9.6.7 (bacula-9.6.7-fix-race-condition.patch,774 bytes, patch)
2021-01-19 20:31 UTC, Phil Stracchino (Unix Ronin)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Phil Stracchino (Unix Ronin) 2021-01-19 20:30:19 UTC
In Bacula 9.6.4, the following code change was made at src/dird/dird.c:1268 :

- strncpy(catalog->db_driver, BDB_db_driver, db_driver_len);
+ bstrncpy(catalog->db_driver, BDB_db_driver, db_driver_len);

It was not noticed at the time that this introduced an off-by-one error that led to a bug in DB driver definition which prevents reuse of the BDB object, leading to unexpected concurrency between jobs, leading in turn to job failures due to race conditions writing to the database.

The fix is to change that line to:

bstrncpy(catalog->db_driver, BDB_db_driver, db_driver_len+1);

I will be attaching a patch for this in a moment that is applicable to all versions 9.6.4 through 9.6.7.  The bug is already fixed in Bacula 11.

Reproducible: Always
Comment 1 Phil Stracchino (Unix Ronin) 2021-01-19 20:31:45 UTC
Created attachment 683773 [details, diff]
Patch for off-by-one error in Bacula Director 9.6.4 through 9.6.7
Comment 2 Thomas Beierlein gentoo-dev 2021-01-22 18:37:32 UTC
Thanks for the bug report and the patch Phil.
I will pick it up on the weekend.
Comment 3 Thomas Beierlein gentoo-dev 2021-01-23 15:40:00 UTC
Looks like the problem you were hunting for some weeks. Glad you found it.
Patched version will be in tree in next minutes.
Comment 4 Larry the Git Cow gentoo-dev 2021-01-23 15:48:57 UTC
The bug has been closed via the following commit(s):

https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=465b334f163a88f6e045202c23c93cd36637e99a

commit 465b334f163a88f6e045202c23c93cd36637e99a
Author:     Thomas Beierlein <tomjbe@gentoo.org>
AuthorDate: 2021-01-23 15:48:21 +0000
Commit:     Thomas Beierlein <tomjbe@gentoo.org>
CommitDate: 2021-01-23 15:48:21 +0000

    app-backup/bacula: Fix database locking bug (bug #766195)
    
    Reported-by: Phil Stracchino <phils@caerllewys.net>
    Closes: https://bugs.gentoo.org/766195
    Package-Manager: Portage-3.0.14, Repoman-3.0.2
    Signed-off-by: Thomas Beierlein <tomjbe@gentoo.org>

 app-backup/bacula/bacula-9.6.5.ebuild                     |  5 ++++-
 app-backup/bacula/bacula-9.6.6.ebuild                     |  5 ++++-
 app-backup/bacula/bacula-9.6.7.ebuild                     |  5 ++++-
 .../bacula/files/bacula-9.6.x-fix-race-condition.patch    | 15 +++++++++++++++
 4 files changed, 27 insertions(+), 3 deletions(-)
Comment 5 Phil Stracchino (Unix Ronin) 2021-01-24 05:03:12 UTC
(In reply to Thomas Beierlein from comment #3)
> Looks like the problem you were hunting for some weeks. Glad you found it.
> Patched version will be in tree in next minutes.

Yup, it's taken a couple of months to track this down.  Martin Simmons actually found it, in code it had never occurred to me to look at.