<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Resolving transaction concurrency issues in a PHP+MySQL multi-user environment</title>
	<atom:link href="http://www.ardamis.com/2008/04/06/resolving-transaction-concurrency-issues-in-a-phpmysql-multi-user-environment/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.ardamis.com/2008/04/06/resolving-transaction-concurrency-issues-in-a-phpmysql-multi-user-environment/</link>
	<description>Ardamis is a blog about web development and technology in general.</description>
	<lastBuildDate>Sat, 31 Jul 2010 02:57:31 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<item>
		<title>By: ardamis</title>
		<link>http://www.ardamis.com/2008/04/06/resolving-transaction-concurrency-issues-in-a-phpmysql-multi-user-environment/#comment-41955</link>
		<dc:creator>ardamis</dc:creator>
		<pubDate>Sat, 31 Jul 2010 02:50:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.ardamis.com/2008/04/06/resolving-transaction-concurrency-issues-in-a-phpmysql-multi-user-environment/#comment-41955</guid>
		<description>I would think that if only one user can access any given record, then there would be less opportunity for problems to arise.  But there is still a possibility that data could be lost.  For example, a user could access the same record from two separate browsers (log in from home, leave that page up, and then log in later from work) and cause data loss in the same way as two different users accessing a single record.

In my opinion, a responsible developer will work to eliminate any possibility of data loss, however unlikely.</description>
		<content:encoded><![CDATA[<p>I would think that if only one user can access any given record, then there would be less opportunity for problems to arise.  But there is still a possibility that data could be lost.  For example, a user could access the same record from two separate browsers (log in from home, leave that page up, and then log in later from work) and cause data loss in the same way as two different users accessing a single record.</p>
<p>In my opinion, a responsible developer will work to eliminate any possibility of data loss, however unlikely.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: David DelMonte</title>
		<link>http://www.ardamis.com/2008/04/06/resolving-transaction-concurrency-issues-in-a-phpmysql-multi-user-environment/#comment-41952</link>
		<dc:creator>David DelMonte</dc:creator>
		<pubDate>Sat, 31 Jul 2010 02:00:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.ardamis.com/2008/04/06/resolving-transaction-concurrency-issues-in-a-phpmysql-multi-user-environment/#comment-41952</guid>
		<description>Would you all recommend the same solution if every user&#039;s data was their own. I am building an app which people can use off of my site, but they each have their own data. Do I replicate the database or follow the examples here, or do something different.. I would appreciate your wisdom..</description>
		<content:encoded><![CDATA[<p>Would you all recommend the same solution if every user&#8217;s data was their own. I am building an app which people can use off of my site, but they each have their own data. Do I replicate the database or follow the examples here, or do something different.. I would appreciate your wisdom..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jon di Elos</title>
		<link>http://www.ardamis.com/2008/04/06/resolving-transaction-concurrency-issues-in-a-phpmysql-multi-user-environment/#comment-31811</link>
		<dc:creator>Jon di Elos</dc:creator>
		<pubDate>Tue, 20 Apr 2010 19:02:52 +0000</pubDate>
		<guid isPermaLink="false">http://www.ardamis.com/2008/04/06/resolving-transaction-concurrency-issues-in-a-phpmysql-multi-user-environment/#comment-31811</guid>
		<description>Why not relly on MySQL innoDB concurrency model? Is there any problem requirement which makes innodb inpractical in this case? Did I miss something?

Regards,
Jon di Leos</description>
		<content:encoded><![CDATA[<p>Why not relly on MySQL innoDB concurrency model? Is there any problem requirement which makes innodb inpractical in this case? Did I miss something?</p>
<p>Regards,<br />
Jon di Leos</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ardamis</title>
		<link>http://www.ardamis.com/2008/04/06/resolving-transaction-concurrency-issues-in-a-phpmysql-multi-user-environment/#comment-18173</link>
		<dc:creator>ardamis</dc:creator>
		<pubDate>Mon, 01 Jun 2009 20:09:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.ardamis.com/2008/04/06/resolving-transaction-concurrency-issues-in-a-phpmysql-multi-user-environment/#comment-18173</guid>
		<description>A hash is a great idea, and in one implementation, it could eliminate the need for each record to contain the timestamp data.  However, as pointed out in another comment, attempting to modify the record using an UPDATE that looks for the timestamp serves to check that the record can be modified at the same instant it would be changed.

I&#039;m not at all familiar with the risks involved with thread switching, but it seems to me that there still exists the potential for data loss in the time it takes the server to calculate the MD5 sum and then send the data to the database.

I&#039;ll certainly consider using it the next time this issue comes up, though.</description>
		<content:encoded><![CDATA[<p>A hash is a great idea, and in one implementation, it could eliminate the need for each record to contain the timestamp data.  However, as pointed out in another comment, attempting to modify the record using an UPDATE that looks for the timestamp serves to check that the record can be modified at the same instant it would be changed.</p>
<p>I&#8217;m not at all familiar with the risks involved with thread switching, but it seems to me that there still exists the potential for data loss in the time it takes the server to calculate the MD5 sum and then send the data to the database.</p>
<p>I&#8217;ll certainly consider using it the next time this issue comes up, though.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steve</title>
		<link>http://www.ardamis.com/2008/04/06/resolving-transaction-concurrency-issues-in-a-phpmysql-multi-user-environment/#comment-18172</link>
		<dc:creator>Steve</dc:creator>
		<pubDate>Mon, 01 Jun 2009 19:27:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.ardamis.com/2008/04/06/resolving-transaction-concurrency-issues-in-a-phpmysql-multi-user-environment/#comment-18172</guid>
		<description>I prefer to use a hash of the original record. When user A retrieves the record for editing, I generate an MD5 hash of the record data that is included as a hidden field in the form. When the user tries to write the record, I can determine whether the record was changed by comparing the MD5 hash. That eliminates the need to manage the timestamps.</description>
		<content:encoded><![CDATA[<p>I prefer to use a hash of the original record. When user A retrieves the record for editing, I generate an MD5 hash of the record data that is included as a hidden field in the form. When the user tries to write the record, I can determine whether the record was changed by comparing the MD5 hash. That eliminates the need to manage the timestamps.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tom Christopherson</title>
		<link>http://www.ardamis.com/2008/04/06/resolving-transaction-concurrency-issues-in-a-phpmysql-multi-user-environment/#comment-18153</link>
		<dc:creator>Tom Christopherson</dc:creator>
		<pubDate>Fri, 29 May 2009 22:57:36 +0000</pubDate>
		<guid isPermaLink="false">http://www.ardamis.com/2008/04/06/resolving-transaction-concurrency-issues-in-a-phpmysql-multi-user-environment/#comment-18153</guid>
		<description>Thanks for the write up... i&#039;ve been wrestling with the same design issue for some time now and your explaination is the best I&#039;ve seen yet as a possible solution.</description>
		<content:encoded><![CDATA[<p>Thanks for the write up&#8230; i&#8217;ve been wrestling with the same design issue for some time now and your explaination is the best I&#8217;ve seen yet as a possible solution.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tony</title>
		<link>http://www.ardamis.com/2008/04/06/resolving-transaction-concurrency-issues-in-a-phpmysql-multi-user-environment/#comment-16949</link>
		<dc:creator>Tony</dc:creator>
		<pubDate>Fri, 26 Sep 2008 11:41:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.ardamis.com/2008/04/06/resolving-transaction-concurrency-issues-in-a-phpmysql-multi-user-environment/#comment-16949</guid>
		<description>Pretty cool solution. To add to that, it works great when process collision is greater than the granularity of the MySql timestamp which is per second. ie, no 2 process will do a read/write within 1 second.

To get around this, you can store the time as a bigint which can handle milliseconds. Unless you have some serious hardware, I don&#039;t think collision granularity would go smaller than milliseconds.

Also instead of re-reading the timestamp before B saves, B should try to UPDATE row WHERE &quot;opened timestamp&quot; = &quot;last modified timestamp&quot;. Otherwise the CPU could potentially decide to switch threads on you right after you&#039;ve done the second read, and do the entire read-write of A in that time.</description>
		<content:encoded><![CDATA[<p>Pretty cool solution. To add to that, it works great when process collision is greater than the granularity of the MySql timestamp which is per second. ie, no 2 process will do a read/write within 1 second.</p>
<p>To get around this, you can store the time as a bigint which can handle milliseconds. Unless you have some serious hardware, I don&#8217;t think collision granularity would go smaller than milliseconds.</p>
<p>Also instead of re-reading the timestamp before B saves, B should try to UPDATE row WHERE &#8220;opened timestamp&#8221; = &#8220;last modified timestamp&#8221;. Otherwise the CPU could potentially decide to switch threads on you right after you&#8217;ve done the second read, and do the entire read-write of A in that time.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ardamis</title>
		<link>http://www.ardamis.com/2008/04/06/resolving-transaction-concurrency-issues-in-a-phpmysql-multi-user-environment/#comment-15859</link>
		<dc:creator>ardamis</dc:creator>
		<pubDate>Sat, 28 Jun 2008 03:40:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.ardamis.com/2008/04/06/resolving-transaction-concurrency-issues-in-a-phpmysql-multi-user-environment/#comment-15859</guid>
		<description>That&#039;s a very interesting PowerPoint presentation, thanks for linking it.  And I&#039;m happy to see that we both arrived at the same solution.  I hope it serves you well.</description>
		<content:encoded><![CDATA[<p>That&#8217;s a very interesting PowerPoint presentation, thanks for linking it.  And I&#8217;m happy to see that we both arrived at the same solution.  I hope it serves you well.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: jlaguna</title>
		<link>http://www.ardamis.com/2008/04/06/resolving-transaction-concurrency-issues-in-a-phpmysql-multi-user-environment/#comment-14773</link>
		<dc:creator>jlaguna</dc:creator>
		<pubDate>Tue, 13 May 2008 06:41:13 +0000</pubDate>
		<guid isPermaLink="false">http://www.ardamis.com/2008/04/06/resolving-transaction-concurrency-issues-in-a-phpmysql-multi-user-environment/#comment-14773</guid>
		<description>Very good explanation, but I did found another source of information including the same idea:

http://www.cs.uta.fi/wo/slides/lecture%205.ppt</description>
		<content:encoded><![CDATA[<p>Very good explanation, but I did found another source of information including the same idea:</p>
<p><a href="http://www.cs.uta.fi/wo/slides/lecture%205.ppt" rel="nofollow">http://www.cs.uta.fi/wo/slides/lecture%205.ppt</a></p>
]]></content:encoded>
	</item>
</channel>
</rss>
