Just set up exception logging and noticed the following:
```
2020-07-13 14:15:13 /w/api.php WikimediaRdbmsDBReadOnlyRoleError fro
m line 968 of .../includes/libs/rdbms/database/Database.php: Write operations are not allowed on repli
ca database connections
er()
string, integer)
integer)
y)
query(string, string, integer)
#5 .../extensions/SemanticMediaWiki/src/SQLStore/TableBuilder/TemporaryTableBuilder.php(59): SMWMediaWiki
ConnectionDatabase->query(string, string, boolean)
reTableBuilderTemporaryTableBuilder->create(string)
reQueryEngineQuerySegmentListProcessor->disjunction(SMWSQLStoreQueryEngineQuerySegment)
reQueryEngineQuerySegmentListProcessor->segment(SMWSQLStoreQueryEngineQuerySegment)
reQueryEngineQuerySegmentListProcessor->table(SMWSQLStoreQueryEngineQuerySegment)
oreQueryEngineQuerySegmentListProcessor->segment(SMWSQLStoreQueryEngineQuerySegment)
eQuerySegmentListProcessor->process(integer)
getQueryResult(SMWQuery)
...
...
Isn't this something for https://www.semantic-mediawiki.org/wiki/Help:$smwgLocalConnectionConf ?
Oops! I was going to put that setting here, but here is what I have:
$smwgLocalConnectionConf = [
'mw.db' => [
'read' => DB_REPLICA,
'write' => DB_MASTER
],
# needed because we have the to keep the queries on the same db
'mw.db.queryengine' => [
'read' => DB_MASTER,
'write' => DB_MASTER,
] ];
Thanks for posting this. Appears that this Pecuniar XtraDB database engine is a real pain in the you know where. I suspect that this case cannot be supported, at least out of the box, since SMW needs temporary tables for generating results which at the same time cannot be replicated. I may however be mistaken here.
You could be right, but, on further examination, I see that this error occurs when the site is read-only, which means that there would be no DB_MASTER above, only DB_REPLICA.
FWIW, Percona is just MySQL with clustering (and some more strictness about semantics), so this probably affects MySQL as well.
so this probably affects MySQL as well.
Lucky us that it this did not show for regular MySQL yet.
This is not a Percona/MySQL issue. MediaWiki has been blocking write operations (incl. temporary table writes) on a read-only replica connection for some time now.
The check occurs here: https://github.com/wikimedia/mediawiki/blob/master/includes/libs/rdbms/database/Database.php#L1258
Looks like this changed in https://phabricator.wikimedia.org/T183265, back in 2017.
@hexmode out of curiosity, are you using a replicated setup here, or is it a single-node environment?
So this is an issue from something like MW 1.32 (guess) till 1.34 but will be fine on MW 1.35+. Not sure something should be done on SMW side then. @hexmode you could always apply @mszabo-wikia his patch.
Yeah. The patch may need a little tweaking for < 1.35 but the gist of it should remain the same.
@mszabo-wikia thanks so much for digging to the root of this and fixing it.
Closing the issue as there does not seem to be anything left to do on SMW side.
Most helpful comment
https://phabricator.wikimedia.org/T259362, https://gerrit.wikimedia.org/r/c/mediawiki/core/+/617741 opened.