List of steps to reproduce (step by step, including full links if applicable):
- In a fresh Wikibase installation, create an item to get Item:Q1
- Export the item as XML (e.g. using /Special:Export/Item:Q1)
- In a second fresh Wikibase installation, import the XML
- Attempt to create a new item in the fresh Wikibase installation via Special:NewItem
What happens?:
Receive an error about the item already existing.
In the first screenshot, you can see the error.
The second shows that the error is not caused by the label already being used.
The third serves to confirm that the second would have turned up a match by correctly finding the imported item.
What should have happened instead?:
A new Item was created
Software version (if not a Wikimedia wiki), browser information, screenshots, other information, etc:
Installed Software
MediaWiki 1.36.1
PHP 7.4.22 (fpm-fcgi)
MariaDB 10.5.11-MariaDB
ICU 67.1
LuaSandbox 4.0.2
Lua 5.1.5
Installed Skins
Timeless 0.9.1 (80cc022) 18:56, 23 July 2021
Vector 1.0.0 (b9deb92) 19:04, 23 July 2021
Installed extensions
Flagged Revisions – (c63cb4d) 19:16, 22 July 2021
CodeEditor – (e587a94) 12:59, 22 July 2021
WikiEditor 0.5.3 (cf1d759) 14:23, 23 July 2021
ParserFunctions 1.6.0 (d999660) 13:28, 27 May 2021
Scribunto – (ac71012) 21:34, 23 July 2021
TitleBlacklist 1.5.0 (67533b2) 05:07, 28 May 2021
WikibaseClient – (a00a340073)
WikibaseRepository – (a00a340073)
WikipartmentsGeocode 0.1.0
WikipartmentsMessages 0.0.0
(The last two are custom extension of mine.)
More information
This issue is caused by the import process not updating (and/or creating) entries in the wb_id_counters table.
(See also https://wikibase.consulting/transferring-wikibase-data-between-wikis/)
Because id generation happens non-atomically with entity creation, failing to create the item still updates the wb_id_counters table with an incremented id. In the specific reproduction case given here, this means a second attempt to create the item will succeed. If more items were imported, however, attempts will fail until the id is incremented to an unused id.
If non-sequential ids are imported, this will create failures sporadically (whenever an attempt to reuse an imported id is reached).