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

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T30051, the corresponding Phabricator task for complete and up-to-date bug report information.
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