View Issue Details

IDProjectCategoryView StatusLast Update
0001409bareos-core[All Projects] directorpublic2022-01-13 14:22
ReporterjalseosAssigned Tobruno-at-bareos 
PrioritylowSeveritytweakReproducibilityalways
Status resolvedResolutionfixed 
PlatformLinuxOSDebianOS Version10
Product Version20.0.2 
Fixed in Version 
Summary0001409: DB error on restore with ExitOnFatal=true
DescriptionI was trying to use ExitOnFatal=true in director and noticed a persistent error when trying to initiate a restore:

bareos-dir: ERROR TERMINATION at cats/postgresql.cc:675
Fatal database error

The error does not happen with unset/default ExitOnFatal=false

The postgresql (11) log reveals:
STATEMENT: DROP TABLE temp
ERROR: table "temp1" does not exist
STATEMENT: DROP TABLE temp1
ERROR: table "temp1" does not exist

I found the SQL statements in thes files in the code:
/core/src/cats/dml/0018_uar_del_temp
/core/src/cats/dml/0019_uar_del_temp1

I am wondering if something like this might be in order: (like 0012_drop_deltabs.postgresql)
/core/src/cats/dml/0018_uar_del_temp.postgres
DROP TABLE IF EXISTS temp
Steps To Reproduce$ bconsole
* restore
9
bareos-dir: ERROR TERMINATION at cats/postgresql.cc:675
Fatal database error
TagsNo tags attached.
bareos-master: impact
bareos-master: action
bareos-19.2: impact
bareos-19.2: action
bareos-18.2: impact
bareos-18.2: action
bareos-17.2: impact
bareos-17.2: action
bareos-16.2: impact
bareos-16.2: action
bareos-15.2: impact
bareos-15.2: action
bareos-14.2: impact
bareos-14.2: action
bareos-13.2: impact
bareos-13.2: action
bareos-12.4: impact
bareos-12.4: action

Activities

bruno-at-bareos

bruno-at-bareos

2021-12-21 15:58

developer   ~0004400

The behavior is exiting in case of error when ExitOnFatal = true

STATEMENT: DROP TABLE temp
ERROR: table "temp1" does not exist

this is an error and the product the obey strictly to the paramet Exit On Fatal.

Now with future version, where only postgresql will be kept as database, but also older postgresql will never be installed the code can be reviewed to chase every drop table without and if exist.

Files to change

```
core/src/cats/dml/0018_uar_del_temp:DROP TABLE temp
core/src/cats/dml/0019_uar_del_temp1:DROP TABLE temp1
core/src/cats/mysql_queries.inc:"DROP TABLE temp "
core/src/cats/mysql_queries.inc:"DROP TABLE temp1 "
core/src/cats/postgresql_queries.inc:"DROP TABLE temp "
core/src/cats/postgresql_queries.inc:"DROP TABLE temp1 "
core/src/cats/sqlite_queries.inc:"DROP TABLE temp "
core/src/cats/sqlite_queries.inc:"DROP TABLE temp1 "
core/src/dird/query.sql:!DROP TABLE temp;
core/src/dird/query.sql:!DROP TABLE temp2;
```
Do you want to propose a PR for ?
bruno-at-bareos

bruno-at-bareos

2021-12-21 16:50

developer   ~0004405

PR proposed
https://github.com/bareos/bareos/pull/1035

Once the PR will be build, there's will be some testing package available, would you like to test them ?
jalseos

jalseos

2022-01-02 16:52

reporter   ~0004443

Hi, thank you for looking into this issue! I will try to test the built package (deb preferred) if a subsequent code/package "downgrade" (ie. no Catalog DB changes, ...) to a published Community Edition release remains possible afterwards.
bruno-at-bareos

bruno-at-bareos

2022-01-13 14:22

developer   ~0004473

Fix committed to bareos master branch with changesetid 15753.

Related Changesets

bareos: master aa1d4726

2021-12-21 16:44:44

bruno-at-bareos


Committer: pstorz

Ported: N/A

Details Diff
core cats: Add IF EXISTS in drop table statements

- Using if exists avoid return of fatal error from database
Allow the use of parameter ExitOnFatal = true on normal workflow
- Fixes 0001409: DB error on restore with ExitOnFatal=true

Signed-off-by: Bruno Friedmann <bruno.friedmann@bareos.com>
Affected Issues
0001409
mod - core/src/cats/dml/0018_uar_del_temp Diff File
mod - core/src/cats/dml/0019_uar_del_temp1 Diff File
mod - core/src/cats/mysql_queries.inc Diff File
mod - core/src/cats/postgresql_queries.inc Diff File
mod - core/src/cats/sqlite_queries.inc Diff File
mod - core/src/dird/query.sql Diff File

Issue History

Date Modified Username Field Change
2021-12-19 00:33 jalseos New Issue
2021-12-21 15:58 bruno-at-bareos Note Added: 0004400
2021-12-21 15:58 bruno-at-bareos Assigned To => bruno-at-bareos
2021-12-21 15:58 bruno-at-bareos Status new => assigned
2021-12-21 16:50 bruno-at-bareos Note Added: 0004405
2022-01-02 16:52 jalseos Note Added: 0004443
2022-01-13 14:22 pstorz Changeset attached => bareos master aa1d4726
2022-01-13 14:22 bruno-at-bareos Note Added: 0004473
2022-01-13 14:22 bruno-at-bareos Status assigned => resolved
2022-01-13 14:22 bruno-at-bareos Resolution open => fixed