[Buildbot-devel] Users, attribute and creation

Georges Racinet gracinet at anybox.fr
Sat Feb 8 15:14:50 UTC 2014


Hi list, it's been a long time.

I'm facing something that looks like a bug, although I'm not 100% sure
it's not the intended behaviour.

In db.users, the method findUserByAttr() creates the user if it can't be
found by attribute in users_info. In the case where the user has never
been seen with that attribute, but already exists (namely with the same
identifier), the creation part will try and introduce a new row in the
users table with that identifier, breaking unicity.

On PostgreSQL, that's an IntegrityError, leading to the fact that the
change that triggered all of this will never be processed, nor its
followers in the same source -> the builder does not react anymore.

Maybe it's clearer to show things rather than to try and write about
them, so here's the current code:

   r = conn.execute(tbl.insert(), dict(identifier=identifier))
   uid = r.inserted_primary_key[0]

   conn.execute(tbl_info.insert(),
                dict(uid=uid, attr_type=attr_type,
                     attr_data=attr_data))

And my hotfix version (which solved the blocking of our builders),
checking for prior existence of an user with that identifier:

    qu = sa.select([tbl.c.uid], whereclause=(tbl.c.identifier ==
identifier))
    rows = conn.execute(qu).fetchall()
    if rows:
        uid = rows[0].uid
    else:
        r = conn.execute(tbl.insert(), dict(identifier=identifier))
        uid = r.inserted_primary_key[0]

    conn.execute(tbl_info.insert(),...

Now the wording of
http://docs.buildbot.net/latest/developer/database.html#module-buildbot.db.users
makes me wonder if that's not the actual intent, or if the caller is wrong.

OTOH, I can't see, unless there's another path, I don't see how it's
possible that a given user may have several different attributes in
users_info. Looks to me that findUserByAttr will always actually
duplicate the user.

I'm seeing this with identifier = "Some Dev <somedev at anybox.fr>", an
existing row in users_info for that uid with
   attr_type='hg', attr_data = "Some Dev <somedev at anybox.fr>

and a call to findUserByAttr with
   attr_type='bzr', attr_data = "Some Dev <somedev at anybox.fr>

that call comes ultimately from a changeset (through master.addChange)

I don't have a great history of finishing up my tasks about buildbot,
but I'm all willing to submit the fix if that's relevant.

Cheers,

-- 
Georges Racinet
Anybox SAS, http://anybox.fr
Bureau: 09 72 39 50 97 / 09 72 39 13 06
Portable: 06 51 32 07 27
GPG: 0x33AB0A35, sur serveurs publics

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 897 bytes
Desc: OpenPGP digital signature
URL: <http://buildbot.net/pipermail/devel/attachments/20140208/f98df310/attachment.bin>


More information about the devel mailing list