-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent endless loop in recorder when using a filter and there are no more states to purge #126149
Prevent endless loop in recorder when using a filter and there are no more states to purge #126149
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @davinkevin
It seems you haven't yet signed a CLA. Please do so here.
Once you do that we will be able to review and accept this pull request.
Thanks!
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
382d2e7
to
c4b53c3
Compare
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
Up? |
This change makes sense
I think this is good to merge once we get a test for it |
FYI, I'm not the best to write python code. This contribution is the result of an issue I ha[d|ve]. tldr; if someone can write the test, it would be welcome. |
… more states to purge (#126149) Co-authored-by: J. Nick Koston <[email protected]>
Proposed change
After investigation for #124994, I found a situation where the
recorder
is stuck in a loop. I suspect a misunderstanding in the code related to variables names and expectations from methodsTo summarize, in
purge.py
, we have:With a
_purge_filtered_data
definition (simplified):The problem in my case is the
_purge_filtered_states
always returnsTrue
, but when we look at its implementation/description, we can see the following:This function returns
True
if "all states are purged", however the calling function assign that value tohas_more_states_to_purge
value… which is literally the opposite.The same applies to the
_purge_filtered_events
function later in that function.I just introduced a
not
operator to invert the value. If the purge is complete, thenhas_more_*****_to_purge
will be false; so the following code can stay like this.Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: