Skip to content

Don't write storage to disk while stopping#33456

Merged
balloob merged 12 commits intohome-assistant:devfrom
dmulcahey:dm/dont-write-storage-while-stopping
Apr 2, 2020
Merged

Don't write storage to disk while stopping#33456
balloob merged 12 commits intohome-assistant:devfrom
dmulcahey:dm/dont-write-storage-while-stopping

Conversation

@dmulcahey
Copy link
Copy Markdown
Contributor

@dmulcahey dmulcahey commented Mar 31, 2020

Proposed change

This PR is a follow up to #33358 specifically this comment: #33358 (comment). The PR prevents storage from being written to disk while the HA state is CoreState.stopping. The changes account for 3 scenarios:

  1. A delayed save is issued before HA stop event has fired and subsequently HA is stopped before the delay kicks in to issue the write
  2. A delayed save is issued after HA stop event has fired
  3. A save is issued after HA stop event has fired

In all of these scenarios the data is held in memory and written when HA is in the final_write state.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Example entry for configuration.yaml:

# Example configuration.yaml

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • Untested files have been added to .coveragerc.

The integration reached or maintains the following Integration Quality Scale:

  • No score or internal
  • 🥈 Silver
  • 🥇 Gold
  • 🏆 Platinum

@dmulcahey
Copy link
Copy Markdown
Contributor Author

I’ll look at the failure some more in the morning. I think there just needs to be a guard in the write data method...

Comment thread homeassistant/helpers/storage.py Outdated
@dmulcahey dmulcahey force-pushed the dm/dont-write-storage-while-stopping branch from 8627ca8 to cfb0754 Compare March 31, 2020 11:49
Comment thread homeassistant/helpers/storage.py Outdated
Comment thread homeassistant/helpers/storage.py Outdated
Comment thread homeassistant/helpers/storage.py Outdated
@dmulcahey dmulcahey force-pushed the dm/dont-write-storage-while-stopping branch from ac56ca7 to 1498290 Compare March 31, 2020 22:23
Comment thread homeassistant/helpers/storage.py Outdated
@dmulcahey dmulcahey force-pushed the dm/dont-write-storage-while-stopping branch from 5f8300e to e3eb823 Compare April 1, 2020 16:27
@dmulcahey dmulcahey force-pushed the dm/dont-write-storage-while-stopping branch from 8752733 to 498d8cb Compare April 2, 2020 00:16
@balloob balloob merged commit 8b0a0ee into home-assistant:dev Apr 2, 2020
@bdraco bdraco mentioned this pull request Apr 2, 2020
20 tasks
@lock lock Bot locked and limited conversation to collaborators Apr 4, 2020
@dmulcahey dmulcahey deleted the dm/dont-write-storage-while-stopping branch April 4, 2020 13:34
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants