Skip to content

Could not lock database within 30 seconds -- prevents backup #1177

@felafel

Description

@felafel

My previous "fix" was to restart HA. That appeared to work. This has been happening for about 4 weeks off and on. It could be that my normal restarts for other integrations/addons is "fixing" this.

Description:

From SUPERVISOR logs:
[31m2025-09-07 15:02:40.126 ERROR (MainThread) [supervisor.homeassistant.module] Preparing backup of Home Assistant Core failed. Failed to inform HA Core: Unsuccessful websocket message - {'id': 2111, 'type': 'result', 'success': False, 'error': {'code': 'pre_backup_actions_failed', 'message': 'Error during pre-backup: Could not lock database within 30 seconds.'}}.[0m
[31m2025-09-07 15:02:40.132 ERROR (MainThread) [supervisor.backups.manager] Backup a5041318 error: Preparing backup of Home Assistant Core failed. Failed to inform HA Core: Unsuccessful websocket message - {'id': 2111, 'type': 'result', 'success': False, 'error': {'code': 'pre_backup_actions_failed', 'message': 'Error during pre-backup: Could not lock database within 30 seconds.'}}.[0m

Addon version: 0.112.1
Home Assistant Version: 2025.8.3
Supervisor Version: 2025.08.3
Supervisor Channel: stable
Hassos Version: 16.1
Docker Version: 28.3.3
Architecture: amd64
Machine: qemux86-64
Date: 2025-09-07T21:51:17.344636+00:00
Timezone: America/New_York
Failure Time: 2025-09-07T07:02:01.372233+00:00
Last Good Sync: 2025-09-07T21:00:35.334223+00:00
Next Sync: 2025-09-07T23:41:30.155274+00:00
Next Backup: 2025-09-10T07:02:00+00:00
Next Cache Warm: 2025-09-07T23:38:25.606673+00:00
Time Offset: 0.0

Exception:
No error could be identified automatically.

Backups:

{
   "HomeAssistant": {
       "backups": 12,
       "retained": 0,
       "deletable": 12,
       "name": "HomeAssistant",
       "title": "Home Assistant",
       "latest": "2025-09-07T19:02:10Z",
       "max": 11,
       "enabled": true,
       "icon": "home-assistant",
       "ignored": 91,
       "detail": "",
       "size": "1.7 GB",
       "ignored_size": "875.4 MB",
       "free_space": "15.8 GB"
   },
   "GoogleDrive": {
       "backups": 11,
       "retained": 0,
       "deletable": 11,
       "name": "GoogleDrive",
       "title": "Google Drive",
       "latest": "2025-09-03T19:02:21Z",
       "max": 11,
       "enabled": true,
       "icon": "google-drive",
       "ignored": 0,
       "detail": "email at gmail.com",
       "size": "1.7 GB",
       "ignored_size": "0.0 B",
       "free_space": "12.8 GB"
   }
}
Config:
{
   "Setting.MAX_BACKUPS_IN_HA": 11,
   "Setting.MAX_BACKUPS_IN_GOOGLE_DRIVE": 11,
   "Setting.BACKUP_TIME_OF_DAY": "03:02",
   "Setting.HA_REPORTING_INTERVAL_SECONDS": 1800.0
}
Addon Logs:
09-07 12:02:09 DEBUG [backup.model.syncer] Sync requested by HomeAssistant
09-07 12:02:09 INFO [backup.model.coordinator] Syncing Backups
09-07 12:02:09 DEBUG [backup.drive.driverequests] Requesting refreshed Google Drive credentials
09-07 12:02:10 INFO [backup.ha.hasource] Requesting a new backup
09-07 12:02:10 INFO [backup.watcher] A backup directory file was modified, we'll check for new backups soon.
09-07 12:02:20 DEBUG [backup.watcher] Checking backup source for changes...
09-07 12:02:41 INFO [backup.watcher] A backup directory file was modified, we'll check for new backups soon.
09-07 12:02:41 WARNING [backup.ha.hasource] A backup was already in progress
09-07 12:02:41 DEBUG [backup.model.syncer] Sync requested by HomeAssistant
09-07 12:02:41 INFO [backup.model.coordinator] Syncing Backups
09-07 12:02:51 DEBUG [backup.watcher] Checking backup source for changes...
09-07 13:59:59 DEBUG [backup.model.destinationprecache] Preemptively retrieving and caching info from the backup destination to avoid peak demand
09-07 13:59:59 DEBUG [backup.drive.driverequests] Requesting refreshed Google Drive credentials
09-07 14:07:50 DEBUG [backup.model.syncer] Sync requested by Coordinator
09-07 14:07:50 INFO [backup.model.coordinator] Syncing Backups
09-07 15:02:10 DEBUG [backup.model.syncer] Sync requested by HomeAssistant
09-07 15:02:10 INFO [backup.model.coordinator] Syncing Backups
09-07 15:02:10 DEBUG [backup.drive.driverequests] Requesting refreshed Google Drive credentials
09-07 15:02:10 INFO [backup.ha.hasource] Requesting a new backup
09-07 15:02:10 INFO [backup.watcher] A backup directory file was modified, we'll check for new backups soon.
09-07 15:02:20 DEBUG [backup.watcher] Checking backup source for changes...
09-07 15:02:40 INFO [backup.watcher] A backup directory file was modified, we'll check for new backups soon.
09-07 15:02:40 WARNING [backup.ha.hasource] A backup was already in progress
09-07 15:02:40 DEBUG [backup.model.syncer] Sync requested by HomeAssistant
09-07 15:02:40 INFO [backup.model.coordinator] Syncing Backups
09-07 15:02:50 DEBUG [backup.watcher] Checking backup source for changes...
09-07 16:50:13 DEBUG [backup.model.destinationprecache] Preemptively retrieving and caching info from the backup destination to avoid peak demand
09-07 16:50:13 DEBUG [backup.drive.driverequests] Requesting refreshed Google Drive credentials
09-07 17:00:35 DEBUG [backup.model.syncer] Sync requested by Coordinator
09-07 17:00:35 INFO [backup.model.coordinator] Syncing Backups
Supervisor Logs:
�[32m2025-09-07 16:26:22.902 INFO (MainThread) [supervisor.host.services] Updating service information�[0m
�[32m2025-09-07 16:26:22.907 INFO (MainThread) [supervisor.host.network] Updating local network information�[0m
�[32m2025-09-07 16:26:23.020 INFO (MainThread) [supervisor.host.sound] Updating PulseAudio information�[0m
�[32m2025-09-07 16:26:23.025 INFO (MainThread) [supervisor.host.manager] Host information reload completed�[0m
�[32m2025-09-07 16:45:37.881 INFO (MainThread) [supervisor.homeassistant.api] Updated Home Assistant API token�[0m
�[32m2025-09-07 17:00:35.337 INFO (MainThread) [supervisor.api.middleware.security] /supervisor/info access from cebe7a76_hassio_google_drive_backup�[0m
�[32m2025-09-07 17:00:35.340 INFO (MainThread) [supervisor.api.middleware.security] /backups access from cebe7a76_hassio_google_drive_backup�[0m
�[32m2025-09-07 17:10:49.278 INFO (MainThread) [supervisor.updater] Fetching update data from https://version.home-assistant.io/stable.json�[0m
�[32m2025-09-07 17:15:27.107 INFO (MainThread) [supervisor.resolution.check] Starting system checks with state running�[0m
�[32m2025-09-07 17:15:27.108 INFO (MainThread) [supervisor.resolution.checks.base] Run check for free_space/system�[0m
�[32m2025-09-07 17:15:27.109 INFO (MainThread) [supervisor.resolution.checks.base] Run check for disk_lifetime/system�[0m
�[32m2025-09-07 17:15:27.111 INFO (MainThread) [supervisor.resolution.checks.base] Run check for security/core�[0m
�[32m2025-09-07 17:15:27.111 INFO (MainThread) [supervisor.resolution.checks.base] Run check for multiple_data_disks/system�[0m
�[32m2025-09-07 17:15:27.111 INFO (MainThread) [supervisor.resolution.checks.base] Run check for ipv4_connection_problem/system�[0m
�[32m2025-09-07 17:15:27.111 INFO (MainThread) [supervisor.resolution.checks.base] Run check for disabled_data_disk/system�[0m
�[32m2025-09-07 17:15:27.111 INFO (MainThread) [supervisor.resolution.checks.base] Run check for trust/supervisor�[0m
�[32m2025-09-07 17:15:27.118 INFO (MainThread) [supervisor.resolution.checks.base] Run check for pwned/addon�[0m
�[32m2025-09-07 17:15:27.118 INFO (MainThread) [supervisor.resolution.checks.base] Run check for docker_config/system�[0m
�[32m2025-09-07 17:15:27.119 INFO (MainThread) [supervisor.resolution.checks.base] Run check for dns_server_ipv6_error/dns_server�[0m
�[32m2025-09-07 17:15:27.120 INFO (MainThread) [supervisor.resolution.checks.base] Run check for no_current_backup/system�[0m
�[32m2025-09-07 17:15:27.121 INFO (MainThread) [supervisor.resolution.checks.base] Run check for dns_server_failed/dns_server�[0m
�[32m2025-09-07 17:15:27.122 INFO (MainThread) [supervisor.resolution.check] System checks complete�[0m
�[32m2025-09-07 17:15:27.122 INFO (MainThread) [supervisor.resolution.evaluate] Starting system evaluation with state running�[0m
�[32m2025-09-07 17:15:27.284 INFO (MainThread) [supervisor.resolution.evaluate] System evaluation complete�[0m
�[32m2025-09-07 17:15:27.286 INFO (MainThread) [supervisor.resolution.fixup] Starting system autofix at state running�[0m
�[32m2025-09-07 17:15:27.286 INFO (MainThread) [supervisor.resolution.fixup] System autofix complete�[0m
�[32m2025-09-07 17:15:49.339 INFO (MainThread) [supervisor.homeassistant.api] Updated Home Assistant API token�[0m
�[32m2025-09-07 17:46:03.447 INFO (MainThread) [supervisor.homeassistant.api] Updated Home Assistant API token�[0m
�[32m2025-09-07 17:51:17.352 INFO (MainThread) [supervisor.api.middleware.security] /supervisor/logs access from cebe7a76_hassio_google_drive_backup�[0m

Home Assistant Core Logs:
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
       self,
       ^^^^^
   ...<4 lines>...
       conn,
       ^^^^^
   )
   ^
 File "/usr/local/lib/python3.13/site-packages/sqlalchemy/orm/bulk_persistence.py", line 1627, in orm_execute_statement
   result = _bulk_update(
       mapper,
   ...<8 lines>...
       enable_check_rowcount=enable_check_rowcount,
   )
 File "/usr/local/lib/python3.13/site-packages/sqlalchemy/orm/bulk_persistence.py", line 357, in _bulk_update
   persistence._emit_update_statements(
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^
       base_mapper,
       ^^^^^^^^^^^^
   ...<6 lines>...
       enable_check_rowcount=enable_check_rowcount,
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   )
   ^
 File "/usr/local/lib/python3.13/site-packages/sqlalchemy/orm/persistence.py", line 948, in _emit_update_statements
   raise orm_exc.StaleDataError(
   ...<3 lines>...
   )
sqlalchemy.orm.exc.StaleDataError: UPDATE statement on table 'states' expected to update 4 row(s); 3 were matched.[0m

Thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions