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 6010703
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:09:17+00:00 2026-05-23T02:09:17+00:00

I have a transaction that does one read on the database, followed by one

  • 0

I have a transaction that does one read on the database, followed by one write. If I choose MyIsam as my database engine in MySQL does the table level locking mechanism of MyIsam guarantee me that, once the transaction starts its read, the table is locked from all other transactions?

I mean if there are two or more transactions, I want them in this order:

R W R W R W R W R W... 

But if these are done in this order:

R R R R W W W W....

my database goes into an inconsistent state. This is the specific requirement in have on this particular table. Is making the table MYIsam sufficient? If not what else do I need to do? Is table level locking meant only for writes?

  • 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-23T02:09:18+00:00Added an answer on May 23, 2026 at 2:09 am

    The MySQL documentation states that:

    • LOCK TABLES is not transaction-safe
      and implicitly commits any active
      transaction before attempting to lock
      the tables.

    • Beginning a transaction (for example,
      with START TRANSACTION) implicitly
      commits any current transaction and
      releases existing locks.

    But those stipulations apply to a transactional engine (InnoDB). MyISAM doesn’t support InnoDB style transactions.

    MyISAM has read locks (which will prevent writes from any sessions), and write locks (which prevent reads and writes from other sessions). Multiple sessions can obtain read locks, but if one session obtains a write lock no other session can read, lock, or write to the table while the write lock is in place.

    I encourage you to consult the docs on the topic, as well as those pages linked to at the top of the page I linked to. Sorry that the link refers to a specific version number; I don’t know of a version-agnostic way to link to MySQL documentation.

    It sounds to me like you need to obtain a write lock, and do your read/write while the lock is active, then release it, and move on to the next. If you were to first obtain a read lock, do your read, then release and obtain a write lock, you expose race conditions.

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

Sidebar

Related Questions

I have one Servlet that does insertion into my database. This is working fine.
If you have a database transaction that should be read only, do you commit
What does it mean that a Transaction Log is Full? I have it the
I have a read query that I execute within a transaction so that I
I currently have a SQL Server (Express 2005) database to hold some transaction/metadata that
I have a method that transfers data from one database to another and in
I have one table called: Transaction. This table has the following fields: (ID,ProductName,Amount,Date) placed
I have a long running insert transaction that inserts data into several related tables.
Here is the scenario: I have an object called a Transaction that needs to
Consider that I have a transaction: BEGIN TRANSACTION DECLARE MONEY @amount SELECT Amount AS

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.