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

  • SEARCH
  • Home
  • 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 4609544
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:00:09+00:00 2026-05-22T01:00:09+00:00

I am building an app on node.js using express, and node-mysql driver. There is

  • 0

I am building an app on node.js using express, and node-mysql driver. There is a couple of cases in my app when I need to make a series of database inserts/updates. I want them in a transaction such that if the second or third one fails, the previous inserts are rolled back completely.

Currently, the way I am doing this is to have some kind of middleware which does a START TRANSACTION when a request arrives. During the course of processing of the request, if any error is thrown, I catch this error, and do a ROLLBACK. If no error occurs, I do a COMMIT before sending the response to the browser.

However, I am now concerned that this won’t work when multiple users access the application simultaneously, as MySQL does a forced commit if another request tries to begin it’s own transaction with START TRANSACTION! I am currently using only a single instance of node, and a single MySQL connection for all the requests.

Can someone please advice me if my concerns are valid, and how should I get in transactions support?

  • 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-05-22T01:00:10+00:00Added an answer on May 22, 2026 at 1:00 am

    You’ll need to create a client pool, or somehow otherwise ensure that two different pages aren’t interspersing commands on the same connection (at least while any of them is in a transaction).

    Since you want to conditionally do a rollback based upon the result of an earlier command, you’ll need to chain the db calls together through their callbacks and not rely on the node-mysql queuing behavior. That will open up a window for some other page to come in and queue up an operation on the same connection as you suggest.

    You could create and manage your own queue, but that would end up serializing all transactional pages (assuming you’re sticking with the single connection model).

    From a quick googling, it looks like there are several node-mysql pools on github. After looking at them, though, they don’t look like they’ll help with your issue.

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

Sidebar

Related Questions

I am building an app that talks to an Access database via OleDB/Jet. There
Im building an app using kohana. I need to be able to upload files
So I'm building an app that uses win32's SendMessage as IPC. I'm using FindWindow
I'm building a app that need manage money datatype. I'm new on Obj-c, so
I'm building an app in PHP and I'm using the data mapper pattern for
I'm building app using GAE and wanted to use Django for that. Which patch
Building an app using a calendar on a Google Apps domain that has SSL
I am building a node.js app and wondering which javascript lib to add to
I'm building an app using Windows Azure Table. I've encapsulated all my calls to
I'm building an app that allows users to snap pictures using the iPhone camera,

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.