Baza Danych MariaDB zamrożona

od jakiegoś czasu zaobserowałem zamrażanie bazy danych MariaDB - brak zbieranych danych. na screnach widać że dane przestały być zbierane w historii, zarówno zwykłe encje jak i energia. wyszło podczas kontroli Watchdoga z PLC. dostawałem powiadomienia o braku połączenia z PLC mimo że zmienna się pięknie zmieniała (10sec TRUE, 10sec FALSE…) jednak w historii pusto…
na wykresach widać że linie zostają zamrożone i tak trwają do restartu HA, przy zakładce energia widac brak zmieranych danych i nagle bum - zebrało wszystko z paru godzin gdy nie działała baza danych… pomaga tylko restart HA.
niestety nie znalazłem encji z aktualnego stanu MariaDB - może ktoś coś ?

mariaDB_frozen1


image

Domyślnie są wyłączone.
Dodaj również sobie addon phpMyAdmin

ooo super trop:) - dzięki za podpowiedź - szukałem w integracjach i encjach a tu niespodzianka… jest w urządzeniach heh. aktywuje i będę pilnował dalej.
dzięki !!

Niestety okazuje się że MariaDB dalej działa bez błędu… to jak by sam RECORDER coś przestał nagrywać…
image
dziś pojawił się taki błąd:
image

efekt jest taki że niby wszystko działa. sygnały się pojawiają jak trzeba … tylko dane do bazy danych się nie zapisują :frowning: wykresy wtedy zostają jak by zamrożone (ta ciągła linia)
restart HA i wszystko wraca do normy … na jakiś czas.
image

A jak z miejscem na dysku ?

dysk z zapasem, baza danych się ładnie zmniejsza o planowanej 4 rano więc tutaj stabilnie…

image

@murcin pytanko mam o Twoją kartę z danymi. Podoba mi się. Te wskaźniki sensorów masz w różnych kolorach. Jak to zrobiłeś? I to, co masz w drugiej linii, to użycie dysków? Fajne.

Podpowiem trochę w zastępstwie - prawdopodobnie wykorzystane karty
vertical-stack i grid, (ewentualnie może to być np. kombinacja z horizontal-stack albo bodajże custom:button?) oraz custom:mini-graph-card,
a użycie dysków wygląda na custom:bar-card

u mnie coś takiego

powstaje w ten sposób

type: vertical-stack
cards:
  - type: grid
    title: Airly Mińska 5 dni
    cards:
      - type: custom:mini-graph-card
        name: Temperatura
        group: true
        entities:
          - sensor.airly_minska_temperature
        line_color: '#e74c3c'
        line_width: 8
        font_size: 75
        hours_to_show: 120
      - type: custom:mini-graph-card
        name: Wilgotność
        group: true
        entities:
          - sensor.airly_minska_humidity
        line_color: blue
        line_width: 8
        font_size: 75
        hours_to_show: 120
      - type: custom:mini-graph-card
        name: Ciśnienie
        group: true
        entities:
          - sensor.airly_minska_pressure
        line_color: green
        line_width: 8
        font_size: 75
        hours_to_show: 120
      - type: custom:mini-graph-card
        name: Pyły
        icon: mdi:blur
        group: true
        entities:
          - entity: sensor.airly_minska_pm1
            name: PM1
          - entity: sensor.owm_pollution_fine_particles_pm2_5
            name: PM2.5
          - entity: sensor.owm_pollution_coarse_particles_pm10
            name: PM10
        line_color:
          - brown
          - red
          - orange
        line_width: 8
        font_size: 75
        hours_to_show: 120
      - type: custom:mini-graph-card
        name: Indeks AQI
        icon: mdi:chart-line
        group: true
        entities:
          - sensor.u_s_air_quality_index
        line_color: black
        line_width: 8
        font_size: 75
        hours_to_show: 120
      - type: custom:mini-graph-card
        name: Indeks POAQ
        group: true
        entities:
          - sensor.owm_pollution_overall_air_quality
          - sensor.waqi_wroclaw_wroclaw_korzeniowskiego_poland
          - sensor.waqi_wroclaw_wroclaw_wisniowa_poland
        line_color:
          - lightgray
          - gray
          - black
        line_width: 8
        font_size: 75
        hours_to_show: 120
    columns: 2
    square: false
  - type: custom:apexcharts-card
    graph_span: 7d
    header:
      show: true
      title: 7 dni pyłki drzew
      show_states: false
      colorize_states: true
      floating: false
    chart_type: line
    all_series_config:
      attribute: value
      transform: 'return x === "null" ? 0 : x;'
      fill_raw: zero
      extend_to_end: true
      curve: smooth
      group_by:
        func: avg
        duration: 48h
    series:
      - entity: sensor.stezenie_brzoza
      - entity: sensor.stezenie_buk
      - entity: sensor.stezenie_cis
      - entity: sensor.stezenie_dab
      - entity: sensor.stezenie_grab
      - entity: sensor.stezenie_jesion
      - entity: sensor.stezenie_klon
      - entity: sensor.stezenie_leszczyna
      - entity: sensor.stezenie_olsza
      - entity: sensor.stezenie_platan
      - entity: sensor.stezenie_sosna
      - entity: sensor.stezenie_topola
      - entity: sensor.stezenie_wierzba
      - entity: sensor.stezenie_wiaz
  - type: custom:apexcharts-card
    graph_span: 7d
    header:
      show: true
      title: 7 dni pyłki traw, grzybów i roślin zielnych
      show_states: false
      colorize_states: true
      floating: false
    chart_type: line
    all_series_config:
      attribute: value
      transform: 'return x === "null" ? 0 : x;'
      fill_raw: zero
      extend_to_end: true
      group_by:
        func: avg
        duration: 48h
    series:
      - entity: sensor.stezenie_nawloc
      - entity: sensor.stezenie_trawy
      - entity: sensor.stezenie_alternaria
      - entity: sensor.stezenie_cladosporium
      - entity: sensor.stezenie_ambrozja
      - entity: sensor.stezenie_babka
      - entity: sensor.stezenie_bylica
      - entity: sensor.stezenie_komosa
      - entity: sensor.stezenie_pokrzywa
      - entity: sensor.stezenie_szczaw

@szopen dzięki. Tak to wygląda, więc pewnie to zastosuje. Jeszcze kombinuję z pobraniem wielkości bazy danych. Mam na MariaDB, ale to zapytanie co jest w poście w bazie wiedzy, do sprawdzania, nie daje mi wyniku. Nie wiem dlaczego.

sensor:
  - platform: sql
    db_url: mysql://user:password@localhost/hass
    queries:
      - name: DB size
        query: 'SELECT table_schema "database", Round(Sum(data_length + index_length) / 1024, 1) "value" FROM information_schema.tables WHERE table_schema="hass" GROUP BY table_schema;'
        column: "value"
        unit_of_measurement: kB
1 polubienie

Poniżej przeliczenie na MB:

- platform: sql
  db_url: mysql://user:hasło@core-mariadb/homeassistant?charset=utf8
  queries:
    - name: 'DataBase rozmiar'
      query: 'SELECT table_schema "database", Round(Sum(data_length + index_length) / 1024 / 1024, 1) "value" FROM information_schema.tables WHERE table_schema="homeassistant" GROUP BY table_schema;'
      column: 'value'
      unit_of_measurement: MB

temat oczywiście zszedł na bok ale nie ma problemu z podzieleniem się kodem :slight_smile:
trzy części ubrane w całość jako
type: vertical-stack

cards:
  - entities:
      - color: yellow
        entity: sensor.processor_use
    animate: true
    lower_bound: 0
    upper_bound: 100
    hours_to_show: 24
    line_width: 3
    name: Procesor
    points_per_hour: 6
    type: custom:mini-graph-card
  - entities:
      - color: green
        entity: sensor.memory_use_percent
    animate: true
    lower_bound: 0
    upper_bound: 100
    hours_to_show: 24
    line_width: 3
    name: Pamięć
    points_per_hour: 6
    type: custom:mini-graph-card
  - entities:
      - color: red
        entity: sensor.disk_use_percent
    animate: true
    lower_bound: 0
    upper_bound: 100
    hours_to_show: 24
    line_width: 3
    name: Dysk
    points_per_hour: 6
    type: custom:mini-graph-card
type: horizontal-stack

cards:
  - entities:
      - entity: sensor.disk_use
    max: '20'
    type: custom:bar-card
  - entities:
      - entity: sensor.disk_free
    max: '30'
    type: custom:bar-card
type: horizontal-stack

cards:
  - entities:
      - color: yellow
        entity: sensor.home_assistant_v2_db
    animate: true
    hours_to_show: 24
    line_width: 3
    name: plik DB
    points_per_hour: 6
    show:
      labels: true
    type: custom:mini-graph-card
  - entities:
      - color: green
        entity: sensor.database_rozmiar
    animate: true
    hours_to_show: 24
    line_width: 3
    name: MariaDB
    points_per_hour: 6
    show:
      labels: true
    type: custom:mini-graph-card
  - entities:
      - color: red
        entity: sensor.home_assistant_log
    animate: true
    hours_to_show: 24
    line_width: 3
    name: Log
    points_per_hour: 6
    show:
      labels: true
    type: custom:mini-graph-card
type: horizontal-stack

po zaniku napiecia, proxmox z HA wstał uruchomił sie sam ,ale mam problem z baza danych mariaDB,nie zbiera danych,jest taki bład jakiś sugestie
2021-12-19 16:17:54 ERROR (Recorder) [homeassistant.components.recorder] Database connection invalidated: Error executing query: (MySQLdb._exceptions.OperationalError) (1927, ‘Connection was killed’)
[SQL: INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id, context_parent_id) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)]
[parameters: (‘state_changed’, ‘{}’, ‘LOCAL’, datetime.datetime(2021, 12, 19, 15, 17, 53, 143260, tzinfo=datetime.timezone.utc), datetime.datetime(2021, 12, 19, 15, 17, 53, 143260, tzinfo=datetime.timezone.utc), ‘dbf64bc3d93dd6d86d6842222a0f48e8’, None, None)]
(Background on this error at: Error Messages — SQLAlchemy 1.4 Documentation). (retrying in 3 seconds)
2021-12-19 16:17:57 ERROR (Recorder) [homeassistant.components.recorder] SQLAlchemyError error processing event <Event time_changed[L]: now=2021-12-19T16:17:54.001698+01:00>: This Session’s transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (MySQLdb._exceptions.OperationalError) (1927, ‘Connection was killed’)
[SQL: INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id, context_parent_id) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)]
[parameters: (‘state_changed’, ‘{}’, ‘LOCAL’, datetime.datetime(2021, 12, 19, 15, 17, 53, 143260, tzinfo=datetime.timezone.utc), datetime.datetime(2021, 12, 19, 15, 17, 53, 143260, tzinfo=datetime.timezone.utc), ‘dbf64bc3d93dd6d86d6842222a0f48e8’, None, None)]
(Background on this error at: Error Messages — SQLAlchemy 1.4 Documentation) (Background on this error at: Error Messages — SQLAlchemy 1.4 Documentation)
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/recorder/init.py”, line 707, in _process_one_event_or_recover
self._process_one_event(event)
File “/usr/src/homeassistant/homeassistant/components/recorder/init.py”, line 874, in _process_one_event
self._commit_event_session_or_retry()
File “/usr/src/homeassistant/homeassistant/components/recorder/init.py”, line 937, in _commit_event_session_or_retry
self._commit_event_session()
File “/usr/src/homeassistant/homeassistant/components/recorder/init.py”, line 963, in _commit_event_session
self.event_session.commit()
File “/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py”, line 1428, in commit
self._transaction.commit(_to_root=self.future)
File “/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py”, line 827, in commit
self._assert_active(prepared_ok=True)
File “/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py”, line 601, in _assert_active
raise sa_exc.PendingRollbackError(
sqlalchemy.exc.PendingRollbackError: This Session’s transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (MySQLdb._exceptions.OperationalError) (1927, ‘Connection was killed’)
[SQL: INSERT INTO events (event_type, event_data, origin, time_fired, created, context_id, context_user_id, context_parent_id) VALUES (%s, %s, %s, %s, %s, %s, %s, %s)]
[parameters: (‘state_changed’, ‘{}’, ‘LOCAL’, datetime.datetime(2021, 12, 19, 15, 17, 53, 143260, tzinfo=datetime.timezone.utc), datetime.datetime(2021, 12, 19, 15, 17, 53, 143260, tzinfo=datetime.timezone.utc), ‘dbf64bc3d93dd6d86d6842222a0f48e8’, None, None)]
(Background on this error at: Error Messages — SQLAlchemy 1.4 Documentation) (Background on this error at: Error Messages — SQLAlchemy 1.4 Documentation)
2021-12-19 16:18:03 ERROR (Recorder) [homeassistant.components.recorder] Error in database connectivity during commit: Error executing query: (MySQLdb._exceptions.OperationalError) (2002, “Can’t connect to MySQL server on ‘core-mariadb’ (115)”)
(Background on this error at: Error Messages — SQLAlchemy 1.4 Documentation). (retrying in 3 seconds)
2021-12-19 16:18:04 ERROR (SyncWorker_7) [homeassistant.components.sql.sensor] Error executing query SELECT table_schema “database”, Round(Sum(data_length + index_length) / 1024 / 1024, 1) “value” FROM information_schema.tables WHERE table_schema=“homeassistant” GROUP BY table_schema LIMIT 1;: (MySQLdb._exceptions.OperationalError) (1927, ‘Connection was killed’)
[SQL: SELECT table_schema “database”, Round(Sum(data_length + index_length) / 1024 / 1024, 1) “value” FROM information_schema.tables WHERE table_schema=“homeassistant” GROUP BY table_schema LIMIT 1;]
(Background on this error at: Error Messages — SQLAlchemy 1.4 Documentation)
2021-12-19 16:18:06 ERROR (Recorder) [homeassistant.components.recorder] SQLAlchemyError error processing event <Event time_changed[L]: now=2021-12-19T16:18:00.004217+01:00>: This Session’s transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (MySQLdb._exceptions.OperationalError) (2002, “Can’t connect to MySQL server on ‘core-mariadb’ (115)”)
(Background on this error at: Error Messages — SQLAlchemy 1.4 Documentation) (Background on this error at: Error Messages — SQLAlchemy 1.4 Documentation)
Traceback (most recent call last):
File “/usr/src/homeassistant/homeassistant/components/recorder/init.py”, line 707, in _process_one_event_or_recover
self._process_one_event(event)
File “/usr/src/homeassistant/homeassistant/components/recorder/init.py”, line 874, in _process_one_event
self._commit_event_session_or_retry()
File “/usr/src/homeassistant/homeassistant/components/recorder/init.py”, line 937, in _commit_event_session_or_retry
self._commit_event_session()
File “/usr/src/homeassistant/homeassistant/components/recorder/init.py”, line 963, in _commit_event_session
self.event_session.commit()
File “/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py”, line 1428, in commit
self._transaction.commit(_to_root=self.future)
File “/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py”, line 827, in commit
self._assert_active(prepared_ok=True)
File “/usr/local/lib/python3.9/site-packages/sqlalchemy/orm/session.py”, line 601, in _assert_active
raise sa_exc.PendingRollbackError(
sqlalchemy.exc.PendingRollbackError: This Session’s transaction has been rolled back due to a previous exception during flush. To begin a new transaction with this Session, first issue Session.rollback(). Original exception was: (MySQLdb._exceptions.OperationalError) (2002, “Can’t connect to MySQL server on ‘core-mariadb’ (115)”)
(Background on this error at: Error Messages — SQLAlchemy 1.4 Documentation) (Background on this error at: Error Messages — SQLAlchemy 1.4 Documentation)
2021-12-19 16:18:14 ERROR (MainThread) [bosch_thermostat_client.helper] Can’t update data for Pool temperature. Trying uri: /heatSources/poolTemperature. Error message: URI /heatSources/poolTemperature doesn not exist: 404, message=‘Not Found’, url=URL(‘http://10.3.3.190/heatSources/poolTemperature’)

spróbuj ponownie uruchomić sam HomeAssistant - u mnie jedynie to pomaga… jak tracę właśnie zapis do bazy danych następuje brak zapisuj i wtedy restart i wraca. niestety nie znalazłem przyczyny :frowning:

Niestety nie.pomaga.Nie wiem jak to rozwiązać.

to spróbuj odinstalować i zainstalować ponownie - wyczyści wtedy konfigurację ale może pomoże :slight_smile:

Wyżej masz sposób na “postawienie” bazy od nowa. Tylko starcisz starą bazę.
P.S.
Pomyśl nad kupnem ups-a

Tak wiem że tak można, ale nie chciałabym np .po pół roku używania HA czegoś takiego robić, to ostatecznosc.
Jest jeszcze jedna dziwna sytuacja baza danych nie zbierała danych cały dzień i noc nagle plik bazy wzrósł o 100Mb i teraz dalej się powiększa więc chyba ruszyło tylko że ja nic nie robiłem. Dziwna sytuacja.Brak też wcześniejszych błędów.

Tak jak pisałem wyżej, zabezpiecz Swoją instalację na okoliczność utraty/spadku zasilania.

Już jest UPS, dzisiaj muszę to podłączyć, Zadam wam pewnie dla niektórych smieszne pytanie jak bezpiecznie wyłączyć HA?W “system” nie mam opcji wyłącz, tylko uruchom ponownie