Database Migration from 3.14 to 3.15

Hi.

I am trying to upgrade to version 3.15 of the application server and I have a database migration issue. All Chirpstack components are running in containers. Previous image tag for the AS was 3.14 and new one is 3.15. Post the upgrade, I get the following error in the logs.

time=“2021-05-26T07:02:46.789333454Z” level=info msg=“integration/postgresql: applying PostgreSQL schema migrations”
time=“2021-05-26T07:02:46.981739838Z” level=fatal msg=“setup integration error: new integration error: integration/postgresql: migrate up error: Dirty database version 2. Fix and force version.”
time=“2021-05-26T07:02:48.522121313Z” level=info msg=“starting ChirpStack Application Server” docs=“https://www.chirpstack.io/” version=3.15.0

If I revert back to 3.14 I dont get the error but there seems to be some compatibility issues between AS 3.14 and NS 3.13 which I am now on. I also cant roll back to NS 3.12 as I get other errors now

Please, how would I go about troubleshooting this and fixing the databse migration to 3.15

Thank you for your help

1 Like

time=“2021-05-26T07:02:46.981739838Z” level=fatal msg=“setup integration error: new integration error: integration/postgresql: migrate up error: Dirty database version 2. Fix and force version.”

Are you using the same database for your PostgreSQL integration as the ChirpStack Application Server?

Hi.

I am using seperate databases for the two. ‘chirpstack_as’ and ‘chirpstack_as_events’ as suggested in the tutorial.

Thank you

Ok, that is good :slightly_smiling_face:

Could you try running migration 2 by hand on the _events database? It is marked as dirty, meaning something failed in the migration process of that migration. If the migration was already partially applied, you might seen an error that one of the columns already exists.

You will find the content of this migration here:

If these changes have been applied, please check the schema_migrations table in the same database.

I expect it looks like this:

chirpstack_as_events=> select * from schema_migrations ;
 version | dirty 
---------+-------
       2| t
(1 row)

Set dirty to f and restart the ChirpStack Application Server. The expected content of this table after a successful migration is:

chirpstack_as_events=> select * from schema_migrations ;
 version | dirty 
---------+-------
       4 | f
(1 row)
1 Like

Great, Thank you.

I did as you suggested and saw an error in the logs due to the the integration user not being an owner on one of the _events tables. This might have broken the previous migration. I fixed it, restarted 3.15 and all is working well. I have set the dirty tag back to f for future system upgrades

Thanks again

1 Like

Hi.

I am postingthis here as I am not sure if it is a carry over of the same issue. If not, I can create a new thread.

I am now getting the below error quite frequently.

time=“2021-05-27T13:35:36.087983118Z” level=error msg=“integration/multi: integration error” ctx_id=82386e9e-1e26-4aac-b0e9-b056a9a5fd14 error=“marshal rx_info error: unknown message type: *gw.UplinkRXInfo” integration="*postgresql.Integration"

Is this related to a bad database migration?

Thank you

Hi.

Did you find the solution to this problem.
I am facing the same issue.

My schema_migrations looks correct, and I got the fields. dev_addr bytea and confirmed_uplink
But I am not seeing any new data stored in the database.
I can see the device under application is getting new data. But it is not stored in the Database.

After update my postgres integration does not work. I would like to know if anyone has the steps to solve this problem. Structure of my dvice_up table…
image

I fixed my problem today.
The error was describes in this thread

Postgre integration / gw.UplinkRXInfo - #4 by miimote
In chirpstack-application-server.toml, if you have
marshaler=“json_v3”
you will get the related error. You must change to
marshaler=“json”
as it was advised in the comments of configuration file.

My problem was that I used locate chirpstack-application-server.toml but I was not Super User.
So I only saw a version in my users home folder. And this was not the one that Chirpstack-application-server was using.
When I did a

sudo locate chirpstack-application-server.toml

This show me a version af the file in
/etc/chirpstack-application-server/chirpstack-application-server.toml

And when I changed marshaler to json and ran

sudo systemctl restart chirpstack-application-server

I then again got the packages saved in the database.

Hopes this helps you

1 Like

Thanks so much. I will attempt that too.

Regards

Is your issue resolved?
I am also getting this error, I am not doing migration but first-time deployment to k8s for the 3.15 version.
I am pointing to external postgresDB

time=“2021-06-24T15:35:11.694077275Z” level=fatal msg=“setup storage error: storage: migrate up error: Dirty database version 1. Fix and force version.”

I’m also running into the marshal rx_info error.

Jul 16 03:53:40 ip-172-31-2-147 chirpstack-application-server[17930]: time=“2021-07-16T03:53:40.902144089Z” level=error msg=“integration/multi: integration error” ctx_id=e4118e24-3b28-41c7-aace-7da129db955b error=“marshal rx_info error: unknown message type: *gw.UplinkRXInfo” integration=“*postgresql.Integration”

When I look at my chirpstack-application-server.toml file, though, there is no marshaler key in the config file. If it is not set, does it default to “json_v3”? If I need to add it, what subsection should it be located in?

This will be fixed by the next release (there is already a test-release available). With regards to the configuration, please see Configuration - ChirpStack open-source LoRaWAN<sup>®</sup> Network Server for a full config example.

how to see device_up chirpstack on pgAdmin postgresql? as the picture you sent

You must configure the PostgreSQL integration in the chirpstack.toml config file. Make sure to point it to a different database.