Recorder mysql error show sql statements

I have some corruption, for about 5 mins the db hdd was out of space; but I think all I need to do is clean it up but the problem is I don’t know what to clean up;

2024-06-01 21:39:50.189 ERROR (Recorder) [homeassistant.components.recorder.core] SQLAlchemyError error processing task CommitTask()
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 922, in _process_one_task_or_event_or_recover
    return task.run(self)
           ^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/recorder/tasks.py", line 293, in run
    instance._commit_event_session_or_retry()
  File "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 1185, in _commit_event_session_or_retry
    self._commit_event_session()
  File "/usr/src/homeassistant/homeassistant/components/recorder/core.py", line 1211, in _commit_event_session
    session.execute(
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 2306, in execute
    return self._execute_internal(
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/orm/session.py", line 2191, in _execute_internal
    result: Result[Any] = compile_state_cls.orm_execute_statement(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/orm/bulk_persistence.py", line 1596, in orm_execute_statement
    result = _bulk_update(
             ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/orm/bulk_persistence.py", line 328, in _bulk_update
    persistence._emit_update_statements(
  File "/usr/local/lib/python3.12/site-packages/sqlalchemy/orm/persistence.py", line 948, in _emit_update_statements
    raise orm_exc.StaleDataError(
sqlalchemy.orm.exc.StaleDataError: UPDATE statement on table 'states' expected to update 5 row(s); 4 were matched.

This thread implies I can turn on the sqlalchemy debug and see the transaction log/query/statement log and see what it is trying to do;

It is lacking details, anyone know how to do this?

isn’t showing me;

found part one;

I get the statements now!

Ok and from that I was able to find the state_id;

then

DELETE from states where state_id = '315920108';

and this justremoved one record… I then restarted mysqld and hass and now my error is gone.