Build Request Query
Many of the reports (End to End Times Report, Build Run Report, TryChooser Report, Average Time per Builder Report, Builder Report) use BuildRequests as constructing blocks. In this post I will describe how BuildRequests are fetched from Buildbot’s scheduler database.
First of all, scheduler database has the following schema:
The information about one BuildRequest is spread among at least 5 tables: builds, buildrequests, buildsets, sourcestamps, sourcestamp_changes and changes. Which means there is no other way to fetch the data we need other than creating a big JOIN/OUTERJOIN for the 5 above mentioned tables. This rather unfriendly query is necessary as a result of scheduler database’s design to work optimal with Buildbot’s internal mechanisms rather than our current query’s need.
The actual query, using SQLAlchemy, looks like this:
b = meta.scheduler_db_meta.tables['builds']
br = meta.scheduler_db_meta.tables['buildrequests']
bs = meta.scheduler_db_meta.tables['buildsets']
s = meta.scheduler_db_meta.tables['sourcestamps']
sch = meta.scheduler_db_meta.tables['sourcestamp_changes']
c = meta.scheduler_db_meta.tables['changes']q = outerjoin(br, b, b.c.brid==br.c.id) \
.join(bs, bs.c.id==br.c.buildsetid) \
.join(s, s.c.id==bs.c.sourcestampid) \
.outerjoin(sch, sch.c.sourcestampid==s.c.id) \
.outerjoin(c, c.c.changeid==sch.c.changeid) \
.select().with_only_columns([...]) \
.group_by(br.c.id, b.c.id)
Query explained:
JOINS:
- OUTERJOIN (LEFT OUTER JOIN) between buildrequests and builds tables – OUTERJOIN is required because some of the BuildRequests might be PENDING or be CANCELLED (thus having no builds, i.e. entries in the builds table)
- JOIN with buildests table on buildsets‘ id column (bs.id = br.buildsetid) – we need to go through the buildesets table in order to link the BuildRequests to the sourcestamps and changes information
- JOIN with sourcestamps table – sourcestamps information
- OUTERJOIN with sourcestamp_changes on sourcestamps‘ id column (s.id = sch.sourcestampid) – linking further along to changes. An OUTERJOIN was necessary instead of an INNER JOIN, because the nightly builds don’t have a revision number or any entries in the changes table
- OUTERJOIN with changes table on changes‘ changeid column (sch.changeid = c.changeid) – OUTERJOIN again needed in order to include all BuildRequests belonging to nightly builds (see JOIN 4. above)
GROUP BY:
A final group by buildrequests.id and builds.id columns (GROUP BY br.id, b.id) is needed to capture multiple builds for the same BuildRequest. One BuildRequest might have multiple builds (usually very few and at most 2 or 3), if the builds have been retriggered or forced build manually.
Selected table columns explained:
- b.number
- b.c.start_time
- b.c.finish_time
- br.c.id.label(‘brid’)
- br.c.buildername
- br.c.submitted_at
- br.c.claimed_at
- br.c.claimed_by_name
- br.c.complete
- br.c.complete_at
- br.c.results
- br.c.buildsetid
- bs.c.reason
- s.c.id.label(‘ssid’)
- s.c.branch
- s.c.revision
- c.c.when_timestamp
- c.c.author
- c.c.comments
- c.c.revlink
- c.c.category
- c.c.repository
- c.c.project
BuildRequest statuses:
- PENDING – the BuildRequest has not started yet / no Build Master claimed it yet:
- RUNNING – the BuildRequest is running (a Build Master claimed the BuildRequest already), and has not finished yet:
- COMPLETE – the BuildRequest was completed without any internal errors or external interruptions (i.e. not CANCELLED / INTERRUPTED):
- CANCELLED – the BuildRequest was cancelled (i.e. it never got to start):
- INTERRUPTED – the build was interrupted (e.g. slave disconnected) and Buildbot retriggered the build:
- MISC – should never happen
BuildRequest results (buildrequests.results):
This column specifies how the BuildRequest execusion went, if it is completed. Naturally, the PENDING and RUNNING ones will have NO_RESULT:
- -1 (NULL) – NO_RESULT
- 0 – SUCCESS
- 1 – WARNINGS
- 2 – FAILURE
- 3 – SKIPPED
- 4 – EXCEPTION
- 5 – RETRY
BuildRequest reasons (buildsets.reason):
The reason of the build, might be the scheduler (normal case), the nightly sheduler, a rebuild or forced build:
- scheduler
- nightly, e.g. ‘The Nightly scheduler named ‘Linux x86-64 mozilla-central nightly’ triggered this build’
- rebuild, e.g. ‘The web-page ‘rebuild’ button was pressed by ‘<unknown>’: redo for slave disconect (nthomas)’
- force build, e.g. ‘The web-page ‘force build’ button was pressed by ‘jhford’: hg poller is busted’
BuildRequest wait time:
How much the BuildRequest waited from when the change was created or the time it was submitted (only for nightlies because they have no changes) until the build has started (was assigned to a free slave):
change_time := c.when_timestamp, if c.when_timestamp != NULL
:= br.submitted_at, otherwise
WAIT_TIME := b.start_time – change_time, if b.start_time != NULL AND change_time != NULL
:= 0, otherwise
BuildRequest duration:
How long from when the change was created or the time it was submitted (only for nightlies because they have no changes) until the build was complete, whether if successful or not:
change_time := c.when_timestamp, if c.when_timestamp != NULL
:= br.submitted_at, otherwise
DURATION := br.complete_at – change_time, if br.complete_at != NULL AND change_time != NULL
:= 0, otherwise
BuildRequest run time:
The actual run time of the build:
RUN_TIME := DURATION – WAIT_TIME
See Also: Wait Times Query, Pushes Query


[...] Wait Times Query is very similar to Build Request Query, only that it fetches jobs (does not care about multiple builds of the same BuildRequest), it [...]
Wait Times Query « Anamaria Stoica
October 13, 2010 at 12:30 am
[...] very important piece of information that can be extracted from the Scheduler Database, besides build requests and jobs, are [...]
Pushes Query « Anamaria Stoica
October 15, 2010 at 4:51 am
[...] every few minutes. The changes are picked up by the Build Scheduler Master, which creates Build Requests, one for each of the supported platforms. The Build Requests go into the Scheduler Database as [...]
Mozilla’s Build System « Anamaria Stoica
November 8, 2010 at 8:57 am
[...] push to hg.mozilla.org triggers off the Build System to generate a certain number of Build Requests (depending on the branch). All these build requests make up a Build Run. In a previous post I have [...]
Build Run Report « Anamaria Stoica
November 12, 2010 at 10:28 am
[...] orange for warnings, red for exception and failure and gray for no result (“-”) (if all Build Requests are currently running or [...]
End to End Times Report « Anamaria Stoica
November 15, 2010 at 6:47 am
[...] every few minutes. The changes are picked up by the Build Scheduler Master, which creates Build Requests, one for each of the supported platforms. The Build Requests go into the Scheduler Database as [...]
Mozilla’s Build System « SLQ
May 27, 2011 at 10:17 pm