In a charmed deployment, the PostgreSQL charm will provide us with a
full connection string including the user, and we won't want to override
that. Allow setting `config.launchpad_session.dbuser` to None to
disable the arrangements that currently let us override the user on a
per-deployment basis. This has no effect on existing deployments.
Fix the condition for dispatching tokens for private source files
If a librarian request has a token, then the librarian will only serve
restricted files. In the case of source package release files, this
isn't quite synonymous with files in private archives: source files in
private archives may be unrestricted if the same source package is also
published in a public archive. Only dispatch tokens for source files
that are actually restricted.
If a gauge has a value of None (e.g. the PPA latency statistics when no
builds have happened recently, which can easily happen on dogfood), then
the statsd client will raise `TypeError`. Skip sending the gauge to
statsd in this case.
Fix race between branchChanged requests and branch scan jobs
If a `branchChanged` XML-RPC request happened to run at the same time as
a branch scan job for the same branch, then they may race to update the
same `Branch` row, causing one to have to roll back its transaction and
try again. However, a bug in the `transaction` library meant that the
exception raised by the before-commit hook to gather job state was
incorrectly ignored, and as a result an `InFailedSqlTransaction`
exception was raised instead, which isn't retried.