Failed to begin transaction: context deadline exceeded

Hello,

we are getting the error “failed to begin transaction: context deadline exceeded” while running the below commands sometimes.

lxc storage volume set default vmname size 45000MB
lxc config set vmname limits.processes 5000
lxc config set vmname limits.cpu.allowance 10%

can you please help me on this.

This usually indicates that you have a very high commit latency on your database, effectively that creating a new DB transaction took over 3s.

I’d recommend checking that none of your servers are overloaded (especially those with the database or database-leader roles in lxc cluster list if on a cluster) and having a close look at I/O performance since this most likely indicates that a disk write couldn’t be completed in that time frame.

thanks for the update. we have also noticed the below error with the mentioned commands.

Error: Failed to write backup file: failed to begin transaction: context deadline exceeded

any help @stgraber

Same answer, it suggests one of your machine is unable to perform timely I/O.

I’d recommend looking at your monitoring system for I/O performance issues on the systems as well as potential disk or memory starvation.

today we have faced the same issue. i have checked our monitoring system and couldn’t see any peak in the I/O and the load of the server is normal.

any help @stgraber

It’s not LXC/LXD issue, it’s your hardware issue. No one here can help you with that… as @stgraber already pointed out.

For fun of it, post screenshots of ‘top’ and ‘iotop’

effectively that creating a new DB transaction took over 3s

if this is the case,for avoiding the error

Error: Failed to write backup file: failed to begin transaction: context deadline exceeded

can you please suggest a solution for this case?

Hello,

we have getting the below error in the logs at the time the issue faced.

Feb 18 09:22:10 cpu-6257 lxd[3179]: t=2022-02-18T09:22:10+0100 lvl=warn msg="Transaction timed out. Retrying once" err="failed to begin transaction: context deadline exceeded" member=1
Feb 18 09:22:11 cpu-6257 lxd[3179]: t=2022-02-18T09:22:11+0100 lvl=warn msg="Transaction timed out. Retrying once" err="failed to begin transaction: context deadline exceeded" member=1
Feb 18 09:22:12 cpu-6257 lxd[3179]: t=2022-02-18T09:22:12+0100 lvl=warn msg="Transaction timed out. Retrying once" err="failed to begin transaction: context deadline exceeded" member=1

@stgraber any idea on this

Is this a cluster?

Hello,

not a cluster

Then this strongly suggests some sort of load on your CPU or storage subsystem causing the database to not respond quickly enough.