<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">I agree, I had noticed this also
although we haven't run into the problem either (at least that we
know of).<br>
<br>
+1<br>
<br>
On 08/01/14 13:48, Zygmuntowicz Michal wrote:<br>
</div>
<blockquote cite="mid:5D26706BABF84CBB835880B476D968FD@zyga"
type="cite">
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
<meta name="GENERATOR" content="MSHTML 8.00.6001.23543">
<div><font face="Arial" size="2">I did not hit this problem (or
maybe I just did not notice it), but recently I took a look</font></div>
<div><font face="Arial" size="2">at the adodb library GenID
function that creates unique IDs for sequences and for me it
seems</font></div>
<div><font face="Arial" size="2">that this function may not be
safe under some circumstances.</font></div>
<div> </div>
<div><font face="Arial" size="2">Most objects use the singleton
instance of the global $adb PearDatabase object.</font></div>
<div><font face="Arial" size="2">1. The genID function of the
underlaying adodb object is not thread safe, as it uses</font></div>
<div><font face="Arial" size="2"> $this->genID to store
intermediate result and return it upon function exit.</font></div>
<div><font face="Arial" size="2"> But this should not be an
issue, as script execution is single-threaded and each</font></div>
<div><font face="Arial" size="2"> HTTP request will get its own
$adb object.</font></div>
<div><font face="Arial" size="2">2. The genID function is using
last_insert_id, which works only if the database connection</font></div>
<div><font face="Arial" size="2"> is used only by a single
script and single thread. I don't know what happens</font></div>
<div><font face="Arial" size="2"> if the web server uses
connection pooling. Maybe it is possible that the same
database</font></div>
<div><font face="Arial" size="2"> connection </font><font
face="Arial" size="2">is shared between concurrent HTTP
requests and therefore last_insert_id</font></div>
<div><font face="Arial" size="2"> may return incorrect values.</font></div>
<div style="FONT: 10pt Tahoma"><font face="Arial">3. I am not sure
if the sequence tables should be locked - I guess
autoincrement columns</font></div>
<div style="FONT: 10pt Tahoma"><font face="Arial"> should be
transaction safe.</font></div>
<div style="FONT: 10pt Tahoma"> </div>
<div style="FONT: 10pt Tahoma"><font face="Arial">These are only
my thoughts - I think someone with good understanding of the
web server/mysql/php</font></div>
<div style="FONT: 10pt Tahoma"><font face="Arial">interactions
should throw some light on this.</font></div>
<div style="FONT: 10pt Tahoma"><br>
</div>
<div style="FONT: 10pt Tahoma; BACKGROUND: #f5f5f5">
<div style="font-color: black"><b>From:</b> <a
moz-do-not-send="true" title="ich@stefanwarnat.de"
href="mailto:ich@stefanwarnat.de">Stefan Warnat</a> </div>
<div><b>Sent:</b> Wednesday, January 08, 2014 12:05 PM</div>
<div><b>To:</b> <a moz-do-not-send="true"
title="vtigercrm-developers@lists.vtigercrm.com"
href="mailto:vtigercrm-developers@lists.vtigercrm.com">vtigercrm-developers@lists.vtigercrm.com</a>
</div>
<div><b>Subject:</b> [Vtigercrm-developers] Duplicate CRMIDs
5.40</div>
</div>
<div><br>
</div>
<div dir="ltr">Hy,
<div><br>
</div>
<div>Yesterday I found a very strange situation in one of my
clients vtiger 5.4 systems.</div>
<div>The System ~250k records contains Leads with a leadid,
which isn't a "setype LEAD" in vtiger_crmentity.</div>
<div>Some are Contacts, other Accounts, Tickets, ...</div>
<div>Also the ID exist correctly in the respective tables of
contacts, accounts, ...</div>
<div><br>
</div>
<div>I create the following problem situation:</div>
<div>Two records are created in absolutely the same moment. (The
createdtime column is completely equal)</div>
<div>Because ADODB don't lock the sequence table, there could be
a chance of duplicate crmid's, I suspect.</div>
<div>I'm not fully sure how safe the used "LAST_INSERT_ID(id+1)"
is. </div>
<div>The normal "LAST_INSERT_ID()" is per connection, but only
get back a auto increment.</div>
<div><br>
</div>
<div>Anyone other with this problem?</div>
<div><br>
</div>
<div>Stefan</div>
</div>
<p>
</p>
<hr>
_______________________________________________<br>
<a class="moz-txt-link-freetext" href="http://www.vtiger.com/">http://www.vtiger.com/</a>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">_______________________________________________
<a class="moz-txt-link-freetext" href="http://www.vtiger.com/">http://www.vtiger.com/</a></pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
Un saludo
Joe
TSolucio</pre>
</body>
</html>