2

Working with Active Record in postgres in a rails application, hosted in heroku I start to notice that sometimes the index of my database are been skipped. For example: product id 1000 1001 1003 <---- Missing the 1002

This is not happen all the time, and I am trying to figure out what is the issue. I check database logs, the server logs and also I call my clients and they said that they have no issue. But I need to know why this skipping scenarios is happening.

rails', '3.2.17' activerecord (3.2.17) pg (0.14.1) pg_search (0.7.0)

I have my guess: this can be heroku issue, with Async Excect, but I have no idea.

2
  • Is it possible that the element was deleted? If an id is used for an element, and then that element is deleted, the id will not be re-used. Commented Apr 20, 2016 at 16:05
  • No we actually never delete anything. I overwrite the models delete method just to unpublish things. The issue happens yesterday. So I am still guessing Commented Apr 20, 2016 at 16:10

1 Answer 1

1

Your transaction rolled back due to some invalid data. Could be google spiders, or less savory robots trying to penetrate the site.

Here's a stack overflow answer: How to reset Autoincremented Id when rollback occurs in sql

Autoincrement IDs should not be contiguous in a production environment.

Sign up to request clarification or add additional context in comments.

2 Comments

can it be a data collision from my own users?
Thanks, I think that now I can have an Idea from what is happening.To avoid blocking concurrent transactions that obtain numbers from the same sequence, a nextval operation is never rolled back; that is, once a value has been fetched it is considered used, even if the transaction that did the nextval later aborts. This means that aborted transactions might leave unused "holes" in the sequence of assigned values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.