Jamie, All<br>Thanks for info.<br><br>If this is the case, I would expect user id to be monotonically increase.<br>I can see my users table, the UIDs follow as<br><br>0,1,2,3,4,5,6,24,25,26,33,40,41,42<br><br>I do uninstall / install of my custom modules, but I hope that is no way related to uid selection.<br>
<br>Just wondering what may cause this.<br><br>Also I delete nodes sometimes.., can that cause this issue, I hope it is unlikely...<br><br>Regards<br>kamal<br>necs, blr<br><br><div class="gmail_quote">On Sat, Dec 1, 2012 at 1:26 PM, Jamie Holly <span dir="ltr"><<a href="mailto:hovercrafter@earthlink.net" target="_blank">hovercrafter@earthlink.net</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">UID is figured by select max(uid). Here is the exact code from user.module:<br>
<br>
if (empty($account->uid)) {<br>
$account->uid = db_next_id(db_query('SELECT MAX(uid) FROM<br>
{users}')->fetchField());<br>
}<br>
// Allow 'created' to be set by the caller.<br>
if (!isset($account->created)) {<br>
$account->created = REQUEST_TIME;<br>
}<br>
$success = drupal_write_record('users', $account);<br>
<br>
$account->uid == 0, which is the same as empty.<br>
<br>
Other modules can influence this via the API, such as hook_user_presave,<br>
but for the core functionality, this is how the UID is figured.<br>
<div class="im HOEnZb"><br>
<br><div style="text-align:right">
Jamie Holly<br></div>
<a href="http://www.intoxination.net" target="_blank">http://www.intoxination.net</a><br>
<a href="http://www.hollyit.net" target="_blank">http://www.hollyit.net</a><br>
<br>
</div><div class="HOEnZb"><div class="h5">On 11/30/2012 9:44 PM, Michael Prasuhn wrote:<br>
> No. If if was just using SELECT MAX(uid) FROM {users} then it wouldn't have gaps like the OP was experiencing.<br>
><br>
> Note that the result from that query is actually fed to db_next_id() which in turn uses a DBMS specific method to ensure unique IDs. (In MySQL this means using an insert query into a table that is set to auto increment and then reading the ID of the inserted record. This cannot produce duplicate keys. see <a href="http://api.drupal.org/api/drupal/includes%21database%21mysql%21database.inc/function/DatabaseConnection_mysql%3A%3AnextId/7" target="_blank">http://api.drupal.org/api/drupal/includes%21database%21mysql%21database.inc/function/DatabaseConnection_mysql%3A%3AnextId/7</a> )<br>
><br>
> -Mike<br>
> __________________<br>
> Michael Prasuhn<br>
> <a href="http://mikeyp.net" target="_blank">http://mikeyp.net</a><br>
><br>
> On Nov 30, 2012, at 5:42 AM, Earnie Boyd <<a href="mailto:earnie@users.sourceforge.net">earnie@users.sourceforge.net</a>> wrote:<br>
><br>
> > On Fri, Nov 30, 2012 at 8:32 AM, Jamie Holly wrote:<br>
> >> This isn't the case in D7. UID is assigned by a SELECT MAX(uid) FROM<br>
> >> {users}. Check user.module line 571.<br>
> ><br>
> > Unless the whole users table is locked then this is guaranteed to fail<br>
> > under heavy use. Some poor user is going to get a DB error of<br>
> > duplicate key. The chances may be small but there is a chance it will<br>
> > happen. Do you know the issue # that caused this to happen?<br>
> ><br>
> > --<br>
> > Earnie<br>
> > -- <a href="https://sites.google.com/site/earnieboyd" target="_blank">https://sites.google.com/site/earnieboyd</a><br>
> > --<br>
> > [ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br>
><br>
<br>
--<br>
[ Drupal support list | <a href="http://lists.drupal.org/" target="_blank">http://lists.drupal.org/</a> ]<br>
</div></div></blockquote></div><br>