vierbergenlars / bareos_exporter

MIT License
12 stars 7 forks source link

Lots of sql: Scan error in logs #9

Closed karlism closed 3 years ago

karlism commented 3 years ago

I'm running BareOS exporter with BareOS 20.0.1 and PostgreSQL 13 and BareOS exporter produces lots of following errors:

Jun 30 23:29:24 backup1 bareos_exporter[21509]: time="2021-06-30T23:29:24Z" level=error msg="sql: Scan error on column index 4, name \"expired\": sql/driver: couldn't convert <nil> (<nil>) into type bool" method=PoolInfo
Jun 30 23:29:42 backup1 bareos_exporter[21509]: time="2021-06-30T23:29:42Z" level=error msg="sql: Scan error on column index 4, name \"expired\": sql/driver: couldn't convert <nil> (<nil>) into type bool" method=PoolInfo

These errors only appear in logs when there are active backup jobs running.

Latest BareOS exporter is used with following flags:

/usr/bin/bareos_exporter -dsn=postgres://user bareos password=XXX host=127.0.0.1 dbname=bareos sslmode=disable
vierbergenlars commented 3 years ago

Can you take a look at what the actual values in the database are at the time that the errors occur?

I'm guessing one of them is NULL, but I don't know which one, and I don't have such a recent bareos director to test with.

Can you check with the following SQL query, and verify that expired is only NULL for newly created volumes that are being written to?

SELECT m.volumename, m.lastwritten, m.volretention, (m.lastwritten + (m.volretention * interval '1s')) < NOW() as expired FROM media m

karlism commented 3 years ago

@vierbergenlars, thanks for looking into this. During backup there is entry in database that has empty lastwritten and expired fields:

bareos=# SELECT m.volumename, m.lastwritten, m.volretention, (m.lastwritten + (m.volretention * interval '1s')) < NOW() as expired FROM media m;
        volumename        |     lastwritten     | volretention | expired 
--------------------------+---------------------+--------------+---------
 FullSQL-0004             | 2021-06-24 08:03:20 |      2592000 | f
[...]
 IncrementalExchange-0072 |                     |      1209600 | 
[...]
vierbergenlars commented 3 years ago

Yes, that explains why expired becomes NULLas well.

I'll see to make expired false instead of null, because those new volumes are can never already be expired.

karlism commented 3 years ago

Thanks! It looks like errors are gone after an update to 0.5.7.