Skip to content

[Bug]: Defguard does not automatically restart after DB goes down #2368

@OoYo0uto

Description

@OoYo0uto

Summary

After our postgres database was shutdown for unattended upgrades, defguard terminated and did not automatically start again.

Steps to reproduce

  1. Terminate the database defguard is configured to use
  2. Wait for a periodic task which tries to do something in the database (lke the stats purge or the peer disconnect)
  3. Defguard terminates with a exit code 0.

Expected behavior

We expected that Defguard returns a non-zero exit code and that systemd therefore automatically starts again in such a case (the provided systemd unit has Restart=on-failure defined).

Actual behavior

After our postgres database was shutdown for unattended upgrades, defguard terminated and did not automatically start again.

Defguard version

Core: v1.6.1

Environment details

Debian 13

Deployment / install method

Standalone packages

Relevant logs / output

defguard.service: Deactivated successfully. 
2026-03-15T05:33:23.527348Z ERROR defguard: message=Periodic peer disconnect task returned early: Err(DbError(Database(PgDatabaseError { severity: Fatal, code: "57P01", message: "terminating connection due to administrator command", detail: None, hint: None, position: None, where: None, schema: None, table: None, column: None, data_type: None, constraint: None, file: Some("postgres.c"), line: Some(3315), routine: Some("ProcessInterrupts") }))) [1.6.1+d810a59 Debian 13.0.0 x86_64] 
2026-03-15T05:33:23.485862Z ERROR run_utility_thread: defguard_core::utility_thread: message=There was an error while performing directory sync job: DbError(Io(Custom { kind: UnexpectedEof, error: "expected to read 5 bytes, got 0 bytes at EOF" })) [1.6.1+d810a59 Debian 13.0.0 x86_64]

Relevant configuration (redacted)

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No fields configured for Bug.

Projects

Status

Ready to release

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions