I can't understand a specific part of the Drupal code, namely this snippet:
$account->uid = db_next_id(db_query('SELECT MAX(uid) FROM {users}')->fetchField());
// Allow 'created' to be set by the caller.
if (!isset($account->created)) {
$account->created = REQUEST_TIME;
}
$success = drupal_write_record('users', $account);
This is from the Drupal 7 code
My question is about concurrency. I imagined that two concurrent sessions are executing this and because the lack of transaction handling here they might try to insert two records with the same uid.
Can you tell me why this works in production? How is it possible that Drupal uses no transaction management although for example creating a node usually involves writing records into many different tables.