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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:41:54+00:00 2026-05-17T20:41:54+00:00

I would like to know if locking my table is necessary in this situation

  • 0

I would like to know if locking my table is necessary in this situation (I’m using Coldfusion and MySQL):

I have a table called wishlists(memberId, gameId, rank, updateAt) where members store games in a personal list.

wishlists has a man-to-many with a members table, and many-to-many with a games table. Many members have many games stored in this list. These games are ranked using an int field. Ranks are particular to a member, so:

Member 1 can have itemId=1, rank=1; itemId=2, rank=2
Member 2 can have itemId=1, rank=1, itemId=2, rank=2
etc...

Each member can modify his or her list by deleting an item, or changing the rank of an item (sendGameToTopOfList(), deleteItemFromList(), for example). This means each time a change is made to a list, the list must be ranked again. I wrote a separate function called rankList() to handle re-ranking. It is fired after “deleteGameFromList()” or “sendGameToTopOfList(); it does the following:

1. Gets a memberWishlist query of all records @memberId ordered first by **rank ASC**, then **updateAt ASC** fields 
2. Loops through memberWishlist query and sets each row's **rank=memberWishlist.RecordCount**

updateAt field is necessary because if a game was moved to top of the list, we would have two items ranked number 1, and to differentiate them I use updatedAt.

Scenario One: A member has 100 games in their list:

  1. Member moves an item to top; rankList() is called after the operation is completed.
  2. While rankList() is still re-ranking the items, member deletes a game

In a normal page request this is fine as the page will not reload until rankList() is done. But if it were ajax, or if were using cfthread, the member can delete 10 games in 5 seconds by clicking through really quickly. Then again, the list will be re-ranked after delete anyway, so it may not matter; but it seems like it’s something I should protect…

Scenario 2:
Some of these wishlist items can turn into orders by using an additional field called “queuedForShipping.” If queuedForShipping is 1, the rankList() function ignores them. What if an admin was creating a shipment when a member just deleted a item or moved one to the top?

Your thoughts are appreciated.

Additional information: New items are automatically ranked last at insert

  • 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-17T20:41:54+00:00Added an answer on May 17, 2026 at 8:41 pm

    No. CFLock isn’t going to have any effect on how MySQL handles things.

    However, you might want a transaction. Wrapping your multiple operations in a transaction block will tell MySQL that you want to guarantee that all the operations complete before storing the changes permanently.

    This assumes that your multiple queries are generated in CF, like this:

    <cffunction sendToTopOfList()>
        <cfquery>
           send to top
        </cfquery>
        <cfquery>
            resort everything
        <cfquery>
    </cffunction>
    

    If you are using a stored procedure on the db server, then (1) I probably would not be too concerned about race conditions here, as you will likely apply row locks as the server makes changes, and (2) look into using transactions on the db server if you are still concerned.

    If you still have questions, I’ll try to answer them, although I’m not really a MySQL expert and haven’t used it much in the last few years.

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

Sidebar

Related Questions

I would like to know who is locking a file (win32). I know about
I would like to know if I can open 2 different diagrams using MS
I would like to know which dependency described in my pom.xml brings a transitive
I would like to know what semaphores, messageQueues, etc... are active in my vxWorks
I would like to know what kind of tool you use for writing your
I would like to know what's the best technique to do single sign-on in
I would like to know what would be the best way to do unit
I would like to know if there is any way to add custom behaviour
I would like to know your experience when you need to take over somebody
I would like to know and understand the steps involved in fetching mail from

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.