```
2018-05-09 17:47:48 [WvM-1NApAMEMAADtSlpwAAADA] mw1232 wikidatawiki 1.32.0-wmf.2 DBQuery ERROR: Wikibase\SqlIdGenerator::generateNewId 10.64.48.26 1205 Lock wait timeout exceeded; try restarting transaction (10.64.48.26) SELECT id_value FROM `wb_id_counters` WHERE id_type = 'wikibase-item' LIMIT 1 FOR UPDATE {"db_server":"10.64.48.26","db_name":"wikidatawiki","db_user":"wikiuser","method":"Wikimedia\\Rdbms\\Database::makeQueryException","errno":1205,"error":"Lock wait timeout exceeded; try restarting transaction (10.64.48.26)","sql1line":"SELECT id_value FROM `wb_id_counters` WHERE id_type = 'wikibase-item' LIMIT 1 FOR UPDATE","fname":"Wikibase\\SqlIdGenerator::generateNewId"}
```
This is happening occasionally, 0 to 5 times a day.
#patch-for-review / TODO:
- [x] [add `UpsertSqlIdGenerator`](https://gerrit.wikimedia.org/r/474278)
- [x] [inject generator into store](https://gerrit.wikimedia.org/r/474725)
- [x] [make generator configurable](https://gerrit.wikimedia.org/r/474731)
- [x] enable UpsertSqlIdGenerator on beta
- [x] enable UpsertSqlIdGenerator on test
- [x] enable UpsertSqlIdGenerator on wikidata
- [] Use a seperate connection for ID insertions? T194299#4840260
== Remaining details ==
>>! In T194299#4713654, @hoo wrote:
> @aaron Suggested to use a separate master DB connection for this (if were in a transaction and don't immediately autocommit), so that it never ends up in the main transaction. That might mean slightly more wasted IDs, but should significantly reduce contention.
>>! In T194299#4714614, @aaron wrote:
> openConnection is badly named and still reuses connections. You'd probably want getConnection with CONN_TRX_AUTO
== Acceptance criteria ==
[] UpsertSqlIdGenerator can generate ids using a seperate master db connection
[] SqlIdGenerator can generate ids using a seperate master db connection
[] Use of a seperate master db connection is configurable
[] The default configuration is false