Rdbms
Wikimedia Rdbms is a database abstraction layer written in PHP, developed as part of MediaWiki.
ChronologyProtector
[edit]The ChronologyProtector feature in the Rdbms library automatically hides database replication lag from end-users. By default, MediaWiki runs from a single database server, which naturally serves the latest data to all users. For larger sites and wiki farms, with multiple database hosts configured (e.g. a primary with one or more replicas), ChronologyProtector ensures a user always sees the effect of their own edits on subsequent page views.
Consider what would happen without ChronologyProtector, on a large site with multiple databases. You save an edit to a page (writes to the primary database), and then view that same page (or e.g. view your contributions, page history, or recent changes). These pages render by reading data from a randomly chosen replica database, which may not yet have processed your changes from the primary DB. Thus making it seem like your edit failed or got lost! ChronologyProtector prevents this by (temporarily, for about one minute) remembering in your browing session that you've made certain database changes. For that minute, any time the Rdbms is reading from a database it will not select a random replica, but a replica that has caught up to your changes. If there isn't a sufficiently up-to-date replica, Rdbms may wait momentarily for it to catch up.
MediaWiki automatically enables the ChronologyProtector feature for you when a cache is configured via $wgMainCacheType (e.g. Memcached or Redis).
You can override which store ChronologyProtector uses, separately from your main caching solution, by setting MicroStash via $wgMicroStashType (since MW 1.43, change 1075647), or $wgChronologyProtectorStash (MW 1.36 - 1.42), or $wgMainStash (change 372220, MW 1.31 - 1.36). If you also operate from multiple regions or data centers, you must additionally route requests with the UseDC=master
cookie to the primary data center.
See also
[edit]- API Documentation
- Source code (GitHub mirror)
- Manual:Database access: For how this library is used in MediaWiki context.
- Manual:Database layout: For MediaWiki core's database schema.
- Database transactions: For how MediaWiki structures transactions and how code should use them.
- MediaWiki database policy
Code stewardship
[edit]- Maintained by MediaWiki Interfaces Team.
- Live chat (IRC): #mediawiki-core connect
- Issue tracker: Phabricator Wikimedia-Rdbms (Report an issue)