Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

postgres_local_cache causing 'IntegrityError: duplicate key value violates unique constraint "jids_pkey"' #54787

Open
breshead opened this issue Sep 27, 2019 · 3 comments
Labels
Bug broken, incorrect, or confusing behavior Confirmed Salt engineer has confirmed bug/feature - often including a MCVE severity-low 4th level, cosemtic problems, work around exists
Milestone

Comments

@breshead
Copy link

Description of Issue

When using postgres master_job_cache, running any state fails with the following message.

2019-09-26 18:06:05,733 [salt.master      :1845][ERROR   ][19716] Error in function _return:
Traceback (most recent call last):
  File "/usr/lib/python2.7/dist-packages/salt/master.py", line 1838, in run_func
    ret = getattr(self, func)(load)
  File "/usr/lib/python2.7/dist-packages/salt/master.py", line 1637, in _return
    self.opts, load, event=self.event, mminion=self.mminion)
  File "/usr/lib/python2.7/dist-packages/salt/utils/job.py", line 109, in store_job
    mminion.returners[savefstr](load['jid'], load)
  File "/usr/lib/python2.7/dist-packages/salt/returners/postgres_local_cache.py", line 303, in save_load
    six.text_type(clear_load.get("fun")),
IntegrityError: duplicate key value violates unique constraint "jids_pkey"
DETAIL:  Key (jid)=(20190926180501069881) already exists.

Setup

https://docs.saltstack.com/en/latest/ref/returners/all/salt.returners.postgres_local_cache.html

Steps to Reproduce Issue

Just run any state

Versions Report

Salt Version:
           Salt: 2019.2.0
 
Dependency Versions:
           cffi: Not Installed
       cherrypy: Not Installed
       dateutil: 1.5
      docker-py: Not Installed
          gitdb: 0.5.4
      gitpython: 0.3.2 RC1
          ioflo: Not Installed
         Jinja2: 2.7.2
        libgit2: Not Installed
        libnacl: Not Installed
       M2Crypto: Not Installed
           Mako: 0.9.1
   msgpack-pure: Not Installed
 msgpack-python: 0.4.6
   mysql-python: 1.2.3
      pycparser: Not Installed
       pycrypto: 2.6.1
   pycryptodome: Not Installed
         pygit2: Not Installed
         Python: 2.7.6 (default, Nov 13 2018, 12:45:42)
   python-gnupg: 0.3.6
         PyYAML: 3.10
          PyZMQ: 14.4.0
           RAET: Not Installed
          smmap: 0.8.2
        timelib: Not Installed
        Tornado: 4.2.1
            ZMQ: 4.0.5
 
System Versions:
           dist: Ubuntu 14.04 trusty
         locale: UTF-8
        machine: x86_64
        release: 3.13.0-74-generic
         system: Linux
        version: Ubuntu 14.04 trusty

Possible Source

In utils/job.py, I changed the if job_cache != 'local_cache' to also check for postgres_local_cache and the errors went away and I was getting the return data I was looking for. However that feels like the wrong thing to do but maybe it gets us closer the the real source.

106     if job_cache != 'local_cache' and job_cache != 'postgres_local_cache':
107         try:
108             log.error("job_cache != 'local_cache' (%s)", job_cache)
109             mminion.returners[savefstr](load['jid'], load)
110         except KeyError as e:
111             log.error("Load does not contain 'jid': %s", e)
@dwoz dwoz added Bug broken, incorrect, or confusing behavior P3 Priority 3 severity-low 4th level, cosemtic problems, work around exists labels Oct 13, 2019
@dwoz dwoz added this to the Approved milestone Oct 13, 2019
@stale
Copy link

stale bot commented Jan 7, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

If this issue is closed prematurely, please leave a comment and we will gladly reopen the issue.

@stale stale bot added the stale label Jan 7, 2020
@waynew waynew added the Confirmed Salt engineer has confirmed bug/feature - often including a MCVE label Jan 8, 2020
@stale
Copy link

stale bot commented Jan 8, 2020

Thank you for updating this issue. It is no longer marked as stale.

@stale stale bot removed the stale label Jan 8, 2020
@sagetherage sagetherage removed the P3 Priority 3 label Jun 3, 2020
@ITJamie
Copy link
Contributor

ITJamie commented Jun 21, 2022

Ive just noticed this on the postgres returner also
salt conf

event_return: [postgres]
master_job_cache: postgres

I see error logs quite often from postgres. eg
2022-06-21 18:00:07.308 UTC [104] ERROR: duplicate key value violates unique constraint "jids_pkey"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug broken, incorrect, or confusing behavior Confirmed Salt engineer has confirmed bug/feature - often including a MCVE severity-low 4th level, cosemtic problems, work around exists
Projects
None yet
Development

No branches or pull requests

5 participants