satellite-sync fails with 'IntegrityError: null value in column "package_id" violates not-null constraint'

Solution Verified - Updated -

Environment

  • Red Hat Satellite v.5.6,/v.5.7

Issue

  • satellite-sync failed with error:

    SYNC ERROR: unhandled exception occurred:
    IntegrityError('null value in column "package_id" violates not-null constraint\n',) null value in column "package_id" violates not-null constraint
    
  • satellite-sync fails after removing channels.
  • satellite-sync is failing with the following traceback:
    SYNC ERROR: unhandled exception occurred:

    Exception reported from satellite.example.com
    Time: Sat Feb 22 11:35:47 2014
    Exception type <class 'psycopg2.IntegrityError'>
    
    Exception Handler Information
    Traceback (most recent call last):
      File "/usr/bin/satellite-sync", line 139, in main
        return satsync.Runner().main()
      File "/usr/lib/python2.6/site-packages/spacewalk/satellite_tools/satsync.py", line 229, in main
        ret = method()
      File "/usr/lib/python2.6/site-packages/spacewalk/satellite_tools/satsync.py", line 349, in _step_errata
        self.syncer.import_errata()
      File "/usr/lib/python2.6/site-packages/spacewalk/satellite_tools/satsync.py", line 1675, in import_errata
        sync_handlers.import_errata)
      File "/usr/lib/python2.6/site-packages/spacewalk/satellite_tools/satsync.py", line 1576, in _proces_batch
        prompt, nevermorethan, process_function_args)
      File "/usr/lib/python2.6/site-packages/spacewalk/satellite_tools/satsync.py", line 1556, in _processWithProgressBar
        process_function(chunk, *process_function_args)
      File "/usr/lib/python2.6/site-packages/spacewalk/satellite_tools/sync_handlers.py", line 400, in import_errata
        importer.run()
      File "/usr/lib/python2.6/site-packages/spacewalk/server/importlib/importLib.py", line 647, in run
        self.submit()
      File "/usr/lib/python2.6/site-packages/spacewalk/server/importlib/errataImport.py", line 196, in submit
        dml = self.backend.processErrata(self.batch)
      File "/usr/lib/python2.6/site-packages/spacewalk/server/importlib/backend.py", line 832, in processErrata
        transactional=1)
      File "/usr/lib/python2.6/site-packages/spacewalk/server/importlib/backend.py", line 1508, in __processObjectCollection
        return self.__processObjectCollection__(objColl, parentTable, childDict, **kwargs)
      File "/usr/lib/python2.6/site-packages/spacewalk/server/importlib/backend.py", line 1678, in __processObjectCollection__
        return self.__doDML(dml)
      File "/usr/lib/python2.6/site-packages/spacewalk/server/importlib/backend.py", line 1786, in __doDML
        self.__doInsert(dml.insert, dml.tables)
      File "/usr/lib/python2.6/site-packages/spacewalk/server/importlib/backend.py", line 1793, in __doInsert
        self.__doInsertTable(tname, dict)
      File "/usr/lib/python2.6/site-packages/spacewalk/server/importlib/backend.py", line 1807, in __doInsertTable
        insertObj.query(hash)
      File "/usr/lib/python2.6/site-packages/spacewalk/server/importlib/backendLib.py", line 431, in query
        executeStatement(statement, values, chunksize)
      File "/usr/lib/python2.6/site-packages/spacewalk/server/importlib/backendLib.py", line 456, in executeStatement
        count += statement.executemany(**tempdict)
      File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnSQL/sql_base.py", line 172, in executemany
        return apply(self._execute_wrapper, (self._executemany, ) + p, kw)
      File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnSQL/driver_postgresql.py", line 273, in _execute_wrapper
        retval = apply(function, p, kw)
      File "/usr/lib/python2.6/site-packages/spacewalk/server/rhnSQL/driver_postgresql.py", line 310, in _executemany
        self._real_cursor.executemany(self.sql, all_kwargs)
    IntegrityError: null value in column "package_id" violates not-null constraint
    

Resolution

  1. Clear the satellite-sync cache on both Master and Slave:

    # rm -rf /var/cache/rhn/satsync/* 
    
  2. Re-run satellite-sync the Red Hat Satellite server:

    # satellite-sync -c <channel-label>
    

Root Cause

  • Corrupted satellite-sync cache on the Red Hat Satellite server.

This solution is part of Red Hat’s fast-track publication program, providing a huge library of solutions that Red Hat engineers have created while supporting our customers. To give you the knowledge you need the instant it becomes available, these articles may be presented in a raw and unedited form.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.