Page MenuHomePhabricator

How to setup ChronologyProtector properly?
Closed, ResolvedPublic

Description

Keep receiving [DBReplication] Cannot use ChronologyProtector with EmptyBagOStuff. in debug log.

https://www.mediawiki.org/wiki/Manual:MediaWiki_architecture#Database_and_text_storage explain the Chronology Protector as following:

MediaWiki's "chronology protector" ensures that replication lag never causes a user to see a page that claims an action they've just performed hasn't happened yet. This is done by storing the master's position in the user's session if a request they made resulted in a write query. The next time the user makes a read request, the load balancer read this position from the session, and tries to select a slave that has caught up to that replication position to serve the request. If none is available, it will wait until one is. It may appear to other users as though the action hasn't happened yet, but the chronology remains consistent for each user.

However, we don't find any article or information about how to set up the Chronology Protector. Neither in https://www.mediawiki.org/wiki/Manual:$wgLBFactoryConf nor https://doc.wikimedia.org/mediawiki-core/master/php/ChronologyProtector_8php_source.html.

Could anyone pleased to explain how to use Chronology Protector for Mediawiki?

Thank you in advance!

Event Timeline

Zoglun created this task.Feb 10 2019, 2:24 PM
Restricted Application added a subscriber: Aklapper. · View Herald TranscriptFeb 10 2019, 2:24 PM
Krinkle closed this task as Resolved.Tue, Jul 23, 7:00 PM
Krinkle claimed this task.
Krinkle moved this task from General library to Wiring for MediaWiki on the Mediawiki-Rdbms board.
Krinkle added a subscriber: Krinkle.

The ChronologyProtector feature of wikimedia/rdbms is configured for MediaWiki in ServiceWiring#DBLoadBalancerFactory and MWLBFactory::injectObjectCaches().

The BagOStuff instance passed to ChronologyProtector is that of MediaWikiServices#getMainObjectStash.

By default, the "main stash" (documentation) will use your MySQL database to store its data.

While that is fine for most things that MediaWiki needs to store in the Main Stash, it is not suitable for Chronology Protector.

The reason: We cannot use the database to keep track of how much the database is lagged. Because the information itself would also be affected by replication lag.

Conclusion:

  • If your website has only 1 database server (Or 1 master and 1 replica server), then you do not need Chronology Protector at all. You will be fine without it. The ChronologyProtector mainly exists to ensure consistency of the page history and user contributions when users visit multiple pages on the wiki, and each time they load a page, it might connect them to a different server. If you only have 1 server, you don't have the problem that CP tries to solve.
  • If you host a large wiki with multiple database servers, you will want to have Chronology Protector. To use it, you will need a caching system such as Memcached or Redis and register this system via $wgObjectCaches, then point $wgMainStash to it. CP will then automatically use it.
Restricted Application added a project: Core Platform Team. · View Herald TranscriptTue, Jul 23, 7:00 PM

Cool thank you @Krinkle !