<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=text/html;charset=iso-8859-1 http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.23543"></HEAD>
<BODY style="PADDING-LEFT: 10px; PADDING-RIGHT: 10px; PADDING-TOP: 15px"
id=MailContainerBody leftMargin=0 topMargin=0 CanvasTabStop="true"
name="Compose message area">
<DIV><FONT size=2 face=Arial>I did not hit this problem (or maybe I
just did not notice it), but recently I took a look</FONT></DIV>
<DIV><FONT size=2 face=Arial>at the adodb library GenID function that creates
unique IDs for sequences and for me it seems</FONT></DIV>
<DIV><FONT size=2 face=Arial>that this function may not be safe under some
circumstances.</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>Most objects use the singleton instance of the
global $adb PearDatabase object.</FONT></DIV>
<DIV><FONT size=2 face=Arial>1. The genID function of the underlaying adodb
object is not thread safe, as it uses</FONT></DIV>
<DIV><FONT size=2 face=Arial> $this->genID to store intermediate
result and return it upon function exit.</FONT></DIV>
<DIV><FONT size=2 face=Arial> But this should not be an issue, as
script execution is single-threaded and each</FONT></DIV>
<DIV><FONT size=2 face=Arial> HTTP request will get its own $adb
object.</FONT></DIV>
<DIV><FONT size=2 face=Arial>2. The genID function is using last_insert_id,
which works only if the database connection</FONT></DIV>
<DIV><FONT size=2 face=Arial> is used only by a single script
and single thread. I don't know what happens</FONT></DIV>
<DIV><FONT size=2 face=Arial> if the web server uses
connection pooling. Maybe it is possible that the same database</FONT></DIV>
<DIV><FONT size=2 face=Arial> connection </FONT><FONT size=2
face=Arial>is shared between concurrent HTTP requests and therefore
last_insert_id</FONT></DIV>
<DIV><FONT size=2 face=Arial> may return incorrect
values.</FONT></DIV>
<DIV style="FONT: 10pt Tahoma"><FONT face=Arial></FONT><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"><FONT face=Arial></FONT> </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 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 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>
<HR>
<P></P>_______________________________________________<BR>http://www.vtiger.com/</BODY></HTML>