TACC / tacc_stats

TACC Stats is an automated resource-usage monitoring and analysis package.
GNU Lesser General Public License v2.1
41 stars 15 forks source link

django.db.utils.ProgrammingError: syntax error at or near "ON" #18

Closed espenfl closed 1 year ago

espenfl commented 4 years ago

Just got this when executing update_db.py manually on a fresh install to check that everything works before creating a cron:

(tacc_stats) [espenfl@dbase.FRAM /tacc_stats_site/src/tacc_stats]$ update_db.py 
Traceback (most recent call last):
  File "/tacc_stats_site/venv/tacc_stats/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute
    return self.cursor.execute(sql, params)
psycopg2.errors.SyntaxError: syntax error at or near "ON"
LINE 1: ..._jobs" ("host_id", "job_id") VALUES (498, 483261) ON CONFLIC...
                                                             ^

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/tacc_stats_site/venv/tacc_stats/bin/update_db.py", line 7, in <module>
    exec(compile(f.read(), __file__, 'exec'))
  File "/tacc_stats_site/src/tacc_stats/tacc_stats/site/machine/update_db.py", line 189, in <module>
    update_acct(date, rerun = False)         
  File "/tacc_stats_site/src/tacc_stats/tacc_stats/site/machine/update_db.py", line 113, in update_acct
    h.jobs.add(obj)
  File "/tacc_stats_site/venv/tacc_stats/lib/python3.8/site-packages/django/db/models/fields/related_descriptors.py", line 944, in add
    self._add_items(
  File "/tacc_stats_site/venv/tacc_stats/lib/python3.8/site-packages/django/db/models/fields/related_descriptors.py", line 1123, in _add_items
    self.through._default_manager.using(db).bulk_create([
  File "/tacc_stats_site/venv/tacc_stats/lib/python3.8/site-packages/django/db/models/query.py", line 492, in bulk_create
    returned_columns = self._batched_insert(
  File "/tacc_stats_site/venv/tacc_stats/lib/python3.8/site-packages/django/db/models/query.py", line 1230, in _batched_insert
    self._insert(item, fields=fields, using=self.db, ignore_conflicts=ignore_conflicts)
  File "/tacc_stats_site/venv/tacc_stats/lib/python3.8/site-packages/django/db/models/query.py", line 1204, in _insert
    return query.get_compiler(using=using).execute_sql(returning_fields)
  File "/tacc_stats_site/venv/tacc_stats/lib/python3.8/site-packages/django/db/models/sql/compiler.py", line 1391, in execute_sql
    cursor.execute(sql, params)
  File "/tacc_stats_site/venv/tacc_stats/lib/python3.8/site-packages/django/db/backends/utils.py", line 100, in execute
    return super().execute(sql, params)
  File "/tacc_stats_site/venv/tacc_stats/lib/python3.8/site-packages/django/db/backends/utils.py", line 68, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/tacc_stats_site/venv/tacc_stats/lib/python3.8/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/tacc_stats_site/venv/tacc_stats/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute
    return self.cursor.execute(sql, params)
  File "/tacc_stats_site/venv/tacc_stats/lib/python3.8/site-packages/django/db/utils.py", line 90, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/tacc_stats_site/venv/tacc_stats/lib/python3.8/site-packages/django/db/backends/utils.py", line 86, in _execute
    return self.cursor.execute(sql, params)
django.db.utils.ProgrammingError: syntax error at or near "ON"
LINE 1: ..._jobs" ("host_id", "job_id") VALUES (498, 483261) ON CONFLIC...
                                                             ^

(tacc_stats) [espenfl@dbase.FRAM /tacc_stats_site/src/tacc_stats]$ 

any idea on what can cause this?

rock98rock commented 3 years ago

Im also facing this error.. any guidance?

rtevans commented 3 years ago

This is probably due to an incompatibility between Django and postgres versions. Currently I successfully deploy Django 3.0.8 w/ Postgres 9.6 or Django 2.1.1 w/ Postgres 9.2

I think more recent versions of Django require Postgres 9.5+. If you're on redhat and have an older postgres as default you can get 9.6 via

https://yallalabs.com/linux/how-to-install-postgresql-9-6-on-centos-7-rhel-7/