puppetlabs/puppetdb — pull request #890 by kbarber (2014-03-21 04:21:44+00:00)
Title: PDB-510 Add migration to fix sequence for catalog.id

The sequence for catalog.id had not been incremented during insert for migration
20 'differential-catalog-resources'.

This meant that the catalog.id column would throw a constraint exception during
insertion until the sequence had increased enough to be greater then the max id
already used in the column.

While this was only a temporary error, it does cause puppetdb to start to throw
errors and potentially dropping some catalog updates until a certain number of
catalogs had been attempted. In some cases catalogs had been queued up and
retried successfully, other cases meant they were simply dropped into the DLQ.

The fix is to reset the sequence to match the max id on the catalogs.id column.

This patch includes a new migration with this step, that utilizes a new function
created to generically reset sequences based on table and catalog in a database
independant way.

Signed-off-by: Ken Barber