Skip to content
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

Recorder limits event type to 32 chars, core does not, causes crash in recorder #16074

Closed
dlashua opened this issue Aug 20, 2018 · 8 comments
Closed

Comments

@dlashua
Copy link
Contributor

dlashua commented Aug 20, 2018

Home Assistant release with the issue:
0.76.0

Last working Home Assistant release (if known):
??

Operating environment (Hass.io/Docker/Windows/etc.):
Ubuntu venv

Component/platform:
recorder / mysql

Description of problem:
Home Assistant allows events to fire with event_type longer than VARCHAR(32). However, the MySQL table structure created by Home Assistant doesn't support it.

Once the error (see below) is thrown, recorder stops updating records entirely until Home Assistant is restarted.

  1. Code limits need to be put in place to limit the length of an event_type. Or, MySQL queries should shorten that field before inserting. Additionally, recorder component should catch the error and allow future updates to continue, instead of dying until the next restart.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

recorder:
  purge_interval: 1
  purge_keep_days: 42
  exclude:
    domains:
      - media_player
      - camera
  db_url: !secret mysql_db_url

Traceback (if applicable):

Aug 19 13:05:11 maverick hass[20390]: 2018-08-19 13:05:11 ERROR (Recorder) [homeassistant.components.recorder.util] Error executing query: (_mysql_exceptions.DataError) (1406, "Data too l
ong for column 'event_type' at row 1") [SQL: 'INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id) VALUES (%s, %s, %s, %s, %s, %s, %s)'] [
parameters: ('device_tracker.life360_update_overdue', '{"entity_id": "device_tracker.celeste_xxxxxx_xxxxxx"}', 'LOCAL', datetime.datetime(2018, 8, 19, 18, 5, 10, 991876, tzinfo=<UTC>), da
tetime.datetime(2018, 8, 19, 18, 5, 11, 1865), '3440540872d84e4a82894fa4b3170e10', None)] (Background on this error at: http://sqlalche.me/e/9h9h)

Additional information:
I've since upgrades to 0.76.1. The problem may be corrected in that version. I'm not sure because I altered the MySQL table to be a VARCHAR(64) in order to stop this error from happening.

@balloob balloob changed the title mysql recorder Recorder limits event type to 32 chars, core does not, causes crash in recorder Aug 21, 2018
@sagilo
Copy link

sagilo commented Sep 12, 2018

Still happens. version 0.77.3

sagilo added a commit to sagilo/home-assistant-1 that referenced this issue Sep 12, 2018
@ghost ghost added the in progress label Sep 12, 2018
sagilo added a commit to sagilo/home-assistant-1 that referenced this issue Sep 12, 2018
sagilo added a commit to sagilo/home-assistant-1 that referenced this issue Sep 12, 2018
sagilo added a commit to sagilo/home-assistant-1 that referenced this issue Sep 12, 2018
@balloobbot
Copy link

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.

Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍

@ziptbm
Copy link

ziptbm commented Dec 31, 2018

I'm seeing this as well in 0.84.6.

Is this the preferred workaround changing the column size? Or will something be changing on the HA side?

@sagilo
Copy link

sagilo commented Dec 31, 2018

I'm seeing this as well in 0.84.6.

Is this the preferred workaround changing the column size? Or will something be changing on the HA side?
I've created a fix as you can see but it will only fix future configurations.
You'll have to alter the column type manually to fix this on your current configuration.

@ziptbm
Copy link

ziptbm commented Dec 31, 2018 via email

@sagilo
Copy link

sagilo commented Dec 31, 2018

@ziptbm, I've updated the PR to have manual fix instructions for existing configurations
#19670

@stale
Copy link

stale bot commented Jul 7, 2019

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates.
Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍
This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale label Jul 7, 2019
@stale stale bot closed this as completed Jul 14, 2019
@basnijholt
Copy link
Contributor

This still seems like it's an issue, see #15984 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment