Last modified: 2011-03-15 00:41:52 UTC

Wikimedia Bugzilla is closed!

Wikimedia has migrated from Bugzilla to Phabricator. Bug reports should be created and updated in Wikimedia Phabricator instead. Please create an account in Phabricator and add your Bugzilla email address to it.
Wikimedia Bugzilla is read-only. If you try to edit or create any bug report in Bugzilla you will be shown an intentional error message.
In order to access the Phabricator task corresponding to a Bugzilla report, just remove "static-" from its URL.
You could still run searches in Bugzilla or access your list of votes but bug reports will obviously not be up-to-date in Bugzilla.
Bug 28051 - Abstract DB_MASTER and DB_SLAVE out of core code
Abstract DB_MASTER and DB_SLAVE out of core code
Status: RESOLVED WONTFIX
Product: MediaWiki
Classification: Unclassified
Database (Other open bugs)
unspecified
All All
: Normal enhancement (vote)
: ---
Assigned To: Nobody - You can work on this!
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-03-15 00:27 UTC by Adam Wight
Modified: 2011-03-15 00:41 UTC (History)
1 user (show)

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Adam Wight 2011-03-15 00:27:43 UTC
The master/slave logic could easily be pushed into db-specific code, as has been done with db/LoadBalancer.  It is an installation-specific concept, and I believe it should be decoupled from core code.

Most queries can be directed to the correct server based on Database::isWriteQuery, and in exceptional cases a flag could be provided, to select from master.
Comment 1 Tim Starling 2011-03-15 00:41:52 UTC
There are important caveats involving reading from slave servers. We expose the master/slave distinction in the interface to ensure that developers writing calling code are aware of the distinction. 

For instance, it is not generally possible to read data from a slave server and then to write it to memcached, because the stale data would be cached indefinitely. It's necessary to either do such read queries against the master, or to check the data returned by the slave for freshness using a separate query against the master.

The flag would need to be set not just in exceptional cases, but in large amounts of code that depends on transactions and consistent reads in order to do accurate write queries. Saving the flag in object state with wfGetDB(), instead of providing it separately for each query, makes such code simpler and less prone to errors.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links