Numbers are Free
Develop | Posted January 07, 2011

Every now and then someone writes in complaining that when they create two reviews back to back, their ID's arent sequential, or perhaps even decreasing. They think that something has gone horribly wrong.

Everything is fine.

The ID's are generated by the database that is backing Code Collaborator. Sometimes numbers are skipped. sometimes they are issued out of order. These behaviors are most common in clustered databases, where the need for concurrent operation has trumped the desire for pretty numbering. Database nodes will request several ID's at a time, and can then issue them for a while without requesting a new batch, enabling several nodes to add new rows at the same time. A node may decide to throw away numbers it hasn't used, resulting in gaps in the numbering, or requests may go to different nodes, resulting in ID's being issued out of order. Imagine the following:


NodeA: "I need some IDs"

IDBroker: "Here, take 123-142"

NodeB: "I need some IDs"

IDBroker: "Here, take 143-162"

User: "I need a review!"

NodeB: "Here, take Review 143"

User: "I need another review!"

NodeA: "Here, take Review 123"

User: "Curious, these ID's are out of order"


In summary, this is an expected situation. It's not uncommon to be annoyed by this behavior, but it's expected and accounted for, and everything will work OK.


By submitting this form, you agree to our
Terms of Use and Privacy Policy

Thanks for Subscribing

Keep an eye on your inbox for more great content.

Continue Reading

Add a little SmartBear to your life

Stay on top of your Software game with the latest developer tips, best practices and news, delivered straight to your inbox