thingsboard / thingsboard-edge

Apache License 2.0
98 stars 74 forks source link

[Question] How to migrate to tb-edge v3.4.3? #42

Closed AndreMaz closed 1 year ago

AndreMaz commented 1 year ago

Component

Description I'm having trouble migrating my TB-edge instance to v3.4.3. The upgrade-tb-edge.sh @ 3.4.3 the script fails because it tries to migrate from 3.4.2 which does not exist in Docker registry (Link https://hub.docker.com/r/thingsboard/tb-edge/tags)

NOT runningupgrade-tb-edge.sh @ 3.4.3 produces the following error:

tb-edge org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [tb_user_email_key]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement

Note: Migration to v3.4.1 worked fine and everything seems to be working.

Environment

volodymyr-babak commented 1 year ago

@AndreMaz

could you please try to upgrade your Edge component using these instructions? https://thingsboard.io/docs/user-guide/install/edge/upgrade-instructions/#docker-linux-mac-343

AndreMaz commented 1 year ago

Hi @volodymyr-babak

Here's what I get for the following docker compose file Docker compose:

version: '3.0'
services:
  tb-edge:
    restart: on-failure
    image: "thingsboard/tb-edge:3.4.3EDGE"
    environment:
      SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/tb-edge
    volumes:
      - tb-data:/data
      - tb-logs:/var/log/tb-edge
    entrypoint: upgrade-tb-edge.sh

Logs

tb-edge Starting ThingsBoard Edge upgrade ... tb-edge =================================================== tb-edge :: ThingsBoard Edge CE :: (v3.4.3EDGE) tb-edge =================================================== tb-edge
tb-edge Starting ThingsBoard Edge Upgrade from version 3.4.2 ... tb-edge Clearing cache to upgrade from version 3.4.2 to 3.4.3 ... tb-edge Clearing cache [repositorySettings] tb-edge Unexpected error during ThingsBoard Edge installation! tb-edge java.lang.RuntimeException: Unable to upgrade ThingsBoard Edge, unsupported fromVersion: 3.4.2 tb-edge at org.thingsboard.server.install.ThingsboardInstallService.performInstall(ThingsboardInstallService.java:252) tb-edge at org.thingsboard.server.TbEdgeInstallApplication.main(TbEdgeInstallApplication.java:49) tb-edge at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) tb-edge at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) tb-edge at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) tb-edge at java.base/java.lang.reflect.Method.invoke(Method.java:566) tb-edge at org.springframework.boot.loader.MainMethodRunner.run(MainMethodRunner.java:49) tb-edge at org.springframework.boot.loader.Launcher.launch(Launcher.java:108) tb-edge at org.springframework.boot.loader.Launcher.launch(Launcher.java:58) tb-edge at org.springframework.boot.loader.PropertiesLauncher.main(PropertiesLauncher.java:467) tb-edge Unexpected error during ThingsBoard Edge installation!

volodymyr-babak commented 1 year ago

@AndreMaz

COMMENT BELOW IS INCORRECT. UPGRADE FROM 3.4.1 to 3.4.3 REQUIRES UPGRADE STEP

_sorry for inconveniences. There is indeed issue in the upgrade file. But you can skip this upgrade step. Please simply update your main docker-compose.yml file and set TB edge version to 3.4.3: image

So please skip upgrade step and it should work. I'm going to update docs soon and remove this step._

AndreMaz commented 1 year ago

Hi @volodymyr-babak

I've tried that. TB edge boots but then it starts throwing errors like:

tb-edge org.springframework.dao.DataIntegrityViolationException: could not execute statement; SQL [n/a]; constraint [tb_user_email_key]; nested exception is org.hibernate.exception.ConstraintViolationException: could not execute statement

I guess that something changed in DB schema between 3.4.1 and 3.4.3

AndreMaz commented 1 year ago

I've ended up deleting the containers and volumes of TB edge and Postgres. After a "clean install" TB edge started to work properly.

However, when I pressed "Sync Edge" I got a GRPC error at TB edge.

I opened another ticket here: https://github.com/thingsboard/thingsboard-edge/issues/46

volodymyr-babak commented 1 year ago

@AndreMaz

You are correct - upgrade step is required. I was wrong in my previous comment. I had updated docker images to be able correctly handle upgrade from 3.4.1 to 3.4.3 using docker images.