Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8683993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:11:04+00:00 2026-06-12T22:11:04+00:00

I have two application servers running Ruby on Rails sharing the same MySQL database

  • 0

I have two application servers running Ruby on Rails sharing the same MySQL database server, using InnoDB engine.

Sometimes under heavy load I find that IDs from the records are skipped in the table Users, X and Y and are not sequential.

This is the pseudo code:

user = Create user x in table Users

user_x = Find user x

Insert a tuple into an auxiliary table X

Insert a tuple into an auxiliary table Y

Update the tuple that was inserted in table X

Insert a tuple into an auxiliary table Z

Tables X, Y, Z, are all related in someway, and I am not deleting any records.

However, I find that sometimes record IDs will skip one or two during heavy load.

Would transaction help with this case?

Start transaction

  user = Create user x

  user_x = Find user x

  Insert a tuple into an auxiliary table X

  Insert a tuple into an auxiliary table Y

  Update the tuple that was inserted in table X

  Insert a tuple into an auxiliary table Z

Commit

Noobie question, this code works fine when there is no load, but once if there is a load. ie multiple users hitting the same resource at the exact same time, then the above happens. Would a transaction help?

What disadvantages would there be to wrap everything in transaction blocks?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T22:11:05+00:00Added an answer on June 12, 2026 at 10:11 pm

    I’m not sure about MYSQL, but in Postgres ids are only allocated once from the autoincrementing sequence and will be unused if a transaction is rolled back or aborted.

    You’re best off looking at why it is a problem that some ids are skipped. Anything relying on them to be sequential is suspect.

    Are you using Foreign Keys between Users and tables X, Y, and Z? Or does the relationship depend on the ids incrementing in parallel?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a rails application running over Postgres. I have two servers: one for
I have two database servers running SQL Server 2005 Enterprise that I want to
i have two .net web application and they ara running on different domain same
We have two servers in the same network. One of them is the server
We have two different servers running our web application, one is Windows and other
I'm running load tests for my application. I have two servers: one with my
I'm using Jmeter to load test my web application. I have two web servers
The set up I have websphere 6.1 running two application servers. Each running the
So, I have three servers in my moss farm. A database server and two
I have two web applications that are running on a single Tomcat server and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.