For MediaWiki (recent comments | status changes | tags | authors | states | release notes)
Index: trunk/phase3/includes/api/ApiMain.php =================================================================== --- trunk/phase3/includes/api/ApiMain.php (revision 52189) +++ trunk/phase3/includes/api/ApiMain.php (revision 52190) @@ -378,11 +378,10 @@ if ( $lag > $maxLag ) { header( 'Retry-After: ' . max( intval( $maxLag ), 5 ) ); header( 'X-Database-Lag: ' . intval( $lag ) ); - // XXX: should we return a 503 HTTP error code like wfMaxlagError() does? if( $wgShowHostnames ) { - $this->dieUsage( "Waiting for $host: $lag seconds lagged", 'maxlag' ); + $this->dieUsage( "Waiting for $host: $lag seconds lagged", 'maxlag', 503 ); } else { - $this->dieUsage( "Waiting for a database server: $lag seconds lagged", 'maxlag' ); + $this->dieUsage( "Waiting for a database server: $lag seconds lagged", 'maxlag', 503 ); } return; } Index: trunk/phase3/RELEASE-NOTES =================================================================== --- trunk/phase3/RELEASE-NOTES (revision 52189) +++ trunk/phase3/RELEASE-NOTES (revision 52190) @@ -225,6 +225,7 @@ * (bug 18785) Add siprop=languages to meta=siteinfo * (bug 14200) Added user and excludeuser parameters to list=watchlist and list=recentchanges +* Return HTTP 503 status code on maxlag error, like index.php does === Languages updated in 1.16 ===
Note that this could be a breaking change for some clients. Python urllib/urllib2 for example raises an exception on 503 errors by default.
Good point, I'll announce it on the mailing list.
Don't forget to send that announcement. Unless our IRC conversation a few days ago changed your mind. ;)
For anyone else: While this change makes sense from one viewpoint, it doesn't from what is IMO a better view. index.php returns 503 because in the HTTP protocol that's how you indicate an error. But the API isn't HTTP, it just uses HTTP as a transport and reports its errors inside a successful HTTP response. This change basically raises API maxlag from "normal API error" to "transport-layer error", which could be considered equivalent to index.php sending an ICMP error on maxlag.
I still haven't seen any announcement of this on the mailing list. Besides knowing that maxlag will throw an HTTP 503 status code, it would be helpful to know what the content of the message body will be, so that this can be distinguished from other 503 conditions (squid errors).