test-backend: Fix db issues with running two copies in parallel.
test-backend: Fix db issues with running two copies in parallel.

Sometimes it's useful to run two copies of test-backend at the same
time.  The problem with doing so is that we need to make sure no two
threads are using the same test database ID.

Previously, this worked only if at most one of those copies was
running in the single-threaded mode, because we used a random database
ID for the single-threaded code path, but the same IDs counting from 0
for the parallel code path.

Fix this, mostly, by generating a random start for the range of IDs
used by the process, and then counting off database IDs starting from
there (both in the parallel and non-paralllel modes).

There's still a very low probability race, see the TODO.
Additionally, there appear to be some other races with running two
copies of test-backend at the same time not related to the database.

See https://github.com/zulip/zulip/issues/12426 for a follow-up issue
that's sorta created by this.

timabbott/zulip,synicalsyntax/zulip,rht/zulip,kou/zulip,rht/zulip,rht/zulip,andersk/zulip,brainwane/zulip,hackerkid/zulip,synicalsyntax/zulip,brainwane/zulip,rishig/zulip,brainwane/zulip,synicalsyntax/zulip,showell/zulip,shubhamdhama/zulip,kou/zulip,zulip/zulip,tommyip/zulip,tommyip/zulip,showell/zulip,hackerkid/zulip,punchagan/zulip,rishig/zulip,andersk/zulip,zulip/zulip,tommyip/zulip,eeshangarg/zulip,rht/zulip,timabbott/zulip,punchagan/zulip,rishig/zulip,synicalsyntax/zulip,eeshangarg/zulip,kou/zulip,shubhamdhama/zulip,timabbott/zulip,brainwane/zulip,punchagan/zulip,tommyip/zulip,rishig/zulip,hackerkid/zulip,tommyip/zulip,eeshangarg/zulip,kou/zulip,zulip/zulip,punchagan/zulip,andersk/zulip,timabbott/zulip,zulip/zulip,shubhamdhama/zulip,showell/zulip,shubhamdhama/zulip,showell/zulip,hackerkid/zulip,andersk/zulip,showell/zulip,hackerkid/zulip,shubhamdhama/zulip,showell/zulip,tommyip/zulip,tommyip/zulip,andersk/zulip,timabbott/zulip,eeshangarg/zulip,rishig/zulip,synicalsyntax/zulip,punchagan/zulip,zulip/zulip,shubhamdhama/zulip,timabbott/zulip,timabbott/zulip,rishig/zulip,zulip/zulip,hackerkid/zulip,andersk/zulip,punchagan/zulip,brainwane/zulip,rht/zulip,rishig/zulip,kou/zulip,shubhamdhama/zulip,synicalsyntax/zulip,kou/zulip,kou/zulip,brainwane/zulip,brainwane/zulip,rht/zulip,hackerkid/zulip,zulip/zulip,showell/zulip,andersk/zulip,eeshangarg/zulip,synicalsyntax/zulip,eeshangarg/zulip,punchagan/zulip,eeshangarg/zulip,rht/zulip