Commit graph

1445 commits

Author SHA1 Message Date
Bartosz Dziewoński
c161c46d26 Improve code suffering from PHP 5.3's lack of support for foo()[]
I searched for /\$(\S+) = (.+?\(.*?\);)\n.*?\$\1\[/, ignored
everything involving isset(), unset() or array assigments, then
skimmed through the remaining results and changed things where they
made sense. These changes were not automated, so please review them.

Change-Id: Ib37b4c66fc57648470f151ad412210b3629c2538
2016-02-28 22:49:20 +01:00
jenkins-bot
d2193f9d1d Merge "Ignore noop DB transactions errors on connection loss" 2016-02-26 16:09:11 +00:00
Matthew Flaschen
d4d086b0ce IDatabase::commit: Docs re 'flush' exception on explicit transaction
Change-Id: I44087e92d2186f4e931b3f0766caba1f90f4ebc4
2016-02-24 18:22:30 -05:00
Aaron Schulz
38f0c07279 Ignore noop DB transactions errors on connection loss
This avoids some needless exceptions for longer running scripts.

Bug: T127428
Change-Id: I3098141aa77a4c73cb2a0c784b38b15c712f82a9
2016-02-24 00:35:03 +00:00
jenkins-bot
d42754e477 Merge "database: Add extra sanity check to selectFieldValues()" 2016-02-18 14:46:29 +00:00
Aaron Schulz
ff23e83f41 database: Add extra sanity check to selectFieldValues()
Change-Id: Ia2788ea84bd099550655930188365984e5274678
2016-02-18 14:38:44 +00:00
Kunal Mehta
6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00
Aaron Schulz
ef44f4308e Upgrade mismatched commit() warnings to exceptions
I saw no WMF logs for these in the last 7 days.

Change-Id: I725535925ba3fc68cee485767f18937fb8f239bf
2016-02-12 21:32:00 +00:00
Ricordisamoa
1e37987beb Follow-up to 02818c441c
* Remove obsolete @protected tag from docstring
  of DatabaseBase::indexName(), now really protected

* Make DatabaseSqlite::indexName() protected too

Change-Id: I90f894878379d0850dba61cd483af16864c209ea
2016-02-11 00:09:05 +01:00
Ricordisamoa
02818c441c Stop doing $that = $this in includes/db
Closures support $this as of PHP 5.4

Also made DatabaseBase::indexName() protected

Change-Id: Iff31e7d9186832a855a953b923ac182f1c66ffa0
2016-02-10 18:08:17 +01:00
Aaron Schulz
39ef7941b0 Style and commenting tweaks to CategoryMembershipChangeJob
Also renamed safeWaitForPos() => safeWaitForMasterPos()

Change-Id: Ic89e2a0b17cd6e6ef09cf703bbbcea1988a5bde9
2016-01-30 10:27:28 -08:00
jenkins-bot
c32764db69 Merge "Do not auto-reconnect to DBs if named locks where lost" 2016-01-30 18:07:35 +00:00
Aaron Schulz
79d12a284b Do not auto-reconnect to DBs if named locks where lost
Otherwise, transactions might be committed without cooperative
locks that were supposed to be present. This is similar to the
logic of not auto-reconnecting if a transaction was started to
avoid committing incomplete changes.

Change-Id: Ia7bc6b188bb5ee53a5bf7c5a30718bc7c4dd0ba9
2016-01-30 09:17:17 -08:00
Aaron Schulz
4e62537a8b Make sure getScopedLockAndFlush() commits before unlocking
This is necessary for callers to see changes from prior callers

Change-Id: I5e05215541e641b5b5a4bc55c91d6ec8ef774ca1
2016-01-30 08:52:06 -08:00
jenkins-bot
4ebf6581f5 Merge "Improve safeGetLag() return docs" 2016-01-30 13:35:39 +00:00
Aaron Schulz
b088acbb63 Improve safeGetLag() return docs
Change-Id: I7b2d0d96901412abe8bdf9abee39e6d545c94644
2016-01-29 15:09:59 -08:00
Aaron Schulz
982869d6b0 Fix IDEA error in safeWaitForPos()
Change-Id: Iecb023925177be05282f67e48056aeb8f2a9703c
2016-01-29 14:47:38 -08:00
Aaron Schulz
69c71cc45e Add LoadBalancer::safeWaitForPos()
This is useful for waiting on a specific slave handle to
reach a given master position.

Change-Id: Ia4569c4fc82c25eb4089cf7198f01e349636e2c7
2016-01-29 13:05:41 -08:00
Aaron Schulz
60013aa328 Add IDatabase::getScopedLockAndFlush() method
This method is less manual and avoids the usual pitfalls of
not unlocking for a return statement or not flushing out any
prior transaction.

Change-Id: Ib1681244767de860105a68210e181e2f024ee525
2016-01-29 20:32:05 +00:00
Aaron Schulz
cca0a7e135 Move MaxUserDBWriteDuration logic to LBFactory
Change-Id: If7231af24f10ae29b7137f147abb60a351c9127f
2016-01-28 17:31:27 -08:00
Aaron Schulz
36a87a8902 Convert page creation to using startAtomic()/endAtomic()
A few semantic changes result from this:

* If multiple pages are created in a request, the updates happen
  in the same order relative to each other, but all in one second
  step instead of after each page edit.
* If an extension set some extra Status info or errors via the
  PageContentInsertComplete hook, they will not be seen by the
  caller (unless it was a CLI script possibly). Few callers use
  $status at all, and I did not see any that mutated it. Since
  the page is already committed when this hooks run (as has always
  been) they cannot veto edits and callers do not care or know what
  to do with random hook-set status errors; there was never much use
  in changing the Status anyway.

Bug: T120718
Change-Id: Ieba35056be31b2f648c57f59d19d3cbbe58f1b05
2016-01-27 11:38:05 -08:00
jenkins-bot
a7f35b7859 Merge "Deprecate wfWaitForSlaves() with LBFactory::waitForReplication()" 2016-01-20 00:10:39 +00:00
Aaron Schulz
b527783de9 Log multi-DB write transactions
Bug: T122387
Change-Id: I03447f8c8465775a70c6a94f24ce196973703ce3
2016-01-15 16:02:02 -07:00
Aaron Schulz
fef85e5d92 Add better error logging for DB getLag() calls
Bug: T32257
Change-Id: I4ea5db670fe96d20b1d593cc2d759f9c3f570790
2016-01-14 01:34:56 +00:00
Aaron Schulz
0599bd94eb Remove pointless rollback() warnings with "flush"
This would previously make log noise when rollbackMasterChangesAndLog()
is triggered for explicit transactions.

Change-Id: Ia0009bcf575ef346d3bb7354ce3fb6fb477eb95f
2016-01-13 07:00:45 -08:00
Aaron Schulz
f86bd0a7eb Remove pointless rollback() warnings with "flush"
This would previously make log noise when rollbackMasterChangesAndLog() runs

Change-Id: I36dd955a89b23ed6d1ea693cf5366c7d3ad8d3af
2016-01-13 06:44:08 -08:00
jenkins-bot
afbbc86090 Merge "Dependency inject TransactionProfiler into DatabaseBase" 2016-01-12 20:05:36 +00:00
Aaron Schulz
7c8edbec73 Dependency inject TransactionProfiler into DatabaseBase
Change-Id: Ie5fc8120c3a3a5afe17897084d345f5fdb06843c
2016-01-06 14:58:31 -08:00
Aaron Schulz
75c09d9b31 Remove redundant DatabaseBase doc comments
Change-Id: I7f65d46dd05c6d9f72ec2e11ebba11f0b0854983
2016-01-05 23:56:27 +00:00
jenkins-bot
e53676d3dd Merge "Show user names as subpages of special pages in autocomplete search" 2015-12-30 00:16:20 +00:00
umherirrender
3e0f3cfd43 Show user names as subpages of special pages in autocomplete search
The autocomplete search allows special pages to define the list of
subpages to be excepted. Use user names on the following special pages,
because these special pages can be called with a user name as subpage.

Special:Block
Special:Contributions
Special:DeletedContributions
Special:Emailuser
Special:Listfiles
Special:Unblock
Special:Userrights

This makes it easier to navigate to this special pages with a prefilled
user name field.

Hidden user names are always not shown, because the suggestion is cached
between priviliged user and non-priviliged user.

Change-Id: I7db575bf66caaa5136489ed99f1655673b55adaf
2015-12-29 11:49:58 +01:00
Aaron Schulz
3ab0c7d4d7 Added IDatabase::doAtomicSection() convenience method
This can replace startAtomic/endAtomic pairs.

Bug: T122115
Change-Id: I01c8e4773ec2b42dbe87a5508a10b997be103c11
2015-12-28 23:11:56 +00:00
jenkins-bot
7028f7e31c Merge "Make getLagFromPtHeartbeat() always use the LB cluster master entry" 2015-12-23 23:27:30 +00:00
Aaron Schulz
fedfee628c Deprecate wfWaitForSlaves() with LBFactory::waitForReplication()
This has a cleaner interface and makes failure more explicit

Change-Id: I5480845196383df85ba7538e15e507fa1b64948a
2015-12-22 21:05:44 -08:00
Aaron Schulz
58cffd04b8 Pass __METHOD__ to load balancer commit/rollback methods
Change-Id: I3fd87908c2a493fae49de6a29efe79f8d433c112
2015-12-22 18:30:20 -08:00
Aaron Schulz
d75aec5975 Let LBFactory/LoadBalancer transaction methods take __METHOD__
Also send commitAll() times to statsd like commitMasterChanges().

Change-Id: I261ca89f00e40b35f2ddeef6845b111720e7e43c
2015-12-22 20:08:48 +00:00
Aaron Schulz
7643d7d885 Avoid "Incorrect user-level lock name " errors in Database lock() method
Use a sha1 hash if the lock name exceeds the MySQL limit. The class
for Postgres already avoids this problem with number hashes.

Change-Id: If587c672b4ff210ee3b512bbe2910ae247079d3f
2015-12-16 16:00:46 +00:00
Aaron Schulz
9c0b55d926 Make getLagFromPtHeartbeat() always use the LB cluster master entry
Before, it just used the immediate master entry, which could be another
slave. In that case, it may not even exists at all.

Bug: T119648
Change-Id: Iea970b81ad2c9855aafcccf0bb0662fc0b3a8d4d
2015-12-09 22:00:19 -08:00
jenkins-bot
1d489846c1 Merge "Fix various mistakes in PHPDoc comments" 2015-12-09 18:13:19 +00:00
Thiemo Mättig
53c5a52970 Fix various mistakes in PHPDoc comments
Change-Id: I434207f61e0663f2d2c9a076296c2e0d04a3fafb
2015-12-09 18:20:41 +01:00
Aaron Schulz
aed92ddf2a Fix edge case in onTransactionIdle()
If a callback set DBO_TRX, make sure it gets unset if that
is not what the DB was set to before the callbacks ran.

Change-Id: I79b649de02e821494d7f88e8979764ec8a9d0c43
2015-12-07 17:26:15 -08:00
Aaron Schulz
c30b049580 Add $wgMaxUserDBWriteDuration to limit user-generated transactions
This is a low level catch-all net for huge updates that still slip
through. Features that let users add/remove arbitrarily many rows
to lists of arbitrary size can easily result in high lag due to
strange usage patterns or deliberate attacks.

Also removed duplicate 'autochange-username' JSON key.

Bug: T95501
Change-Id: I58a91ca23cae528ef1954d2d78c8f0a90681983e
2015-12-04 13:08:52 -08:00
Aaron Schulz
cb8842dbab Make getCacheSetOptions() and WAN cache handle broken replication
TTL_LAGGED now triggers if the slave or I/O threads stopped

Change-Id: I5e7bf2d33b8d3a60182ec53a93d65f7e55f02222
2015-12-02 15:38:23 -08:00
Reedy
00c426e3c2 Replace wfBaseConvert with Wikimedia\base_convert
Change-Id: Iadab3d018c3559daf79be90edb23d131729bdb68
2015-11-24 22:51:42 +00:00
jenkins-bot
bd3e6861c6 Merge "Improve docs for lag related DB functions" 2015-11-19 07:33:19 +00:00
Aaron Schulz
36f025f8c9 Improve docs for lag related DB functions
* They can return false if replication is stopped.
* Also remove redundant related doc blocks.

Change-Id: I40a1cb2da2f23815b9da8f79195df45c5e510585
2015-11-18 18:23:08 -08:00
umherirrender
5311afb6a4 phpcs: Assignment expression not allowed
Fix some "Assignment expression not allowed"

Found by tests:
https://integration.wikimedia.org/ci/job/mediawiki-core-phpcs/2736/consoleFull

Change-Id: Ibfc62b0aaa5c7fa63081edea3ef2b4d0dc984f85
2015-11-18 19:39:19 +01:00
Timo Tijhof
bf331d7c79 Use makeGlobalKey() directly instead of wfGlobalCacheKey()
Saves a small trip through ObjectCache::getLocalClusterInstance(),
call_user_func_array, and func_get_args.

Change-Id: If5d2170accaecb6cc8c0520ab9de9241b42a4727
2015-11-18 00:21:02 +00:00
Aaron Schulz
da6afd8899 Clean up some wfDebug() calls in LoadBalancer
Change-Id: I01143bec5b084a32c3edd836d194c0a17ca0e43c
2015-11-15 19:26:06 +00:00
Aaron Schulz
1af6474a6e Add LBFactory::disableChronologyProtection method
This is useful for things like job running entry points by 
avoiding pointless overhead.

Change-Id: I007273dd95e6a2e9d258d475d383bc869d63f7b1
2015-11-13 00:09:25 +00:00