Loraserver gave pq: syntax error

I got the following error when check loraserver job status:
"sudo systemctl status loraserver -l
● loraserver.service - LoRa Server
Loaded: loaded (/lib/systemd/system/loraserver.service; enabled)
Active: active (running) since Fri 2018-02-16 15:34:06 PST; 9min ago
Docs: https://docs.loraserver.io
Main PID: 622 (loraserver)
CGroup: /system.slice/loraserver.service
└─622 /usr/bin/loraserver

Feb 16 15:43:14 ttn-gateway loraserver[622]: time=“2018-02-16T15:43:14-08:00” level=error msg=“class-c scheduler error” error=“get deveuis with class-c device-queue items error: select error: pq: syntax error at or near “skip””
"

I am wondering anyone has a clue where it is from and how to fix it. Additionally, can I just simply ignore this error? Thanks.

Which version of PostgreSQL are you using?

I have the same issue with following version:

PostgreSQL 9.4.15 on armv8l-unknown-linux-gnueabihf, compiled by gcc (Raspbian 4.9.2-10) 4.9.2, 32-bit

Hello @r.peters, PostgreSQL 9.5+ is required to run the project, see https://docs.loraserver.io/install/requirements/

I did use the PostgreSQL 9.4.15 as @r.peters. But I just upgraded to version 9.6.6. The same problem exists. In addition, when I issue “sudo systemctl status postgresql”, the result shows that the program is active but exited:
$ sudo systemctl status postgresql
● postgresql.service - PostgreSQL RDBMS
Loaded: loaded (/lib/systemd/system/postgresql.service; enabled)
Active: active (exited) since Mon 2018-02-19 12:09:44 PST; 15min ago
Process: 1421 ExecStart=/bin/true (code=exited, status=0/SUCCESS)
Main PID: 1421 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/postgresql.service

Feb 19 12:09:44 ttn-gateway systemd[1]: Started PostgreSQL RDBMS.

I found that both PostgreSQL 9.4 and 9.6 are running in my rpi. After I removed version 9.4, I no longer got the loraserver error. Both loraserver and lora-app-server can connect to psql database. However, psql job still has the active(exited) status.
I noted that even though I created the loraserver_as and loraserver_ns databases. There are no table (schema) being created inside these databases. I uninstalled loraserver and lora-app-server and reinstalled them, the problem persists. I did not write down the schema of previous 9.4 database. Thus I cannot try to manually create those tables.

Update. After I completely removed the postgresql and did a clean installation of version 9.6. It seems to work now although the active (exited) status still exists. Here is what I did:
Remove old installation:
sudo apt-get --purge remove postgresql\*
sudo rm -r /etc/postgresql/
sudo rm -r /etc/postgresql-common/
sudo rm -r /var/lib/postgresql/
sudo userdel -r postgres
sudo groupdel postgres

Install postgresql 9.6:
sudo apt-get -t jessie-backports install postgresql-9.6
sudo apt-get -t jessie-backports install postgresql-contrib-9.6
sudo apt-get -t jessie-backports install postgresql-doc-9.6

Please note that the regular “sudo apt-get install postgresql” command only installs postgresql-9.4. To install version 9.6, you need to do the following:

  1. Create a backports.list file in /etc/apt/sources.list.d containing “deb http://ftp.debian.org/debian jessie-backports main”
  2. Get public keys:
    sudo gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 8B48AD6246925553
    sudo gpg -a --export 8B48AD6246925553 | sudo apt-key add -
    sudo gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-key 7638D0442B90D010
    sudo gpg -a --export 7638D0442B90D010 | sudo apt-key add -
  3. do update
    sudo apt-get update
  4. Then proceed with above install postgresql 9.6 step

Hope this learning can help others as well.

Thanks for your explanation and great you’ve solved your issue.