Files
teleport/lib/backend
rosstimothy ebd8bcafea Improve closure of sqlite backend (#63828)
The lifetime of `runPeriodicOperations` was only loosely tied to
the lite.Backend via lite.Backend.ctx. When closing the backend
the context was cancelled which would eventually terminate
`runPeriodicOperations`. However, `lite.Backend.Close` could return
while `runPeriodicOperations` was still processing as a result
of the periodic ticker firing. To prevent this race the backend
now utilizies a sync.WaitGroup to launch `runPeriodicOperations`
and waits for the group to be completed _prior_ to returning from
`(lite.Backend) Close`.

`runPeriodicOperations` also attempted to close the sql.DB when it
detected that the context had been cancelled. While the double close
is fine due to the idempotence of (lite.Backed) closeDatabase, it
was confusing and unnecesarry. Ownership of closing the database now
lies exclusively on explicitly calling `(lite.Backend) Close`.

The closed flag has also been removed. It existed solely to prevent
logging or rolling back transactions that had failed after the
underlying database had been closed. Both operations are always attempted
now. All logs are silenced in the event that the database is unreachable
during process termination.

On failure to create the database schema the underlying sqlite database
is now closed before returning an error from lite.NewWithConfig.
2026-02-18 13:51:36 +00:00
..
2025-07-15 18:11:10 +00:00
2025-06-27 18:16:44 +00:00
2025-06-27 18:16:44 +00:00
2025-06-27 18:16:44 +00:00