6, July 2008

table row locking - what do you think and what is your idea? - webmaster forum

 
Webdigity webmaster forums
This forum shares its ad revenue with its members!
[ Home | Help | Search | Forum's Shop | Archive | Login | Register | Webmaster Directory ]
Webdigity Webmaster Forums  >  Web Development  >  Databases  >  MySQL
Topic: table row locking - what do you think and what is your idea?
« previous next »
Pages: [1] Print

Author Topic: table row locking - what do you think and what is your idea?  (Read 1257 times)
OMG!I am geek
**
Posts: 57
394 credits
Members referred : 0


« on: May 23, 2007, 04:45:33 PM »

I start this new thread because the other one discusses a differed table locking problem whith session. This thread is created not for the seesion table locking but for the general table locking problems.

For example the admin and a user try to insert something in users_profile table and there is no locking featcher, which data will be insert and shown at next?

I assume that problem could be solved by only allow only one user to edit/view the same row by checking if this row has an session for a tempoary insert which should be deleted afted the insert in done. What do you think of it?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6272
38458 credits
Members referred : 374


It's time to use PHP5!


« Reply #1 on: May 23, 2007, 04:56:12 PM »

I say this discussion is not related to this class but related to your application, will say is you own decision...


Last blog : 4th of July Lottery from TemplateMonster.com
OMG!I am geek
**
Posts: 57
394 credits
Members referred : 0


« Reply #2 on: May 23, 2007, 05:13:18 PM »

I say this discussion is not related to this class but related to your application, will say is you own decision...
Why this question should not related to this class? This situation is even possible with this class. If a user and the admin updates say the password from a user at the same time. What will be happen, which update will be take place in the  users table, which password will be the right one?
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6272
38458 credits
Members referred : 374


It's time to use PHP5!


« Reply #3 on: May 23, 2007, 05:17:52 PM »


Why this question should not related to this class? This situation is even possible with this class. If a user and the admin updates say the password from a user at the same time. What will be happen, which update will be take place in the  users table, which password will be the right one?

look this class script is not a full function application, the examples are purposed to give you an idea how to use that class. It's up to you as web developer to build an application where this is feature is possible or not.

if you see the replacement of a password by user and admin as a problem you need to find a solution and not the class script



Last blog : 4th of July Lottery from TemplateMonster.com
OMG!I am geek
**
Posts: 57
394 credits
Members referred : 0


« Reply #4 on: May 23, 2007, 05:23:10 PM »

ok, you are right but I'm intressed how maybe you or others think of that and if they think that this is a problem or not and maybe  you have ideas to solve it.
« Last Edit: May 23, 2007, 05:24:43 PM by tomz »
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 7931
40535 credits
Members referred : 3



« Reply #5 on: May 23, 2007, 06:11:26 PM »

In my opinion this is not a problem. First of all why both admin and the user want to change the password at the same milisecond? Isn't that strange?

Even if it happen, the mysql will keep the last one, but no matter what, you can't prevent that. If you lock the row then the first one will save the value. If you don't lock the row the second will save it. So what's the difference?

Trial and Error my two best teachers Cool
Promote your blog for free.... Visit through proxy

Last blog : Keep it Legal - Tims guide to legal notices
OMG!I am geek
**
Posts: 57
394 credits
Members referred : 0


« Reply #6 on: May 23, 2007, 06:43:49 PM »

In my opinion this is not a problem. First of all why both admin and the user want to change the password at the same milisecond? Isn't that strange?

Even if it happen, the mysql will keep the last one, but no matter what, you can't prevent that. If you lock the row then the first one will save the value. If you don't lock the row the second will save it. So what's the difference?
Hm, I think the difference is that we will be able to determine who is the first and who is the second. Otherwise it's random but maybe your are right and it is'nt realy a problem because the insert or update value will be shown after it is done but it would be nice if the user would be informed that the data was changed by sombody else if thise case arises and I dont mean only for the password, it could be happend for every value.
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 7931
40535 credits
Members referred : 3



« Reply #7 on: May 23, 2007, 11:49:38 PM »

In order to do what you say, you should keep a file of changes (another table in the db) and run some checks every time someone changes something to an account.

In my opinion this would be needed only to a bank system and only for security reasons, as the possibility of someone changing his/her information while the admin does the same is almost impossible Smiley

Trial and Error my two best teachers Cool
Promote your blog for free.... Visit through proxy

Last blog : Keep it Legal - Tims guide to legal notices
OMG!I am geek
**
Posts: 57
394 credits
Members referred : 0


« Reply #8 on: May 24, 2007, 12:27:32 AM »

In my opinion this would be needed only to a bank system ...
There are more real reasons as only the getting money process. For example every time if you sell somthing there could be a problem, every shop solution need a solution like this otherwise you will sell something what was already sold ...

I'm not very closed to mysql but I know that transaction are not possible whis myisam. ok, I don't want to use transactions but is there realy no risk in damaging databases if two users writes at the same time in the same row, dow mysql handle this case one after the other as you said before?
« Last Edit: May 24, 2007, 12:29:23 AM by tomz »
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 7931
40535 credits
Members referred : 3



« Reply #9 on: May 24, 2007, 12:43:29 AM »

This is a design problem. The session is not relevant here, as there is no practical reason to hold your shop's inventory in the session right?

When you sell something you update your inventory. If this happened twice at the same time both processes will update, but I again if your code is correct there is no problem. For instance if you say UPDATE products SET sum = sum -1 WHERE productID = X, both processes will update the table.

Regarding transactions I think you can use them since mysql 5.0

Trial and Error my two best teachers Cool
Promote your blog for free.... Visit through proxy

Last blog : Keep it Legal - Tims guide to legal notices
Global Moderator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 6272
38458 credits
Members referred : 374


It's time to use PHP5!


« Reply #10 on: May 24, 2007, 01:06:36 AM »

I think it's time to move this thread to the mysql forum...Smiley


Last blog : 4th of July Lottery from TemplateMonster.com
I am a metal monkey!
Administrator
Community Supporter ?
Jedai Sword Master
*****
Gender: Male
Posts: 7931
40535 credits
Members referred : 3



« Reply #11 on: May 24, 2007, 03:31:22 AM »

I think it's time to move this thread to the mysql forum...Smiley

Right Smiley

I've moved the thread.

Trial and Error my two best teachers Cool
Promote your blog for free.... Visit through proxy

Last blog : Keep it Legal - Tims guide to legal notices
Trackback URI for this entry : http://www.webdigity.com/trackback.php?topic=6608
Tags : table locking Bookmark this thread : Digg Del.icio.us Dzone more....

Topic sponsors:
Get a permanent link here for $1.99!


Pages: [1] Print 
Webdigity Webmaster Forums  >  Web Development  >  Databases  >  MySQL
Topic: table row locking - what do you think and what is your idea?
« previous next »
Jump to:
User Area
Welcome, Guest. Please login or register.
Did you miss your activation email?
Jul 06, 2008, 07:46:51 AM





Login with username, password and session length

Donate to our community, and get a permanent link back to your site!

Donate to our community, and get a permanent link back to your site!


Forum Statistics
Total Posts: 35.548
Total Topics: 7.348
Total Members: 3.648
Tutorials : 56
Resources : 143
Designs : 220
Latest Member: mybaseballcards

18 Guests, 5 Users online :

12 users online today:



Readers

Web Design Gallery · Whois Lookup · Pagerank · Tag Browsing · Lo-fi version · Syndication · Webmaster forum history · Advertise
Developed by HumanWorks © 2005 - 2008 Webdigity webmaster community · sublime directory
Webdigity Webmaster Forums | Powered by SMF 1.0.12. © 2001-2005, Lewis Media. All Rights Reserved.