mirror of
https://github.com/advplyr/audiobookshelf.git
synced 2026-08-03 15:11:44 +00:00
add timeout to postgres backup commands
Kill pg_dump/pg_restore after 30 minutes so a lock wait cannot hang a backup or leave the server disconnected from its database during a restore. A killed restore rolls back via --single-transaction.
This commit is contained in:
parent
c8f753c58c
commit
dedbe57b0c
2 changed files with 3 additions and 0 deletions
|
|
@ -657,6 +657,8 @@ class BackupManager {
|
|||
|
||||
const options = {
|
||||
maxBuffer: 10 * 1024 * 1024,
|
||||
// Kill after 30 mins (e.g. lock waits) - a killed restore rolls back via --single-transaction
|
||||
timeout: 30 * 60 * 1000,
|
||||
env: connection.env
|
||||
}
|
||||
childProcess.execFile(command, [...args, ...connection.args], options, (error, stdout, stderr) => {
|
||||
|
|
|
|||
|
|
@ -76,6 +76,7 @@ describe('BackupManager', () => {
|
|||
])
|
||||
expect(execFileStub.firstCall.args[1].join(' ')).to.not.include('secretpass')
|
||||
expect(execFileStub.firstCall.args[2].env.PGPASSWORD).to.equal('secretpass')
|
||||
expect(execFileStub.firstCall.args[2].timeout).to.be.a('number')
|
||||
})
|
||||
|
||||
it('should restore Postgres dumps in one transaction and clean existing objects', async () => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue