﻿<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://moleski.net/cacwiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Laura</id>
	<title>Cor ad Cor - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://moleski.net/cacwiki/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Laura"/>
	<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=Special:Contributions/Laura"/>
	<updated>2026-04-06T19:12:46Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=File:-1_How_to_Tell_a_Story.docx&amp;diff=16941</id>
		<title>File:-1 How to Tell a Story.docx</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=File:-1_How_to_Tell_a_Story.docx&amp;diff=16941"/>
		<updated>2016-07-08T18:49:21Z</updated>

		<summary type="html">&lt;p&gt;Laura: Laura uploaded a new version of File:-1 How to Tell a Story.docx&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=File:-4_Video_Review.docx&amp;diff=16940</id>
		<title>File:-4 Video Review.docx</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=File:-4_Video_Review.docx&amp;diff=16940"/>
		<updated>2016-07-08T18:48:00Z</updated>

		<summary type="html">&lt;p&gt;Laura: Laura uploaded a new version of File:-4 Video Review.docx&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=File:-3_How_to_Compose_and_work_with_time.docx&amp;diff=16939</id>
		<title>File:-3 How to Compose and work with time.docx</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=File:-3_How_to_Compose_and_work_with_time.docx&amp;diff=16939"/>
		<updated>2016-07-08T18:47:59Z</updated>

		<summary type="html">&lt;p&gt;Laura: Laura uploaded a new version of File:-3 How to Compose and work with time.docx&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=File:-2_Script_Writing_for_Video.docx&amp;diff=16938</id>
		<title>File:-2 Script Writing for Video.docx</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=File:-2_Script_Writing_for_Video.docx&amp;diff=16938"/>
		<updated>2016-07-08T18:47:57Z</updated>

		<summary type="html">&lt;p&gt;Laura: Laura uploaded a new version of File:-2 Script Writing for Video.docx&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=File:-1_How_to_Tell_a_Story.docx&amp;diff=16937</id>
		<title>File:-1 How to Tell a Story.docx</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=File:-1_How_to_Tell_a_Story.docx&amp;diff=16937"/>
		<updated>2016-07-08T18:47:55Z</updated>

		<summary type="html">&lt;p&gt;Laura: Laura uploaded a new version of File:-1 How to Tell a Story.docx&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=Set_Free&amp;diff=16936</id>
		<title>Set Free</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=Set_Free&amp;diff=16936"/>
		<updated>2016-07-08T18:46:40Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* Notes for Teaching */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
==Project Teams==&lt;br /&gt;
; The Event (July 10-16, 2016)&lt;br /&gt;
: Team names: Dove, Raven, Sparrow, Eagle.&lt;br /&gt;
&lt;br /&gt;
==Notes for Teaching==&lt;br /&gt;
&lt;br /&gt;
Worksheets&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Sunday===&lt;br /&gt;
&lt;br /&gt;
===Monday===&lt;br /&gt;
&lt;br /&gt;
===Tuesday===&lt;br /&gt;
&lt;br /&gt;
===Wednesday===&lt;br /&gt;
&lt;br /&gt;
===Thursday===&lt;br /&gt;
&lt;br /&gt;
===Friday===&lt;br /&gt;
&lt;br /&gt;
==Ecclesial Art Project==&lt;br /&gt;
[[Mosaics]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Środowisko]]&lt;br /&gt;
[[Category:Event Themes]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=Set_Free&amp;diff=16935</id>
		<title>Set Free</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=Set_Free&amp;diff=16935"/>
		<updated>2016-07-08T18:46:19Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* Notes for Teaching */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
==Project Teams==&lt;br /&gt;
; The Event (July 10-16, 2016)&lt;br /&gt;
: Team names: Dove, Raven, Sparrow, Eagle.&lt;br /&gt;
&lt;br /&gt;
==Notes for Teaching==&lt;br /&gt;
&lt;br /&gt;
Worksheets&lt;br /&gt;
&lt;br /&gt;
*[[:File:#1 How to Tell a Story.docx]]&lt;br /&gt;
*[[:File:#2 Script Writing for Video.docx]]&lt;br /&gt;
*[[:File:#3 How to Compose and work with time.docx]]&lt;br /&gt;
*[[:File:#4 Video Review.docx]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Sunday===&lt;br /&gt;
&lt;br /&gt;
===Monday===&lt;br /&gt;
&lt;br /&gt;
===Tuesday===&lt;br /&gt;
&lt;br /&gt;
===Wednesday===&lt;br /&gt;
&lt;br /&gt;
===Thursday===&lt;br /&gt;
&lt;br /&gt;
===Friday===&lt;br /&gt;
&lt;br /&gt;
==Ecclesial Art Project==&lt;br /&gt;
[[Mosaics]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Środowisko]]&lt;br /&gt;
[[Category:Event Themes]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=File:-4_Video_Review.docx&amp;diff=16934</id>
		<title>File:-4 Video Review.docx</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=File:-4_Video_Review.docx&amp;diff=16934"/>
		<updated>2016-07-08T18:45:58Z</updated>

		<summary type="html">&lt;p&gt;Laura: Laura uploaded a new version of File:-4 Video Review.docx&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=File:-3_How_to_Compose_and_work_with_time.docx&amp;diff=16933</id>
		<title>File:-3 How to Compose and work with time.docx</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=File:-3_How_to_Compose_and_work_with_time.docx&amp;diff=16933"/>
		<updated>2016-07-08T18:45:57Z</updated>

		<summary type="html">&lt;p&gt;Laura: Laura uploaded a new version of File:-3 How to Compose and work with time.docx&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=File:-2_Script_Writing_for_Video.docx&amp;diff=16932</id>
		<title>File:-2 Script Writing for Video.docx</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=File:-2_Script_Writing_for_Video.docx&amp;diff=16932"/>
		<updated>2016-07-08T18:45:54Z</updated>

		<summary type="html">&lt;p&gt;Laura: Laura uploaded a new version of File:-2 Script Writing for Video.docx&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=File:-1_How_to_Tell_a_Story.docx&amp;diff=16931</id>
		<title>File:-1 How to Tell a Story.docx</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=File:-1_How_to_Tell_a_Story.docx&amp;diff=16931"/>
		<updated>2016-07-08T18:45:53Z</updated>

		<summary type="html">&lt;p&gt;Laura: Laura uploaded a new version of File:-1 How to Tell a Story.docx&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=Set_Free&amp;diff=16930</id>
		<title>Set Free</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=Set_Free&amp;diff=16930"/>
		<updated>2016-07-08T18:45:26Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* Notes for Teaching */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
==Project Teams==&lt;br /&gt;
; The Event (July 10-16, 2016)&lt;br /&gt;
: Team names: Dove, Raven, Sparrow, Eagle.&lt;br /&gt;
&lt;br /&gt;
==Notes for Teaching==&lt;br /&gt;
&lt;br /&gt;
Worksheets&lt;br /&gt;
[[File:#1 How to Tell a Story.docx]]&lt;br /&gt;
[[File:#2 Script Writing for Video.docx]]&lt;br /&gt;
[[File:#3 How to Compose and work with time.docx]]&lt;br /&gt;
[[File:#4 Video Review.docx]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Sunday===&lt;br /&gt;
&lt;br /&gt;
===Monday===&lt;br /&gt;
&lt;br /&gt;
===Tuesday===&lt;br /&gt;
&lt;br /&gt;
===Wednesday===&lt;br /&gt;
&lt;br /&gt;
===Thursday===&lt;br /&gt;
&lt;br /&gt;
===Friday===&lt;br /&gt;
&lt;br /&gt;
==Ecclesial Art Project==&lt;br /&gt;
[[Mosaics]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Środowisko]]&lt;br /&gt;
[[Category:Event Themes]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=File:-4_Video_Review.docx&amp;diff=16929</id>
		<title>File:-4 Video Review.docx</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=File:-4_Video_Review.docx&amp;diff=16929"/>
		<updated>2016-07-08T18:45:16Z</updated>

		<summary type="html">&lt;p&gt;Laura: Laura uploaded a new version of File:-4 Video Review.docx&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=File:-3_How_to_Compose_and_work_with_time.docx&amp;diff=16928</id>
		<title>File:-3 How to Compose and work with time.docx</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=File:-3_How_to_Compose_and_work_with_time.docx&amp;diff=16928"/>
		<updated>2016-07-08T18:45:15Z</updated>

		<summary type="html">&lt;p&gt;Laura: Laura uploaded a new version of File:-3 How to Compose and work with time.docx&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=File:-2_Script_Writing_for_Video.docx&amp;diff=16927</id>
		<title>File:-2 Script Writing for Video.docx</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=File:-2_Script_Writing_for_Video.docx&amp;diff=16927"/>
		<updated>2016-07-08T18:45:12Z</updated>

		<summary type="html">&lt;p&gt;Laura: Laura uploaded a new version of File:-2 Script Writing for Video.docx&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=File:-1_How_to_Tell_a_Story.docx&amp;diff=16926</id>
		<title>File:-1 How to Tell a Story.docx</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=File:-1_How_to_Tell_a_Story.docx&amp;diff=16926"/>
		<updated>2016-07-08T18:45:11Z</updated>

		<summary type="html">&lt;p&gt;Laura: Laura uploaded a new version of File:-1 How to Tell a Story.docx&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=Set_Free&amp;diff=16925</id>
		<title>Set Free</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=Set_Free&amp;diff=16925"/>
		<updated>2016-07-08T18:44:44Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* Notes for Teaching */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
==Project Teams==&lt;br /&gt;
; The Event (July 10-16, 2016)&lt;br /&gt;
: Team names: Dove, Raven, Sparrow, Eagle.&lt;br /&gt;
&lt;br /&gt;
==Notes for Teaching==&lt;br /&gt;
&lt;br /&gt;
Worksheets&lt;br /&gt;
[[File:#1 How to Tell a Story.docx]]&lt;br /&gt;
[[File:#2 Script Writing for Video.docx]]&lt;br /&gt;
[[File:#3 How to Compose and work with time.docx]]&lt;br /&gt;
[[File:#4 Video Review.docx]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Sunday===&lt;br /&gt;
&lt;br /&gt;
===Monday===&lt;br /&gt;
&lt;br /&gt;
===Tuesday===&lt;br /&gt;
&lt;br /&gt;
===Wednesday===&lt;br /&gt;
&lt;br /&gt;
===Thursday===&lt;br /&gt;
&lt;br /&gt;
===Friday===&lt;br /&gt;
&lt;br /&gt;
==Ecclesial Art Project==&lt;br /&gt;
[[Mosaics]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Środowisko]]&lt;br /&gt;
[[Category:Event Themes]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=File:-4_Video_Review.docx&amp;diff=16924</id>
		<title>File:-4 Video Review.docx</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=File:-4_Video_Review.docx&amp;diff=16924"/>
		<updated>2016-07-08T18:44:16Z</updated>

		<summary type="html">&lt;p&gt;Laura: File uploaded with MsUpload&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=File:-1_How_to_Tell_a_Story.docx&amp;diff=16923</id>
		<title>File:-1 How to Tell a Story.docx</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=File:-1_How_to_Tell_a_Story.docx&amp;diff=16923"/>
		<updated>2016-07-08T18:42:19Z</updated>

		<summary type="html">&lt;p&gt;Laura: File uploaded with MsUpload&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=File:-3_How_to_Compose_and_work_with_time.docx&amp;diff=16922</id>
		<title>File:-3 How to Compose and work with time.docx</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=File:-3_How_to_Compose_and_work_with_time.docx&amp;diff=16922"/>
		<updated>2016-07-08T18:41:46Z</updated>

		<summary type="html">&lt;p&gt;Laura: File uploaded with MsUpload&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=File:-2_Script_Writing_for_Video.docx&amp;diff=16921</id>
		<title>File:-2 Script Writing for Video.docx</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=File:-2_Script_Writing_for_Video.docx&amp;diff=16921"/>
		<updated>2016-07-08T18:41:43Z</updated>

		<summary type="html">&lt;p&gt;Laura: File uploaded with MsUpload&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=%C5%9Arodowisko_Activity_Board&amp;diff=16920</id>
		<title>Środowisko Activity Board</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=%C5%9Arodowisko_Activity_Board&amp;diff=16920"/>
		<updated>2016-07-08T17:33:52Z</updated>

		<summary type="html">&lt;p&gt;Laura: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;The Activity Board was introduced in 2014.&lt;br /&gt;
&lt;br /&gt;
*Adoration sign-up sheet for the entire week &lt;br /&gt;
[[File:Adoration and swimming Sign ups.docx]]&lt;br /&gt;
*Daily swim sign-up sheet&lt;br /&gt;
*Talent Show sign-up sheet&lt;br /&gt;
[[File:Talent show sign ups.docx]]&lt;br /&gt;
*Mystery Messenger ideas&lt;br /&gt;
*Social media&lt;br /&gt;
*Rules and reminders&lt;br /&gt;
*Announcements&lt;br /&gt;
*Apropos quotes&lt;br /&gt;
*Horarium&lt;br /&gt;
[[File:Sro Free Time Check In.docx]]&lt;br /&gt;
[[Category:Środowisko]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=File:Talent_show_sign_ups.docx&amp;diff=16919</id>
		<title>File:Talent show sign ups.docx</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=File:Talent_show_sign_ups.docx&amp;diff=16919"/>
		<updated>2016-07-08T17:32:48Z</updated>

		<summary type="html">&lt;p&gt;Laura: File uploaded with MsUpload&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=File:Sro_Free_Time_Check_In.docx&amp;diff=16918</id>
		<title>File:Sro Free Time Check In.docx</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=File:Sro_Free_Time_Check_In.docx&amp;diff=16918"/>
		<updated>2016-07-08T17:32:48Z</updated>

		<summary type="html">&lt;p&gt;Laura: File uploaded with MsUpload&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=File:Adoration_and_swimming_Sign_ups.docx&amp;diff=16917</id>
		<title>File:Adoration and swimming Sign ups.docx</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=File:Adoration_and_swimming_Sign_ups.docx&amp;diff=16917"/>
		<updated>2016-07-08T17:32:47Z</updated>

		<summary type="html">&lt;p&gt;Laura: File uploaded with MsUpload&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;File uploaded with MsUpload&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=Set_Free&amp;diff=16916</id>
		<title>Set Free</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=Set_Free&amp;diff=16916"/>
		<updated>2016-07-08T15:12:59Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* Project Teams */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;br /&gt;
==Project Teams==&lt;br /&gt;
; The Event (July 10-16, 2016)&lt;br /&gt;
: Team names: Dove, Raven, Sparrow, Eagle.&lt;br /&gt;
&lt;br /&gt;
==Notes for Teaching==&lt;br /&gt;
===Sunday===&lt;br /&gt;
&lt;br /&gt;
===Monday===&lt;br /&gt;
&lt;br /&gt;
===Tuesday===&lt;br /&gt;
&lt;br /&gt;
===Wednesday===&lt;br /&gt;
&lt;br /&gt;
===Thursday===&lt;br /&gt;
&lt;br /&gt;
===Friday===&lt;br /&gt;
&lt;br /&gt;
==Ecclesial Art Project==&lt;br /&gt;
[[Mosaics]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Środowisko]]&lt;br /&gt;
[[Category:Event Themes]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=Development_of_Religious_Life&amp;diff=16412</id>
		<title>Development of Religious Life</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=Development_of_Religious_Life&amp;diff=16412"/>
		<updated>2015-12-04T13:03:45Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* Chronology */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Development of discipline: disciples are called to good order.  &lt;br /&gt;
&lt;br /&gt;
Permutations and combinations: evolution happens!  &amp;quot;Let&#039;s try this.  If it works, great.  If it doesn&#039;t, we&#039;ll know what doesn&#039;t work.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
To be religious is to be connected to God and to other believers.&lt;br /&gt;
&lt;br /&gt;
We are all members of the same Body, but we have different gifts and play different roles in the Body.&lt;br /&gt;
&lt;br /&gt;
When Protestants disagree with each other, they create new churches; when faithful Catholics disagree with each other, they found new religious communities.&lt;br /&gt;
&lt;br /&gt;
In either case, as they say in AA, all it takes to start a new way of life in the Church is &amp;quot;two resentments and a coffee pot.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Chronology ==&lt;br /&gt;
{|{{Prettytable}}&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;|&#039;&#039;&#039;Classical Era&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|OT&lt;br /&gt;
|Temple orders: priests, attendants, choirs, musicians&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|OT&lt;br /&gt;
|Pious men and women, devotees&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|OT&lt;br /&gt;
|synagogues&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|OT&lt;br /&gt;
|rabbinic schools&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|OT&lt;br /&gt;
|&amp;quot;Essenes&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|OT&lt;br /&gt;
|John the Baptist&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|NT&lt;br /&gt;
|1 Cor 7 gives evidence of people deciding to remain virgins, even in marriage, in order to be free to serve the Lord.  Evangelical counsels [gospel-preaching instructions] : give everything to the poor; follow Jesus; rely on begging to preach the gospel; become a &amp;quot;eunuch [a person incapable of having sex] for the sake of the Kingdom&amp;quot; (Mt 19:12).  Note well how the Church takes this text symbolically and not literally.  When Origen (~185-254 AD) castrated himself, the Church did NOT think it was a praiseworthy act.  Origen has never been and never will be canonized (listed as a saint to be venerated and imitated).&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|250&lt;br /&gt;
|Persecution of Decius inspires many to flee to the desert and live solitary lives of prayer.&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|381&lt;br /&gt;
|Decisive end of the age of persecutions in the Roman Empire.&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|331&amp;amp;#8209;379&lt;br /&gt;
|St. Basil wrote the first rules for religious life.&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|427&lt;br /&gt;
|St. Augustine wrote rules for a community of women.  He also lived in community with friends and fellow priests.&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;|&#039;&#039;&#039;Dark Ages&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|480&amp;amp;#8209;547&lt;br /&gt;
|St. Benedict founded many monasteries, especially Monte Cassino.  &lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|927&lt;br /&gt;
|Foundation of the Congregation of Cluny.&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;|&#039;&#039;&#039;Middle Ages&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|1100&lt;br /&gt;
|Cistercians reform Benedictine life.&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|1155&lt;br /&gt;
|First indisputable evidence of the existence of Carmelite Communities (Order of Mt. Carmel).&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|1209&lt;br /&gt;
|St. Francis founded the Order of Friars Minor (Franciscans).&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|1215&lt;br /&gt;
|St. Dominic founded the Order of Preachers (Dominicans).&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;|&#039;&#039;&#039;Renaissance&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|1517&lt;br /&gt;
|Martin Luther abandoned the priesthood and religious life (he had been an Augustinian priest) and initiated the Protestant Reformation.&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|1540&lt;br /&gt;
|St. Ignatius founded the Society of Jesus (Jesuits).&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;|&#039;&#039;&#039;Enlightenment&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|1680&lt;br /&gt;
|St. John Baptist de la Salle took over his first school--origin of the Christian Brothers.&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|1700&lt;br /&gt;
|Trappists reform Cistercian life.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
There are hundreds of other religious communities: Basilians, Carthusians, Ursilines, Sisters of St. Joseph, Redemptorists, Trinitarians, Holy Cross Fathers, Passionists, Paulists, Religious of the Sacred Heart of Mary, Grey Nuns of the Sacred Heart, Sisters of the Holy Child Jesus, Madams of the Sacred Heart, many kinds of Franciscans, etc.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Count the stars, if you can.&amp;quot;&lt;br /&gt;
Jesus and apostles: peripatetic, homeless.&lt;br /&gt;
&lt;br /&gt;
Two-by-two&lt;br /&gt;
&lt;br /&gt;
Evangelical counsels.&lt;br /&gt;
&lt;br /&gt;
Acts: common life (honeymoon of the early Church).&lt;br /&gt;
&lt;br /&gt;
Presbyteroi and diakonoi: servants to the local Church.&lt;br /&gt;
&lt;br /&gt;
Pastoral gifts.&lt;br /&gt;
&lt;br /&gt;
The family is a form of religious life.  Marriage is a sacred vocation in the Church.  The faithfulness of husband and wife reflects Jesus faithfulness to His Bride, the Church.&lt;br /&gt;
&lt;br /&gt;
Eunuchs for the sake of the kingdom; single for the Lord, like Paul.&lt;br /&gt;
&lt;br /&gt;
Virgins and widows.&lt;br /&gt;
&lt;br /&gt;
Couples living as brother and sister.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Holy Orders.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Diocesan system.&lt;br /&gt;
&lt;br /&gt;
Augustine.&lt;br /&gt;
&lt;br /&gt;
Canons.&lt;br /&gt;
&lt;br /&gt;
Hermits.&lt;br /&gt;
&lt;br /&gt;
Benedictines&lt;br /&gt;
&lt;br /&gt;
Orders of monks and nuns.&lt;br /&gt;
&lt;br /&gt;
Never alone.  Always surrounded by benefactors, partners, and clients.&lt;br /&gt;
&lt;br /&gt;
Franciscans and Dominicans: mendicants.&lt;br /&gt;
&lt;br /&gt;
Jesuits: contemplatives in action.&lt;br /&gt;
&lt;br /&gt;
Lay saints.  Matt Talbot.  &lt;br /&gt;
&lt;br /&gt;
Madonna House, Catholic Worker, l&#039;Arche&lt;br /&gt;
&lt;br /&gt;
Covenant communities&lt;br /&gt;
&lt;br /&gt;
Apostolic associations: priests, laity.  Oratorians, SOLT.&lt;br /&gt;
&lt;br /&gt;
Personal prelature (Opus Dei)&lt;br /&gt;
&lt;br /&gt;
Ordinariates.&lt;br /&gt;
&lt;br /&gt;
[[Third Orders]]&lt;br /&gt;
&lt;br /&gt;
== Typology ==&lt;br /&gt;
&lt;br /&gt;
Canon law on religious life.&lt;br /&gt;
&lt;br /&gt;
Life changes faster than law.&lt;br /&gt;
&lt;br /&gt;
Development of code always outstrips documentation.  First people make a discovery, then later it gets codified so that others may use the same &#039;&#039;type&#039;&#039; of organization.  Both God and His people are highly creative.  There is no law that says that &amp;quot;no new way of serving God can be invented.&amp;quot;  The Church tried to pass that law around the time of the Ignatian innovation, but it got swept away by a torrent of new forms of religious life.&lt;br /&gt;
&lt;br /&gt;
Religious life is not a sacrament.  It is a community structure created by volunteers who want to belong to the community.&lt;br /&gt;
&lt;br /&gt;
Religious life is structured by vows.  Typically, religious communities take vows of poverty, chastity (celibacy), and obedience.  Jesuits and some other orders take a fourth vow of obedience to the Pope.&lt;br /&gt;
&lt;br /&gt;
The various kinds of religious communities in the Church are distinguished from each other, in part, by whether the vows are solemn or simple.  Solemn vows give the person making the vows certain rights and privileges; people who take simple vows have fewer rights in the life of their community.&lt;br /&gt;
&lt;br /&gt;
Promises.  &lt;br /&gt;
&lt;br /&gt;
Simple vows.&lt;br /&gt;
&lt;br /&gt;
Solemn vows.&lt;br /&gt;
&lt;br /&gt;
:; [http://www.etymonline.com/index.php?term=diocese &#039;&#039;Online Etymology Dictionary&#039;&#039;, &amp;quot;diocese&amp;quot;:]&lt;br /&gt;
:: Early 14c., from Old Frence &#039;&#039;diocese&#039;&#039; (13c., Modern French, diocÃ¨se), from Late Latin, &#039;&#039;diocesis&#039;&#039; &amp;quot;a governor&#039;s jurisdiction,&amp;quot; later, &amp;quot;a bishop&#039;s jurisdiction,&amp;quot; from Greek &#039;&#039;dioikesis&#039;&#039; &amp;quot;government, administration; province,&amp;quot; originally &amp;quot;economy, housekeeping,&amp;quot; from &#039;&#039;dioikein&#039;&#039; &amp;quot;control, govern, administer, manage a house,&amp;quot; from &#039;&#039;dia-&#039;&#039; &amp;quot;thoroughly&amp;quot; + &#039;&#039;oikos&#039;&#039; &amp;quot;house.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* Vatican II docs.&lt;br /&gt;
* [[Opus Dei]].&lt;br /&gt;
* [http://www.ncregister.com/daily-news/franciscan-missionaries-of-the-eternal-word-celebrate-25th-anniversary/ &amp;quot;Franciscan Missionaries of the Eternal Word,&amp;quot;] founded by Mother Angelica in 1987.&lt;br /&gt;
&lt;br /&gt;
[[Category:Religious Life]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=Development_of_Religious_Life&amp;diff=16411</id>
		<title>Development of Religious Life</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=Development_of_Religious_Life&amp;diff=16411"/>
		<updated>2015-12-04T13:01:53Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* Chronology */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Development of discipline: disciples are called to good order.  &lt;br /&gt;
&lt;br /&gt;
Permutations and combinations: evolution happens!  &amp;quot;Let&#039;s try this.  If it works, great.  If it doesn&#039;t, we&#039;ll know what doesn&#039;t work.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
To be religious is to be connected to God and to other believers.&lt;br /&gt;
&lt;br /&gt;
We are all members of the same Body, but we have different gifts and play different roles in the Body.&lt;br /&gt;
&lt;br /&gt;
When Protestants disagree with each other, they create new churches; when faithful Catholics disagree with each other, they found new religious communities.&lt;br /&gt;
&lt;br /&gt;
In either case, as they say in AA, all it takes to start a new way of life in the Church is &amp;quot;two resentments and a coffee pot.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== Chronology ==&lt;br /&gt;
{|{{Prettytable}}&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;|&#039;&#039;&#039;Classical Era&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|OT&lt;br /&gt;
|Temple orders: priests, attendants, choirs, musicians&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|OT&lt;br /&gt;
|Pious men and women, devotees&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|OT&lt;br /&gt;
|synagogues&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|OT&lt;br /&gt;
|rabbinic schools&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|OT&lt;br /&gt;
|&amp;quot;Essenes&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|OT&lt;br /&gt;
|John the Baptist&lt;br /&gt;
|-valign=&amp;quot;top&amp;quot;&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|NT&lt;br /&gt;
|1 Cor 7 gives evidence of people deciding to remain virgins, even in marriage, in order to be free to serve the Lord.  Evangelical counsels [gospel-preaching instructions] : give everything to the poor; follow Jesus; rely on begging to preach the gospel; become a &amp;quot;eunuch [a person incapable of having sex] for the sake of the Kingdom&amp;quot; (Mt 19:12).  Note well how the Church takes this text symbolically and not literally.  When Origen (~185-254 AD) castrated himself, the Church did NOT think it was a praiseworthy act.  Origen has never been and never will be canonized (listed as a saint to be venerated and imitated).&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|250&lt;br /&gt;
|Persecution of Decius inspires many to flee to the desert and live solitary lives of prayer.&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|381&lt;br /&gt;
|Decisive end of the age of persecutions in the Roman Empire.&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|331-379&lt;br /&gt;
|St. Basil wrote the first rules for religious life.&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|427&lt;br /&gt;
|St. Augustine wrote rules for a community of women.  He also lived in community with friends and fellow priests.&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;|&#039;&#039;&#039;Dark Ages&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|480-547&lt;br /&gt;
|St. Benedict founded many monasteries, especially Monte Cassino.  &lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|927&lt;br /&gt;
|Foundation of the Congregation of Cluny.&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;|&#039;&#039;&#039;Middle Ages&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|1100&lt;br /&gt;
|Cistercians reform Benedictine life.&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|1155&lt;br /&gt;
|First indisputable evidence of the existence of Carmelite Communities (Order of Mt. Carmel).&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|1209&lt;br /&gt;
|St. Francis founded the Order of Friars Minor (Franciscans).&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|1215&lt;br /&gt;
|St. Dominic founded the Order of Preachers (Dominicans).&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;|&#039;&#039;&#039;Renaissance&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|1517&lt;br /&gt;
|Martin Luther abandoned the priesthood and religious life (he had been an Augustinian priest) and initiated the Protestant Reformation.&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|1540&lt;br /&gt;
|St. Ignatius founded the Society of Jesus (Jesuits).&lt;br /&gt;
|-&lt;br /&gt;
|colspan=&amp;quot;2&amp;quot;|&#039;&#039;&#039;Enlightenment&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|1680&lt;br /&gt;
|St. John Baptist de la Salle took over his first school--origin of the Christian Brothers.&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|1700&lt;br /&gt;
|Trappists reform Cistercian life.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
There are hundreds of other religious communities: Basilians, Carthusians, Ursilines, Sisters of St. Joseph, Redemptorists, Trinitarians, Holy Cross Fathers, Passionists, Paulists, Religious of the Sacred Heart of Mary, Grey Nuns of the Sacred Heart, Sisters of the Holy Child Jesus, Madams of the Sacred Heart, many kinds of Franciscans, etc.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Count the stars, if you can.&amp;quot;&lt;br /&gt;
Jesus and apostles: peripatetic, homeless.&lt;br /&gt;
&lt;br /&gt;
Two-by-two&lt;br /&gt;
&lt;br /&gt;
Evangelical counsels.&lt;br /&gt;
&lt;br /&gt;
Acts: common life (honeymoon of the early Church).&lt;br /&gt;
&lt;br /&gt;
Presbyteroi and diakonoi: servants to the local Church.&lt;br /&gt;
&lt;br /&gt;
Pastoral gifts.&lt;br /&gt;
&lt;br /&gt;
The family is a form of religious life.  Marriage is a sacred vocation in the Church.  The faithfulness of husband and wife reflects Jesus faithfulness to His Bride, the Church.&lt;br /&gt;
&lt;br /&gt;
Eunuchs for the sake of the kingdom; single for the Lord, like Paul.&lt;br /&gt;
&lt;br /&gt;
Virgins and widows.&lt;br /&gt;
&lt;br /&gt;
Couples living as brother and sister.&lt;br /&gt;
&lt;br /&gt;
&amp;quot;Holy Orders.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Diocesan system.&lt;br /&gt;
&lt;br /&gt;
Augustine.&lt;br /&gt;
&lt;br /&gt;
Canons.&lt;br /&gt;
&lt;br /&gt;
Hermits.&lt;br /&gt;
&lt;br /&gt;
Benedictines&lt;br /&gt;
&lt;br /&gt;
Orders of monks and nuns.&lt;br /&gt;
&lt;br /&gt;
Never alone.  Always surrounded by benefactors, partners, and clients.&lt;br /&gt;
&lt;br /&gt;
Franciscans and Dominicans: mendicants.&lt;br /&gt;
&lt;br /&gt;
Jesuits: contemplatives in action.&lt;br /&gt;
&lt;br /&gt;
Lay saints.  Matt Talbot.  &lt;br /&gt;
&lt;br /&gt;
Madonna House, Catholic Worker, l&#039;Arche&lt;br /&gt;
&lt;br /&gt;
Covenant communities&lt;br /&gt;
&lt;br /&gt;
Apostolic associations: priests, laity.  Oratorians, SOLT.&lt;br /&gt;
&lt;br /&gt;
Personal prelature (Opus Dei)&lt;br /&gt;
&lt;br /&gt;
Ordinariates.&lt;br /&gt;
&lt;br /&gt;
[[Third Orders]]&lt;br /&gt;
&lt;br /&gt;
== Typology ==&lt;br /&gt;
&lt;br /&gt;
Canon law on religious life.&lt;br /&gt;
&lt;br /&gt;
Life changes faster than law.&lt;br /&gt;
&lt;br /&gt;
Development of code always outstrips documentation.  First people make a discovery, then later it gets codified so that others may use the same &#039;&#039;type&#039;&#039; of organization.  Both God and His people are highly creative.  There is no law that says that &amp;quot;no new way of serving God can be invented.&amp;quot;  The Church tried to pass that law around the time of the Ignatian innovation, but it got swept away by a torrent of new forms of religious life.&lt;br /&gt;
&lt;br /&gt;
Religious life is not a sacrament.  It is a community structure created by volunteers who want to belong to the community.&lt;br /&gt;
&lt;br /&gt;
Religious life is structured by vows.  Typically, religious communities take vows of poverty, chastity (celibacy), and obedience.  Jesuits and some other orders take a fourth vow of obedience to the Pope.&lt;br /&gt;
&lt;br /&gt;
The various kinds of religious communities in the Church are distinguished from each other, in part, by whether the vows are solemn or simple.  Solemn vows give the person making the vows certain rights and privileges; people who take simple vows have fewer rights in the life of their community.&lt;br /&gt;
&lt;br /&gt;
Promises.  &lt;br /&gt;
&lt;br /&gt;
Simple vows.&lt;br /&gt;
&lt;br /&gt;
Solemn vows.&lt;br /&gt;
&lt;br /&gt;
:; [http://www.etymonline.com/index.php?term=diocese &#039;&#039;Online Etymology Dictionary&#039;&#039;, &amp;quot;diocese&amp;quot;:]&lt;br /&gt;
:: Early 14c., from Old Frence &#039;&#039;diocese&#039;&#039; (13c., Modern French, diocÃ¨se), from Late Latin, &#039;&#039;diocesis&#039;&#039; &amp;quot;a governor&#039;s jurisdiction,&amp;quot; later, &amp;quot;a bishop&#039;s jurisdiction,&amp;quot; from Greek &#039;&#039;dioikesis&#039;&#039; &amp;quot;government, administration; province,&amp;quot; originally &amp;quot;economy, housekeeping,&amp;quot; from &#039;&#039;dioikein&#039;&#039; &amp;quot;control, govern, administer, manage a house,&amp;quot; from &#039;&#039;dia-&#039;&#039; &amp;quot;thoroughly&amp;quot; + &#039;&#039;oikos&#039;&#039; &amp;quot;house.&amp;quot;&lt;br /&gt;
&lt;br /&gt;
== References ==&lt;br /&gt;
&amp;lt;references /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* Vatican II docs.&lt;br /&gt;
* [[Opus Dei]].&lt;br /&gt;
* [http://www.ncregister.com/daily-news/franciscan-missionaries-of-the-eternal-word-celebrate-25th-anniversary/ &amp;quot;Franciscan Missionaries of the Eternal Word,&amp;quot;] founded by Mother Angelica in 1987.&lt;br /&gt;
&lt;br /&gt;
[[Category:Religious Life]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16410</id>
		<title>WAMP, localhost, Mediawiki: Cannot access the database</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16410"/>
		<updated>2015-12-04T03:45:43Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* WAMPserver 3 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;or &#039;&#039;&#039;&#039;&#039;The Bug that Ate a Week of My Life!&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mediawiki on localhost ==&lt;br /&gt;
&lt;br /&gt;
Since 2:42 PM on 14 March 2009, I have run a private wiki for myself on a WAMP stack--6.5 years and counting.&lt;br /&gt;
&lt;br /&gt;
I have migrated the wiki from one desktop to another and installed it on two different laptops.&lt;br /&gt;
&lt;br /&gt;
I have never had everything work perfectly right out of the box, but I have never been frustrated for too long.  People have solved all of the basic problems more than once, and it has been just a matter of googling around long enough to debug the setup.&lt;br /&gt;
&lt;br /&gt;
All that has changed.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve found a bug that has defeated me.&lt;br /&gt;
&lt;br /&gt;
== Mediawiki 1.26, WAMPserver 2.5, and WAMPserver 3 ==&lt;br /&gt;
&lt;br /&gt;
== Error Messages ==&lt;br /&gt;
&lt;br /&gt;
=== Shorter version ===&lt;br /&gt;
&lt;br /&gt;
Sorry! This site is experiencing technical difficulties.&lt;br /&gt;
&lt;br /&gt;
Try waiting a few minutes and reloading.&lt;br /&gt;
&lt;br /&gt;
(Cannot access the database)&lt;br /&gt;
&lt;br /&gt;
=== With debugging and backtracking enabled ===&lt;br /&gt;
&lt;br /&gt;
Cannot access the database: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ())&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Backtrace:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
:  #0 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(842): &#039;&#039;&#039;DatabaseBase&#039;&#039;&#039;-&amp;gt;reportConnectionError(&#039;Unknown error (...&#039;)&lt;br /&gt;
:  #1 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(537): &#039;&#039;&#039;LoadBalancer&#039;&#039;&#039;-&amp;gt;reportConnectionError()&lt;br /&gt;
:  #2 C:\wamp\www\mediawiki\includes\GlobalFunctions.php(3631): LoadBalancer-&amp;gt;getConnection(-1, Array, false)&lt;br /&gt;
:  #3 C:\wamp\www\mediawiki\includes\User.php(1208): wfGetDB(-1)&lt;br /&gt;
:  #4 C:\wamp\www\mediawiki\includes\User.php(397): User-&amp;gt;loadFromDatabase(0)&lt;br /&gt;
:  #5 C:\wamp\www\mediawiki\includes\User.php(362): User-&amp;gt;loadFromId(0)&lt;br /&gt;
:  #6 C:\wamp\www\mediawiki\includes\User.php(2459): User-&amp;gt;load()&lt;br /&gt;
:  #7 C:\wamp\www\mediawiki\includes\User.php(1167): User-&amp;gt;getToken(false)&lt;br /&gt;
:  #8 C:\wamp\www\mediawiki\includes\User.php(365): User-&amp;gt;loadFromSession()&lt;br /&gt;
:  #9 C:\wamp\www\mediawiki\includes\User.php(2029): User-&amp;gt;load()&lt;br /&gt;
:  #10 C:\wamp\www\mediawiki\includes\User.php(3204): User-&amp;gt;getId()&lt;br /&gt;
:  #11 C:\wamp\www\mediawiki\includes\MediaWiki.php(627): User-&amp;gt;isLoggedIn()&lt;br /&gt;
:  #12 C:\wamp\www\mediawiki\includes\MediaWiki.php(476): MediaWiki-&amp;gt;main()&lt;br /&gt;
:  #13 C:\wamp\www\mediawiki\index.php(51): MediaWiki-&amp;gt;run()&lt;br /&gt;
:  #14 {main}&lt;br /&gt;
&lt;br /&gt;
:  reportConnectionError &amp;quot;Unknown error&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Failure message when MySQL is totally disabled ===&lt;br /&gt;
&lt;br /&gt;
Warning: mysqli::mysqli(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp\www\mediawiki\LocalSettings.php on line 152&lt;br /&gt;
&lt;br /&gt;
Connection failed: No connection could be made because the target machine actively refused it.&lt;br /&gt;
&lt;br /&gt;
== Not a code or configuration problem ==&lt;br /&gt;
&lt;br /&gt;
Except for a few times when I shot myself in the foot while debugging, the proof that the PHP code base and my configuration are correct is that I can immediately obtain the page I want by reloading the page.  &lt;br /&gt;
&lt;br /&gt;
It is only on the first call after a long time (five minutes? ten?) of not accessing the wiki that the problem occurs.&lt;br /&gt;
&lt;br /&gt;
== Timing is everything ==&lt;br /&gt;
&lt;br /&gt;
The most common time for the bug to bite is when I open my browser.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve got two tabs to pages on the local wiki in my collection of home pages.&lt;br /&gt;
&lt;br /&gt;
The first one usually fails if I&#039;ve had the browser closed for a while; the second never does.&lt;br /&gt;
&lt;br /&gt;
I dropped the second page from the set to see if that would help the first. &lt;br /&gt;
&lt;br /&gt;
It didn&#039;t.&lt;br /&gt;
&lt;br /&gt;
Once MySQL is awakened from its slumbers, all the links in the wiki work reasonably well--no worse than ever before--unless I spend a long time composing a page, and then the connection fails when I try to save the page.  Refresh the page, and it saves perfectly.&lt;br /&gt;
&lt;br /&gt;
Something somewhere keeps MySQL from answering the FIRST request for a connection in the time frame that Mediawiki expects.  After that, everything is normal enough until MySQL decides to fall asleep again.&lt;br /&gt;
&lt;br /&gt;
== Round up the usual suspects ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s some interaction between Windows, Apache, MySQL, and the Wikimedia routines that has got me down.&lt;br /&gt;
&lt;br /&gt;
Why can&#039;t we all just get along?&lt;br /&gt;
&lt;br /&gt;
The articles in the [[#Links|links below]] have got excellent information and links in them.  They cover pretty much everything I&#039;ve tried, and then some.  I&#039;m just going to list the failed fixes that float into mind:&lt;br /&gt;
&lt;br /&gt;
* turn off IPv6 on my machine&lt;br /&gt;
* have Apache listen only to 127.0.0.1:80&lt;br /&gt;
* bind MySQL to 127.0.0.1 &lt;br /&gt;
* turn off name resolution in MySQL&lt;br /&gt;
* change localhost to 127.0.0.1 everywhere I can to avoid DNS calls&lt;br /&gt;
* edit Hosts file to make sure localhost is defined&lt;br /&gt;
* enable opcache and install APCu&lt;br /&gt;
* turn off Zend debugger&lt;br /&gt;
* moved from WAMPserver 2.5 to 3&lt;br /&gt;
&lt;br /&gt;
Total failure, but intriguing: get MySQL to use a socket.  There are paths for it in the configuration files, but I&#039;ve never gotten it going.  I must do more googling!  It seems as though it SHOULD work.&lt;br /&gt;
&lt;br /&gt;
== Sysinfo ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
: BIOS Manufacturer: American Megatrends Inc.&lt;br /&gt;
: Release Date: 10/23/2012&lt;br /&gt;
: BIOS Version: ALASKA - 1072009&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: Board Product ID: Gigabyte 990FXA-UD3&lt;br /&gt;
&lt;br /&gt;
: AMD FX-8350 Eight-Core Processor, 4 Ghz&lt;br /&gt;
: 16 GB RAM&lt;br /&gt;
: 480 Gb SSHD&lt;br /&gt;
: 1 Tb HD&lt;br /&gt;
: 650 W power supply&lt;br /&gt;
: AMD Radeon HD 7700 with 2 Gb RAM&lt;br /&gt;
&lt;br /&gt;
Report Generated at: 1/8/2013 1:02:45 AM&lt;br /&gt;
&lt;br /&gt;
OK, so the machine is sneaking up on its third year in service.  It still gets a decent rating from me and Windows:&lt;br /&gt;
&lt;br /&gt;
[[File:Homebrew 5 performance.jpg]]&lt;br /&gt;
&lt;br /&gt;
And, as with everything else except for Wikimedia version and the WAMPserver versions, I haven&#039;t changed anything from last week, when all was well in wikiland.&lt;br /&gt;
&lt;br /&gt;
=== OS ===&lt;br /&gt;
&lt;br /&gt;
: Windows 7 Professional, 64-bit&lt;br /&gt;
: Service Pack 1&lt;br /&gt;
&lt;br /&gt;
=== Browser ===&lt;br /&gt;
&lt;br /&gt;
: Chrome 46.0.2490.86 m&lt;br /&gt;
&lt;br /&gt;
=== Software Guardians ===&lt;br /&gt;
&lt;br /&gt;
: Malware Bytes&lt;br /&gt;
::: Set to exclude 127.0.0.1, httpd.exe, and mysql.exe from inspection.&lt;br /&gt;
&lt;br /&gt;
: CylanceProtect&lt;br /&gt;
::: I&#039;ve got no control over this.  All I can say is that with MediaWiki 1.20, I had no connection problems.&lt;br /&gt;
&lt;br /&gt;
: Firewall&lt;br /&gt;
::: Made sure port 3306 is open.&lt;br /&gt;
&lt;br /&gt;
=== [http://sourceforge.net/projects/wampserver/ WAMPserver 3] ===&lt;br /&gt;
&lt;br /&gt;
::{|&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|Apache &lt;br /&gt;
|2.4.17&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|MySQL &lt;br /&gt;
|5.7.9&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|PHP &lt;br /&gt;
|5.6.15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #1 ==&lt;br /&gt;
&lt;br /&gt;
Because the connection ALWAYS worked on the very next try after a failure, I thought that perhaps I could arrange a sacrificial connection to feed the ravenous Connection Monster; while it was chomping on the carcass, the real Mediawiki connection might sneak by unnoticed.&lt;br /&gt;
&lt;br /&gt;
So I put this in my LocalSettings.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$servername = &amp;quot;127.0.0.1&amp;quot;;&lt;br /&gt;
$username = &amp;quot;dbuser&amp;quot;;&lt;br /&gt;
$password = &amp;quot;dbuserpassword&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Create connection&lt;br /&gt;
$conn = new mysqli($servername, $username, $password);&lt;br /&gt;
&lt;br /&gt;
// Check connection&lt;br /&gt;
if ($conn-&amp;gt;connect_error) {&lt;br /&gt;
    die(&amp;quot;Connection failed: &amp;quot; . $conn-&amp;gt;connect_error);&lt;br /&gt;
} &lt;br /&gt;
#echo &amp;quot;Connected successfully&amp;quot;;&lt;br /&gt;
mysqli_close($conn);&lt;br /&gt;
#die(&amp;quot;test finished&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This idiotic connection hasn&#039;t ever failed yet.&lt;br /&gt;
&lt;br /&gt;
And the wiki page hasn&#039;t yet failed to connect afterward, either.&lt;br /&gt;
&lt;br /&gt;
Pasta faggiole!&lt;br /&gt;
&lt;br /&gt;
I hate it.&lt;br /&gt;
&lt;br /&gt;
But not as much as I hate seeing the &amp;quot;connection failed&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Not yet, anyway.&lt;br /&gt;
&lt;br /&gt;
Using the [http://php.net/manual/en/book.hrtime.php &#039;&#039;hrtime&#039;&#039; extension,] I can see that this little connection check only takes a couple of milliseconds, so it&#039;s not costing me huge time in loading pages.  &lt;br /&gt;
&lt;br /&gt;
But I hate it.&lt;br /&gt;
&lt;br /&gt;
== It&#039;s a feature, not a bug ==&lt;br /&gt;
&lt;br /&gt;
The MediaWiki wizards know &#039;that there is something awkward in &#039;&#039;&#039;LoadBalancer.php&#039;&#039;&#039;: [https://phabricator.wikimedia.org/T72223#1673869 &amp;quot;&#039;Unknown error&#039; in LoadBalancer-&amp;gt;reportConnectionError() hides a real database problem&amp;quot; (Sep 25 2015, 9:15 AM):]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Change 157488 abandoned by Hashar:&lt;br /&gt;
Do not hide real DB error on first connect&lt;br /&gt;
&lt;br /&gt;
Reason:&lt;br /&gt;
That would cause T31233 Broken failover for DB slave connection errors.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;The try/catch was done on purpose&#039;&#039;&#039;&#039;&#039;, see Tim comment on https://www.mediawiki.org/wiki/Special:Code/MediaWiki/90266#c20239 &lt;br /&gt;
&lt;br /&gt;
We have a task for a better fix T35036&lt;br /&gt;
&lt;br /&gt;
[https://gerrit.wikimedia.org/r/157488 Do not hide real DB error on first connect]&lt;br /&gt;
:: LoadBalancer should not silence database exception. Bug: 70223&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is not a problem on public linux production sites, such as this one (moleski.net) and another one that I run, even though they are, like localhost, single-server sites with no database slaves to worry about.&lt;br /&gt;
&lt;br /&gt;
There is &#039;&#039;something&#039;&#039; about the Windows environment that unsettles Mediawiki&#039;s database procedures ...&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #2 ==&lt;br /&gt;
&lt;br /&gt;
I&#039;ve commented out the &amp;quot;try ... catch&amp;quot; code and replaced with with the rejected simplification suggested by Saper.  I don&#039;t care that this simplification &amp;quot;would cause T31233 Broken failover for DB slave connection errors.&amp;quot; Not my circus, not my monkeys.  I&#039;m running this code on &#039;&#039;localhost.&#039;&#039;  There are no slave connections.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# MXM Cutting out &amp;quot;ugliest thing&amp;quot; and substituting another&#039;s guy&#039;s remedy&lt;br /&gt;
#		try {&lt;br /&gt;
#			$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
#		} catch ( DBConnectionError $e ) {&lt;br /&gt;
#			// FIXME: This is probably the ugliest thing I have ever done to&lt;br /&gt;
#			// PHP. I&#039;m half-expecting it to segfault, just out of disgust. -- TS&lt;br /&gt;
#			$db = $e-&amp;gt;db;&lt;br /&gt;
#                       die(&#039;MXM: yep, came through here.&#039;)&lt;br /&gt;
#		}&lt;br /&gt;
# MXM&lt;br /&gt;
$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
# MXM&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What difference does this difference make?  $db is not assigned to $e-&amp;gt;db if the connection fails.  I put some feedback in the &amp;quot;catch&amp;quot; block, to see if for some reason my system is taking that route.  After I rebooted, I got the confirmation that the program execution flowed through that branch.&lt;br /&gt;
&lt;br /&gt;
But making this change did not make all things well again.  On a cold boot the next day, all of my &amp;quot;technical difficulties&amp;quot; came crashing back.  By itself, Ugly Workaround #2 does not scratch the itch.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;What I don&#039;t know is why there is any problem on startup at all&#039;&#039;&#039;&#039;&#039;.  What is the difference between this setup and the one that hummed along for almost three years without any difficulty?  I can&#039;t disable Cylance to find out.  It is imposed on me from above.  In theory, I have configured Malware Bytes to ignore things served from localhost.  &lt;br /&gt;
&lt;br /&gt;
== Just the facts, Ma&#039;am. ==&lt;br /&gt;
&lt;br /&gt;
:: - My setup is slow on startup after a reboot.&lt;br /&gt;
:: - Mediawiki is not willing to wait for localhost to wake up.&lt;br /&gt;
:: - Ugly Workaround #1 does work around the problem, probably because it has no Mediawiki timer running but just sits there stupidly for hundreds of thousands of nanoseconds while something in the background preoccupies my system.  If I can find the timing loop for the connection, I can maybe develop a more elegant workaround.&lt;br /&gt;
&lt;br /&gt;
== Tweak MySQL ==&lt;br /&gt;
&lt;br /&gt;
; [https://bugs.mysql.com/bug.php?id=28805 &amp;quot;MySQL Service takes a very long time to start up.&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
: I&#039;ve set httpd and mysqld to run with administrator privileges after reading this article, FWIW.&lt;br /&gt;
&lt;br /&gt;
== I give up ==&lt;br /&gt;
&lt;br /&gt;
I&#039;m not going to find an elegant solution.&lt;br /&gt;
&lt;br /&gt;
Ugly Workaround #1 works.&lt;br /&gt;
&lt;br /&gt;
I presume that is because my request for a connection has no timing constraints.&lt;br /&gt;
&lt;br /&gt;
If the system is slow to respond, that line of code just waits until MySQL starts talking.  Once aroused, then the server is ready to respond to queries from Mediawiki in a reasonable time frame.&lt;br /&gt;
&lt;br /&gt;
It works.&lt;br /&gt;
&lt;br /&gt;
That is really all that matters.&lt;br /&gt;
&lt;br /&gt;
It&#039;s ugly.&lt;br /&gt;
&lt;br /&gt;
Once the inital lag is over, it doesn&#039;t cost me more than a few microseconds at the most per fresh page load.  That&#039;s a small price to pay for not having to manually reload my home pages after cold boots or long delays.&lt;br /&gt;
&lt;br /&gt;
I can live with it.&lt;br /&gt;
&lt;br /&gt;
Yes, I can.&lt;br /&gt;
&lt;br /&gt;
Any Day Now.&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.mail-archive.com/mediawiki-commits@lists.wikimedia.org/msg283522.html &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;MediaWiki-commits&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;Gerrit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; Add support for connect_timeout -	change (mediawiki...PoolCounter).]&lt;br /&gt;
:: The intriguing line: &#039;&#039;we implement here what we already do for mysql connections: if we set a connection timeout to a very small value (in the order of magnitude of twice the RTT to the poolcounter server) and retry twice, we can have very fast failures in case one server goes down, and the failover to the other active servers would happen almost harmlessly.&#039;&#039;  &lt;br /&gt;
:: I&#039;m convinced this is a clue, but I haven&#039;t waded into the code to see what I might be able to play with.  &lt;br /&gt;
* [http://serverfault.com/questions/408550/connecting-to-mysql-from-php-is-extremely-slow &amp;quot;Connecting to MySQL from PHP is extremely slow.&amp;quot;]&lt;br /&gt;
:: David Random&#039;s essay on this page is superb.  It didn&#039;t fix what ailed me, but it made me feel that I was understanding the problem better.&lt;br /&gt;
* [https://ineed.coffee/1441/apache-php-mysql-slow-under-windows-8-how-to-fix/ &amp;quot;Apache, PHP, MySQL slow under Windows 8. How to fix.&amp;quot;]&lt;br /&gt;
* [http://stackoverflow.com/questions/8432601/wamp-xampp-is-responding-very-slow-over-localhost/17163207#17163207 &amp;quot;WAMP/XAMPP is responding very slow over localhost.&amp;quot;]&lt;br /&gt;
:: Contains an excellent set of links to various tips and tricks, as well as making some fresh suggestions.&lt;br /&gt;
* [http://127.0.0.1/mediawiki/api.php?action=query&amp;amp;meta=siteinfo&amp;amp;siprop=statistics&amp;amp;format=jsonfm Count jobs on my localhost.]  This won&#039;t do you any good or me any harm, if I&#039;m lucky.  This is a handy spot for me to drop this link to see whether jobs have accumulated on my local wiki.  They haven&#039;t.&lt;br /&gt;
[[Category:Computers]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16409</id>
		<title>WAMP, localhost, Mediawiki: Cannot access the database</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16409"/>
		<updated>2015-12-04T03:45:11Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* Software Guardians */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;or &#039;&#039;&#039;&#039;&#039;The Bug that Ate a Week of My Life!&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mediawiki on localhost ==&lt;br /&gt;
&lt;br /&gt;
Since 2:42 PM on 14 March 2009, I have run a private wiki for myself on a WAMP stack--6.5 years and counting.&lt;br /&gt;
&lt;br /&gt;
I have migrated the wiki from one desktop to another and installed it on two different laptops.&lt;br /&gt;
&lt;br /&gt;
I have never had everything work perfectly right out of the box, but I have never been frustrated for too long.  People have solved all of the basic problems more than once, and it has been just a matter of googling around long enough to debug the setup.&lt;br /&gt;
&lt;br /&gt;
All that has changed.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve found a bug that has defeated me.&lt;br /&gt;
&lt;br /&gt;
== Mediawiki 1.26, WAMPserver 2.5, and WAMPserver 3 ==&lt;br /&gt;
&lt;br /&gt;
== Error Messages ==&lt;br /&gt;
&lt;br /&gt;
=== Shorter version ===&lt;br /&gt;
&lt;br /&gt;
Sorry! This site is experiencing technical difficulties.&lt;br /&gt;
&lt;br /&gt;
Try waiting a few minutes and reloading.&lt;br /&gt;
&lt;br /&gt;
(Cannot access the database)&lt;br /&gt;
&lt;br /&gt;
=== With debugging and backtracking enabled ===&lt;br /&gt;
&lt;br /&gt;
Cannot access the database: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ())&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Backtrace:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
:  #0 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(842): &#039;&#039;&#039;DatabaseBase&#039;&#039;&#039;-&amp;gt;reportConnectionError(&#039;Unknown error (...&#039;)&lt;br /&gt;
:  #1 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(537): &#039;&#039;&#039;LoadBalancer&#039;&#039;&#039;-&amp;gt;reportConnectionError()&lt;br /&gt;
:  #2 C:\wamp\www\mediawiki\includes\GlobalFunctions.php(3631): LoadBalancer-&amp;gt;getConnection(-1, Array, false)&lt;br /&gt;
:  #3 C:\wamp\www\mediawiki\includes\User.php(1208): wfGetDB(-1)&lt;br /&gt;
:  #4 C:\wamp\www\mediawiki\includes\User.php(397): User-&amp;gt;loadFromDatabase(0)&lt;br /&gt;
:  #5 C:\wamp\www\mediawiki\includes\User.php(362): User-&amp;gt;loadFromId(0)&lt;br /&gt;
:  #6 C:\wamp\www\mediawiki\includes\User.php(2459): User-&amp;gt;load()&lt;br /&gt;
:  #7 C:\wamp\www\mediawiki\includes\User.php(1167): User-&amp;gt;getToken(false)&lt;br /&gt;
:  #8 C:\wamp\www\mediawiki\includes\User.php(365): User-&amp;gt;loadFromSession()&lt;br /&gt;
:  #9 C:\wamp\www\mediawiki\includes\User.php(2029): User-&amp;gt;load()&lt;br /&gt;
:  #10 C:\wamp\www\mediawiki\includes\User.php(3204): User-&amp;gt;getId()&lt;br /&gt;
:  #11 C:\wamp\www\mediawiki\includes\MediaWiki.php(627): User-&amp;gt;isLoggedIn()&lt;br /&gt;
:  #12 C:\wamp\www\mediawiki\includes\MediaWiki.php(476): MediaWiki-&amp;gt;main()&lt;br /&gt;
:  #13 C:\wamp\www\mediawiki\index.php(51): MediaWiki-&amp;gt;run()&lt;br /&gt;
:  #14 {main}&lt;br /&gt;
&lt;br /&gt;
:  reportConnectionError &amp;quot;Unknown error&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Failure message when MySQL is totally disabled ===&lt;br /&gt;
&lt;br /&gt;
Warning: mysqli::mysqli(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp\www\mediawiki\LocalSettings.php on line 152&lt;br /&gt;
&lt;br /&gt;
Connection failed: No connection could be made because the target machine actively refused it.&lt;br /&gt;
&lt;br /&gt;
== Not a code or configuration problem ==&lt;br /&gt;
&lt;br /&gt;
Except for a few times when I shot myself in the foot while debugging, the proof that the PHP code base and my configuration are correct is that I can immediately obtain the page I want by reloading the page.  &lt;br /&gt;
&lt;br /&gt;
It is only on the first call after a long time (five minutes? ten?) of not accessing the wiki that the problem occurs.&lt;br /&gt;
&lt;br /&gt;
== Timing is everything ==&lt;br /&gt;
&lt;br /&gt;
The most common time for the bug to bite is when I open my browser.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve got two tabs to pages on the local wiki in my collection of home pages.&lt;br /&gt;
&lt;br /&gt;
The first one usually fails if I&#039;ve had the browser closed for a while; the second never does.&lt;br /&gt;
&lt;br /&gt;
I dropped the second page from the set to see if that would help the first. &lt;br /&gt;
&lt;br /&gt;
It didn&#039;t.&lt;br /&gt;
&lt;br /&gt;
Once MySQL is awakened from its slumbers, all the links in the wiki work reasonably well--no worse than ever before--unless I spend a long time composing a page, and then the connection fails when I try to save the page.  Refresh the page, and it saves perfectly.&lt;br /&gt;
&lt;br /&gt;
Something somewhere keeps MySQL from answering the FIRST request for a connection in the time frame that Mediawiki expects.  After that, everything is normal enough until MySQL decides to fall asleep again.&lt;br /&gt;
&lt;br /&gt;
== Round up the usual suspects ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s some interaction between Windows, Apache, MySQL, and the Wikimedia routines that has got me down.&lt;br /&gt;
&lt;br /&gt;
Why can&#039;t we all just get along?&lt;br /&gt;
&lt;br /&gt;
The articles in the [[#Links|links below]] have got excellent information and links in them.  They cover pretty much everything I&#039;ve tried, and then some.  I&#039;m just going to list the failed fixes that float into mind:&lt;br /&gt;
&lt;br /&gt;
* turn off IPv6 on my machine&lt;br /&gt;
* have Apache listen only to 127.0.0.1:80&lt;br /&gt;
* bind MySQL to 127.0.0.1 &lt;br /&gt;
* turn off name resolution in MySQL&lt;br /&gt;
* change localhost to 127.0.0.1 everywhere I can to avoid DNS calls&lt;br /&gt;
* edit Hosts file to make sure localhost is defined&lt;br /&gt;
* enable opcache and install APCu&lt;br /&gt;
* turn off Zend debugger&lt;br /&gt;
* moved from WAMPserver 2.5 to 3&lt;br /&gt;
&lt;br /&gt;
Total failure, but intriguing: get MySQL to use a socket.  There are paths for it in the configuration files, but I&#039;ve never gotten it going.  I must do more googling!  It seems as though it SHOULD work.&lt;br /&gt;
&lt;br /&gt;
== Sysinfo ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
: BIOS Manufacturer: American Megatrends Inc.&lt;br /&gt;
: Release Date: 10/23/2012&lt;br /&gt;
: BIOS Version: ALASKA - 1072009&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: Board Product ID: Gigabyte 990FXA-UD3&lt;br /&gt;
&lt;br /&gt;
: AMD FX-8350 Eight-Core Processor, 4 Ghz&lt;br /&gt;
: 16 GB RAM&lt;br /&gt;
: 480 Gb SSHD&lt;br /&gt;
: 1 Tb HD&lt;br /&gt;
: 650 W power supply&lt;br /&gt;
: AMD Radeon HD 7700 with 2 Gb RAM&lt;br /&gt;
&lt;br /&gt;
Report Generated at: 1/8/2013 1:02:45 AM&lt;br /&gt;
&lt;br /&gt;
OK, so the machine is sneaking up on its third year in service.  It still gets a decent rating from me and Windows:&lt;br /&gt;
&lt;br /&gt;
[[File:Homebrew 5 performance.jpg]]&lt;br /&gt;
&lt;br /&gt;
And, as with everything else except for Wikimedia version and the WAMPserver versions, I haven&#039;t changed anything from last week, when all was well in wikiland.&lt;br /&gt;
&lt;br /&gt;
=== OS ===&lt;br /&gt;
&lt;br /&gt;
: Windows 7 Professional, 64-bit&lt;br /&gt;
: Service Pack 1&lt;br /&gt;
&lt;br /&gt;
=== Browser ===&lt;br /&gt;
&lt;br /&gt;
: Chrome 46.0.2490.86 m&lt;br /&gt;
&lt;br /&gt;
=== Software Guardians ===&lt;br /&gt;
&lt;br /&gt;
: Malware Bytes&lt;br /&gt;
::: Set to exclude 127.0.0.1, httpd.exe, and mysql.exe from inspection.&lt;br /&gt;
&lt;br /&gt;
: CylanceProtect&lt;br /&gt;
::: I&#039;ve got no control over this.  All I can say is that with MediaWiki 1.20, I had no connection problems.&lt;br /&gt;
&lt;br /&gt;
: Firewall&lt;br /&gt;
::: Made sure port 3306 is open.&lt;br /&gt;
&lt;br /&gt;
=== WAMPserver 3 ===&lt;br /&gt;
&lt;br /&gt;
::{|&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|Apache &lt;br /&gt;
|2.4.17&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|MySQL &lt;br /&gt;
|5.7.9&lt;br /&gt;
|-&lt;br /&gt;
|align=&amp;quot;right&amp;quot;|PHP &lt;br /&gt;
|5.6.15&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #1 ==&lt;br /&gt;
&lt;br /&gt;
Because the connection ALWAYS worked on the very next try after a failure, I thought that perhaps I could arrange a sacrificial connection to feed the ravenous Connection Monster; while it was chomping on the carcass, the real Mediawiki connection might sneak by unnoticed.&lt;br /&gt;
&lt;br /&gt;
So I put this in my LocalSettings.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$servername = &amp;quot;127.0.0.1&amp;quot;;&lt;br /&gt;
$username = &amp;quot;dbuser&amp;quot;;&lt;br /&gt;
$password = &amp;quot;dbuserpassword&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Create connection&lt;br /&gt;
$conn = new mysqli($servername, $username, $password);&lt;br /&gt;
&lt;br /&gt;
// Check connection&lt;br /&gt;
if ($conn-&amp;gt;connect_error) {&lt;br /&gt;
    die(&amp;quot;Connection failed: &amp;quot; . $conn-&amp;gt;connect_error);&lt;br /&gt;
} &lt;br /&gt;
#echo &amp;quot;Connected successfully&amp;quot;;&lt;br /&gt;
mysqli_close($conn);&lt;br /&gt;
#die(&amp;quot;test finished&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This idiotic connection hasn&#039;t ever failed yet.&lt;br /&gt;
&lt;br /&gt;
And the wiki page hasn&#039;t yet failed to connect afterward, either.&lt;br /&gt;
&lt;br /&gt;
Pasta faggiole!&lt;br /&gt;
&lt;br /&gt;
I hate it.&lt;br /&gt;
&lt;br /&gt;
But not as much as I hate seeing the &amp;quot;connection failed&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Not yet, anyway.&lt;br /&gt;
&lt;br /&gt;
Using the [http://php.net/manual/en/book.hrtime.php &#039;&#039;hrtime&#039;&#039; extension,] I can see that this little connection check only takes a couple of milliseconds, so it&#039;s not costing me huge time in loading pages.  &lt;br /&gt;
&lt;br /&gt;
But I hate it.&lt;br /&gt;
&lt;br /&gt;
== It&#039;s a feature, not a bug ==&lt;br /&gt;
&lt;br /&gt;
The MediaWiki wizards know &#039;that there is something awkward in &#039;&#039;&#039;LoadBalancer.php&#039;&#039;&#039;: [https://phabricator.wikimedia.org/T72223#1673869 &amp;quot;&#039;Unknown error&#039; in LoadBalancer-&amp;gt;reportConnectionError() hides a real database problem&amp;quot; (Sep 25 2015, 9:15 AM):]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Change 157488 abandoned by Hashar:&lt;br /&gt;
Do not hide real DB error on first connect&lt;br /&gt;
&lt;br /&gt;
Reason:&lt;br /&gt;
That would cause T31233 Broken failover for DB slave connection errors.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;The try/catch was done on purpose&#039;&#039;&#039;&#039;&#039;, see Tim comment on https://www.mediawiki.org/wiki/Special:Code/MediaWiki/90266#c20239 &lt;br /&gt;
&lt;br /&gt;
We have a task for a better fix T35036&lt;br /&gt;
&lt;br /&gt;
[https://gerrit.wikimedia.org/r/157488 Do not hide real DB error on first connect]&lt;br /&gt;
:: LoadBalancer should not silence database exception. Bug: 70223&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is not a problem on public linux production sites, such as this one (moleski.net) and another one that I run, even though they are, like localhost, single-server sites with no database slaves to worry about.&lt;br /&gt;
&lt;br /&gt;
There is &#039;&#039;something&#039;&#039; about the Windows environment that unsettles Mediawiki&#039;s database procedures ...&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #2 ==&lt;br /&gt;
&lt;br /&gt;
I&#039;ve commented out the &amp;quot;try ... catch&amp;quot; code and replaced with with the rejected simplification suggested by Saper.  I don&#039;t care that this simplification &amp;quot;would cause T31233 Broken failover for DB slave connection errors.&amp;quot; Not my circus, not my monkeys.  I&#039;m running this code on &#039;&#039;localhost.&#039;&#039;  There are no slave connections.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# MXM Cutting out &amp;quot;ugliest thing&amp;quot; and substituting another&#039;s guy&#039;s remedy&lt;br /&gt;
#		try {&lt;br /&gt;
#			$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
#		} catch ( DBConnectionError $e ) {&lt;br /&gt;
#			// FIXME: This is probably the ugliest thing I have ever done to&lt;br /&gt;
#			// PHP. I&#039;m half-expecting it to segfault, just out of disgust. -- TS&lt;br /&gt;
#			$db = $e-&amp;gt;db;&lt;br /&gt;
#                       die(&#039;MXM: yep, came through here.&#039;)&lt;br /&gt;
#		}&lt;br /&gt;
# MXM&lt;br /&gt;
$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
# MXM&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What difference does this difference make?  $db is not assigned to $e-&amp;gt;db if the connection fails.  I put some feedback in the &amp;quot;catch&amp;quot; block, to see if for some reason my system is taking that route.  After I rebooted, I got the confirmation that the program execution flowed through that branch.&lt;br /&gt;
&lt;br /&gt;
But making this change did not make all things well again.  On a cold boot the next day, all of my &amp;quot;technical difficulties&amp;quot; came crashing back.  By itself, Ugly Workaround #2 does not scratch the itch.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;What I don&#039;t know is why there is any problem on startup at all&#039;&#039;&#039;&#039;&#039;.  What is the difference between this setup and the one that hummed along for almost three years without any difficulty?  I can&#039;t disable Cylance to find out.  It is imposed on me from above.  In theory, I have configured Malware Bytes to ignore things served from localhost.  &lt;br /&gt;
&lt;br /&gt;
== Just the facts, Ma&#039;am. ==&lt;br /&gt;
&lt;br /&gt;
:: - My setup is slow on startup after a reboot.&lt;br /&gt;
:: - Mediawiki is not willing to wait for localhost to wake up.&lt;br /&gt;
:: - Ugly Workaround #1 does work around the problem, probably because it has no Mediawiki timer running but just sits there stupidly for hundreds of thousands of nanoseconds while something in the background preoccupies my system.  If I can find the timing loop for the connection, I can maybe develop a more elegant workaround.&lt;br /&gt;
&lt;br /&gt;
== Tweak MySQL ==&lt;br /&gt;
&lt;br /&gt;
; [https://bugs.mysql.com/bug.php?id=28805 &amp;quot;MySQL Service takes a very long time to start up.&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
: I&#039;ve set httpd and mysqld to run with administrator privileges after reading this article, FWIW.&lt;br /&gt;
&lt;br /&gt;
== I give up ==&lt;br /&gt;
&lt;br /&gt;
I&#039;m not going to find an elegant solution.&lt;br /&gt;
&lt;br /&gt;
Ugly Workaround #1 works.&lt;br /&gt;
&lt;br /&gt;
I presume that is because my request for a connection has no timing constraints.&lt;br /&gt;
&lt;br /&gt;
If the system is slow to respond, that line of code just waits until MySQL starts talking.  Once aroused, then the server is ready to respond to queries from Mediawiki in a reasonable time frame.&lt;br /&gt;
&lt;br /&gt;
It works.&lt;br /&gt;
&lt;br /&gt;
That is really all that matters.&lt;br /&gt;
&lt;br /&gt;
It&#039;s ugly.&lt;br /&gt;
&lt;br /&gt;
Once the inital lag is over, it doesn&#039;t cost me more than a few microseconds at the most per fresh page load.  That&#039;s a small price to pay for not having to manually reload my home pages after cold boots or long delays.&lt;br /&gt;
&lt;br /&gt;
I can live with it.&lt;br /&gt;
&lt;br /&gt;
Yes, I can.&lt;br /&gt;
&lt;br /&gt;
Any Day Now.&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.mail-archive.com/mediawiki-commits@lists.wikimedia.org/msg283522.html &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;MediaWiki-commits&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;Gerrit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; Add support for connect_timeout -	change (mediawiki...PoolCounter).]&lt;br /&gt;
:: The intriguing line: &#039;&#039;we implement here what we already do for mysql connections: if we set a connection timeout to a very small value (in the order of magnitude of twice the RTT to the poolcounter server) and retry twice, we can have very fast failures in case one server goes down, and the failover to the other active servers would happen almost harmlessly.&#039;&#039;  &lt;br /&gt;
:: I&#039;m convinced this is a clue, but I haven&#039;t waded into the code to see what I might be able to play with.  &lt;br /&gt;
* [http://serverfault.com/questions/408550/connecting-to-mysql-from-php-is-extremely-slow &amp;quot;Connecting to MySQL from PHP is extremely slow.&amp;quot;]&lt;br /&gt;
:: David Random&#039;s essay on this page is superb.  It didn&#039;t fix what ailed me, but it made me feel that I was understanding the problem better.&lt;br /&gt;
* [https://ineed.coffee/1441/apache-php-mysql-slow-under-windows-8-how-to-fix/ &amp;quot;Apache, PHP, MySQL slow under Windows 8. How to fix.&amp;quot;]&lt;br /&gt;
* [http://stackoverflow.com/questions/8432601/wamp-xampp-is-responding-very-slow-over-localhost/17163207#17163207 &amp;quot;WAMP/XAMPP is responding very slow over localhost.&amp;quot;]&lt;br /&gt;
:: Contains an excellent set of links to various tips and tricks, as well as making some fresh suggestions.&lt;br /&gt;
* [http://127.0.0.1/mediawiki/api.php?action=query&amp;amp;meta=siteinfo&amp;amp;siprop=statistics&amp;amp;format=jsonfm Count jobs on my localhost.]  This won&#039;t do you any good or me any harm, if I&#039;m lucky.  This is a handy spot for me to drop this link to see whether jobs have accumulated on my local wiki.  They haven&#039;t.&lt;br /&gt;
[[Category:Computers]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16408</id>
		<title>WAMP, localhost, Mediawiki: Cannot access the database</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16408"/>
		<updated>2015-12-04T01:18:02Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* Tweak MySQL */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;or &#039;&#039;&#039;&#039;&#039;The Bug that Ate a Week of My Life!&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mediawiki on localhost ==&lt;br /&gt;
&lt;br /&gt;
Since 2:42 PM on 14 March 2009, I have run a private wiki for myself on a WAMP stack--6.5 years and counting.&lt;br /&gt;
&lt;br /&gt;
I have migrated the wiki from one desktop to another and installed it on two different laptops.&lt;br /&gt;
&lt;br /&gt;
I have never had everything work perfectly right out of the box, but I have never been frustrated for too long.  People have solved all of the basic problems more than once, and it has been just a matter of googling around long enough to debug the setup.&lt;br /&gt;
&lt;br /&gt;
All that has changed.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve found a bug that has defeated me.&lt;br /&gt;
&lt;br /&gt;
== Mediawiki 1.26, WAMPserver 2.5, and WAMPserver 3 ==&lt;br /&gt;
&lt;br /&gt;
== Error Messages ==&lt;br /&gt;
&lt;br /&gt;
=== Shorter version ===&lt;br /&gt;
&lt;br /&gt;
Sorry! This site is experiencing technical difficulties.&lt;br /&gt;
&lt;br /&gt;
Try waiting a few minutes and reloading.&lt;br /&gt;
&lt;br /&gt;
(Cannot access the database)&lt;br /&gt;
&lt;br /&gt;
=== With debugging and backtracking enabled ===&lt;br /&gt;
&lt;br /&gt;
Cannot access the database: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ())&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Backtrace:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
:  #0 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(842): &#039;&#039;&#039;DatabaseBase&#039;&#039;&#039;-&amp;gt;reportConnectionError(&#039;Unknown error (...&#039;)&lt;br /&gt;
:  #1 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(537): &#039;&#039;&#039;LoadBalancer&#039;&#039;&#039;-&amp;gt;reportConnectionError()&lt;br /&gt;
:  #2 C:\wamp\www\mediawiki\includes\GlobalFunctions.php(3631): LoadBalancer-&amp;gt;getConnection(-1, Array, false)&lt;br /&gt;
:  #3 C:\wamp\www\mediawiki\includes\User.php(1208): wfGetDB(-1)&lt;br /&gt;
:  #4 C:\wamp\www\mediawiki\includes\User.php(397): User-&amp;gt;loadFromDatabase(0)&lt;br /&gt;
:  #5 C:\wamp\www\mediawiki\includes\User.php(362): User-&amp;gt;loadFromId(0)&lt;br /&gt;
:  #6 C:\wamp\www\mediawiki\includes\User.php(2459): User-&amp;gt;load()&lt;br /&gt;
:  #7 C:\wamp\www\mediawiki\includes\User.php(1167): User-&amp;gt;getToken(false)&lt;br /&gt;
:  #8 C:\wamp\www\mediawiki\includes\User.php(365): User-&amp;gt;loadFromSession()&lt;br /&gt;
:  #9 C:\wamp\www\mediawiki\includes\User.php(2029): User-&amp;gt;load()&lt;br /&gt;
:  #10 C:\wamp\www\mediawiki\includes\User.php(3204): User-&amp;gt;getId()&lt;br /&gt;
:  #11 C:\wamp\www\mediawiki\includes\MediaWiki.php(627): User-&amp;gt;isLoggedIn()&lt;br /&gt;
:  #12 C:\wamp\www\mediawiki\includes\MediaWiki.php(476): MediaWiki-&amp;gt;main()&lt;br /&gt;
:  #13 C:\wamp\www\mediawiki\index.php(51): MediaWiki-&amp;gt;run()&lt;br /&gt;
:  #14 {main}&lt;br /&gt;
&lt;br /&gt;
:  reportConnectionError &amp;quot;Unknown error&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Failure message when MySQL is totally disabled ===&lt;br /&gt;
&lt;br /&gt;
Warning: mysqli::mysqli(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp\www\mediawiki\LocalSettings.php on line 152&lt;br /&gt;
&lt;br /&gt;
Connection failed: No connection could be made because the target machine actively refused it.&lt;br /&gt;
&lt;br /&gt;
== Not a code or configuration problem ==&lt;br /&gt;
&lt;br /&gt;
Except for a few times when I shot myself in the foot while debugging, the proof that the PHP code base and my configuration are correct is that I can immediately obtain the page I want by reloading the page.  &lt;br /&gt;
&lt;br /&gt;
It is only on the first call after a long time (five minutes? ten?) of not accessing the wiki that the problem occurs.&lt;br /&gt;
&lt;br /&gt;
== Timing is everything ==&lt;br /&gt;
&lt;br /&gt;
The most common time for the bug to bite is when I open my browser.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve got two tabs to pages on the local wiki in my collection of home pages.&lt;br /&gt;
&lt;br /&gt;
The first one usually fails if I&#039;ve had the browser closed for a while; the second never does.&lt;br /&gt;
&lt;br /&gt;
I dropped the second page from the set to see if that would help the first. &lt;br /&gt;
&lt;br /&gt;
It didn&#039;t.&lt;br /&gt;
&lt;br /&gt;
Once MySQL is awakened from its slumbers, all the links in the wiki work reasonably well--no worse than ever before--unless I spend a long time composing a page, and then the connection fails when I try to save the page.  Refresh the page, and it saves perfectly.&lt;br /&gt;
&lt;br /&gt;
Something somewhere keeps MySQL from answering the FIRST request for a connection in the time frame that Mediawiki expects.  After that, everything is normal enough until MySQL decides to fall asleep again.&lt;br /&gt;
&lt;br /&gt;
== Round up the usual suspects ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s some interaction between Windows, Apache, MySQL, and the Wikimedia routines that has got me down.&lt;br /&gt;
&lt;br /&gt;
Why can&#039;t we all just get along?&lt;br /&gt;
&lt;br /&gt;
The articles in the [[#Links|links below]] have got excellent information and links in them.  They cover pretty much everything I&#039;ve tried, and then some.  I&#039;m just going to list the failed fixes that float into mind:&lt;br /&gt;
&lt;br /&gt;
* turn off IPv6 on my machine&lt;br /&gt;
* have Apache listen only to 127.0.0.1:80&lt;br /&gt;
* bind MySQL to 127.0.0.1 &lt;br /&gt;
* turn off name resolution in MySQL&lt;br /&gt;
* change localhost to 127.0.0.1 everywhere I can to avoid DNS calls&lt;br /&gt;
* edit Hosts file to make sure localhost is defined&lt;br /&gt;
* enable opcache and install APCu&lt;br /&gt;
* turn off Zend debugger&lt;br /&gt;
* moved from WAMPserver 2.5 to 3&lt;br /&gt;
&lt;br /&gt;
Total failure, but intriguing: get MySQL to use a socket.  There are paths for it in the configuration files, but I&#039;ve never gotten it going.  I must do more googling!  It seems as though it SHOULD work.&lt;br /&gt;
&lt;br /&gt;
== Sysinfo ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
: BIOS Manufacturer: American Megatrends Inc.&lt;br /&gt;
: Release Date: 10/23/2012&lt;br /&gt;
: BIOS Version: ALASKA - 1072009&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: Board Product ID: Gigabyte 990FXA-UD3&lt;br /&gt;
&lt;br /&gt;
: AMD FX-8350 Eight-Core Processor, 4 Ghz&lt;br /&gt;
: 16 GB RAM&lt;br /&gt;
: 480 Gb SSHD&lt;br /&gt;
: 1 Tb HD&lt;br /&gt;
: 650 W power supply&lt;br /&gt;
: AMD Radeon HD 7700 with 2 Gb RAM&lt;br /&gt;
&lt;br /&gt;
Report Generated at: 1/8/2013 1:02:45 AM&lt;br /&gt;
&lt;br /&gt;
OK, so the machine is sneaking up on its third year in service.  It still gets a decent rating from me and Windows:&lt;br /&gt;
&lt;br /&gt;
[[File:Homebrew 5 performance.jpg]]&lt;br /&gt;
&lt;br /&gt;
And, as with everything else except for Wikimedia version and the WAMPserver versions, I haven&#039;t changed anything from last week, when all was well in wikiland.&lt;br /&gt;
&lt;br /&gt;
=== OS ===&lt;br /&gt;
&lt;br /&gt;
: Windows 7 Professional, 64-bit&lt;br /&gt;
: Service Pack 1&lt;br /&gt;
&lt;br /&gt;
=== Browser ===&lt;br /&gt;
&lt;br /&gt;
: Chrome 46.0.2490.86 m&lt;br /&gt;
&lt;br /&gt;
=== Software Guardians ===&lt;br /&gt;
&lt;br /&gt;
: Malware Bytes&lt;br /&gt;
::: Set to exclude 127.0.0.1, httpd.exe, and mysql.exe from inspection.&lt;br /&gt;
&lt;br /&gt;
: CylanceProtect&lt;br /&gt;
::: I&#039;ve got no control over this.  All I can say is that with MediaWiki 1.20, I had no connection problems.&lt;br /&gt;
&lt;br /&gt;
: Firewall&lt;br /&gt;
::: Made sure port 3306 is open.&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #1 ==&lt;br /&gt;
&lt;br /&gt;
Because the connection ALWAYS worked on the very next try after a failure, I thought that perhaps I could arrange a sacrificial connection to feed the ravenous Connection Monster; while it was chomping on the carcass, the real Mediawiki connection might sneak by unnoticed.&lt;br /&gt;
&lt;br /&gt;
So I put this in my LocalSettings.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$servername = &amp;quot;127.0.0.1&amp;quot;;&lt;br /&gt;
$username = &amp;quot;dbuser&amp;quot;;&lt;br /&gt;
$password = &amp;quot;dbuserpassword&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Create connection&lt;br /&gt;
$conn = new mysqli($servername, $username, $password);&lt;br /&gt;
&lt;br /&gt;
// Check connection&lt;br /&gt;
if ($conn-&amp;gt;connect_error) {&lt;br /&gt;
    die(&amp;quot;Connection failed: &amp;quot; . $conn-&amp;gt;connect_error);&lt;br /&gt;
} &lt;br /&gt;
#echo &amp;quot;Connected successfully&amp;quot;;&lt;br /&gt;
mysqli_close($conn);&lt;br /&gt;
#die(&amp;quot;test finished&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This idiotic connection hasn&#039;t ever failed yet.&lt;br /&gt;
&lt;br /&gt;
And the wiki page hasn&#039;t yet failed to connect afterward, either.&lt;br /&gt;
&lt;br /&gt;
Pasta faggiole!&lt;br /&gt;
&lt;br /&gt;
I hate it.&lt;br /&gt;
&lt;br /&gt;
But not as much as I hate seeing the &amp;quot;connection failed&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Not yet, anyway.&lt;br /&gt;
&lt;br /&gt;
Using the [http://php.net/manual/en/book.hrtime.php &#039;&#039;hrtime&#039;&#039; extension,] I can see that this little connection check only takes a couple of milliseconds, so it&#039;s not costing me huge time in loading pages.  &lt;br /&gt;
&lt;br /&gt;
But I hate it.&lt;br /&gt;
&lt;br /&gt;
== It&#039;s a feature, not a bug ==&lt;br /&gt;
&lt;br /&gt;
The MediaWiki wizards know &#039;that there is something awkward in &#039;&#039;&#039;LoadBalancer.php&#039;&#039;&#039;: [https://phabricator.wikimedia.org/T72223#1673869 &amp;quot;&#039;Unknown error&#039; in LoadBalancer-&amp;gt;reportConnectionError() hides a real database problem&amp;quot; (Sep 25 2015, 9:15 AM):]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Change 157488 abandoned by Hashar:&lt;br /&gt;
Do not hide real DB error on first connect&lt;br /&gt;
&lt;br /&gt;
Reason:&lt;br /&gt;
That would cause T31233 Broken failover for DB slave connection errors.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;The try/catch was done on purpose&#039;&#039;&#039;&#039;&#039;, see Tim comment on https://www.mediawiki.org/wiki/Special:Code/MediaWiki/90266#c20239 &lt;br /&gt;
&lt;br /&gt;
We have a task for a better fix T35036&lt;br /&gt;
&lt;br /&gt;
[https://gerrit.wikimedia.org/r/157488 Do not hide real DB error on first connect]&lt;br /&gt;
:: LoadBalancer should not silence database exception. Bug: 70223&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is not a problem on public linux production sites, such as this one (moleski.net) and another one that I run, even though they are, like localhost, single-server sites with no database slaves to worry about.&lt;br /&gt;
&lt;br /&gt;
There is &#039;&#039;something&#039;&#039; about the Windows environment that unsettles Mediawiki&#039;s database procedures ...&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #2 ==&lt;br /&gt;
&lt;br /&gt;
I&#039;ve commented out the &amp;quot;try ... catch&amp;quot; code and replaced with with the rejected simplification suggested by Saper.  I don&#039;t care that this simplification &amp;quot;would cause T31233 Broken failover for DB slave connection errors.&amp;quot; Not my circus, not my monkeys.  I&#039;m running this code on &#039;&#039;localhost.&#039;&#039;  There are no slave connections.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# MXM Cutting out &amp;quot;ugliest thing&amp;quot; and substituting another&#039;s guy&#039;s remedy&lt;br /&gt;
#		try {&lt;br /&gt;
#			$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
#		} catch ( DBConnectionError $e ) {&lt;br /&gt;
#			// FIXME: This is probably the ugliest thing I have ever done to&lt;br /&gt;
#			// PHP. I&#039;m half-expecting it to segfault, just out of disgust. -- TS&lt;br /&gt;
#			$db = $e-&amp;gt;db;&lt;br /&gt;
#                       die(&#039;MXM: yep, came through here.&#039;)&lt;br /&gt;
#		}&lt;br /&gt;
# MXM&lt;br /&gt;
$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
# MXM&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What difference does this difference make?  $db is not assigned to $e-&amp;gt;db if the connection fails.  I put some feedback in the &amp;quot;catch&amp;quot; block, to see if for some reason my system is taking that route.  After I rebooted, I got the confirmation that the program execution flowed through that branch.&lt;br /&gt;
&lt;br /&gt;
But making this change did not make all things well again.  On a cold boot the next day, all of my &amp;quot;technical difficulties&amp;quot; came crashing back.  By itself, Ugly Workaround #2 does not scratch the itch.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;What I don&#039;t know is why there is any problem on startup at all&#039;&#039;&#039;&#039;&#039;.  What is the difference between this setup and the one that hummed along for almost three years without any difficulty?  I can&#039;t disable Cylance to find out.  It is imposed on me from above.  In theory, I have configured Malware Bytes to ignore things served from localhost.  &lt;br /&gt;
&lt;br /&gt;
== Just the facts, Ma&#039;am. ==&lt;br /&gt;
&lt;br /&gt;
:: - My setup is slow on startup after a reboot.&lt;br /&gt;
:: - Mediawiki is not willing to wait for localhost to wake up.&lt;br /&gt;
:: - Ugly Workaround #1 does work around the problem, probably because it has no Mediawiki timer running but just sits there stupidly for hundreds of thousands of nanoseconds while something in the background preoccupies my system.  If I can find the timing loop for the connection, I can maybe develop a more elegant workaround.&lt;br /&gt;
&lt;br /&gt;
== Tweak MySQL ==&lt;br /&gt;
&lt;br /&gt;
; [https://bugs.mysql.com/bug.php?id=28805 &amp;quot;MySQL Service takes a very long time to start up.&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
: I&#039;ve set httpd and mysqld to run with administrator privileges after reading this article, FWIW.&lt;br /&gt;
&lt;br /&gt;
== I give up ==&lt;br /&gt;
&lt;br /&gt;
I&#039;m not going to find an elegant solution.&lt;br /&gt;
&lt;br /&gt;
Ugly Workaround #1 works.&lt;br /&gt;
&lt;br /&gt;
I presume that is because my request for a connection has no timing constraints.&lt;br /&gt;
&lt;br /&gt;
If the system is slow to respond, that line of code just waits until MySQL starts talking.  Once aroused, then the server is ready to respond to queries from Mediawiki in a reasonable time frame.&lt;br /&gt;
&lt;br /&gt;
It works.&lt;br /&gt;
&lt;br /&gt;
That is really all that matters.&lt;br /&gt;
&lt;br /&gt;
It&#039;s ugly.&lt;br /&gt;
&lt;br /&gt;
Once the inital lag is over, it doesn&#039;t cost me more than a few microseconds at the most per fresh page load.  That&#039;s a small price to pay for not having to manually reload my home pages after cold boots or long delays.&lt;br /&gt;
&lt;br /&gt;
I can live with it.&lt;br /&gt;
&lt;br /&gt;
Yes, I can.&lt;br /&gt;
&lt;br /&gt;
Any Day Now.&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.mail-archive.com/mediawiki-commits@lists.wikimedia.org/msg283522.html &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;MediaWiki-commits&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;Gerrit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; Add support for connect_timeout -	change (mediawiki...PoolCounter).]&lt;br /&gt;
:: The intriguing line: &#039;&#039;we implement here what we already do for mysql connections: if we set a connection timeout to a very small value (in the order of magnitude of twice the RTT to the poolcounter server) and retry twice, we can have very fast failures in case one server goes down, and the failover to the other active servers would happen almost harmlessly.&#039;&#039;  &lt;br /&gt;
:: I&#039;m convinced this is a clue, but I haven&#039;t waded into the code to see what I might be able to play with.  &lt;br /&gt;
* [http://serverfault.com/questions/408550/connecting-to-mysql-from-php-is-extremely-slow &amp;quot;Connecting to MySQL from PHP is extremely slow.&amp;quot;]&lt;br /&gt;
:: David Random&#039;s essay on this page is superb.  It didn&#039;t fix what ailed me, but it made me feel that I was understanding the problem better.&lt;br /&gt;
* [https://ineed.coffee/1441/apache-php-mysql-slow-under-windows-8-how-to-fix/ &amp;quot;Apache, PHP, MySQL slow under Windows 8. How to fix.&amp;quot;]&lt;br /&gt;
* [http://stackoverflow.com/questions/8432601/wamp-xampp-is-responding-very-slow-over-localhost/17163207#17163207 &amp;quot;WAMP/XAMPP is responding very slow over localhost.&amp;quot;]&lt;br /&gt;
:: Contains an excellent set of links to various tips and tricks, as well as making some fresh suggestions.&lt;br /&gt;
* [http://127.0.0.1/mediawiki/api.php?action=query&amp;amp;meta=siteinfo&amp;amp;siprop=statistics&amp;amp;format=jsonfm Count jobs on my localhost.]  This won&#039;t do you any good or me any harm, if I&#039;m lucky.  This is a handy spot for me to drop this link to see whether jobs have accumulated on my local wiki.  They haven&#039;t.&lt;br /&gt;
[[Category:Computers]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16407</id>
		<title>WAMP, localhost, Mediawiki: Cannot access the database</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16407"/>
		<updated>2015-12-03T18:45:02Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;or &#039;&#039;&#039;&#039;&#039;The Bug that Ate a Week of My Life!&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mediawiki on localhost ==&lt;br /&gt;
&lt;br /&gt;
Since 2:42 PM on 14 March 2009, I have run a private wiki for myself on a WAMP stack--6.5 years and counting.&lt;br /&gt;
&lt;br /&gt;
I have migrated the wiki from one desktop to another and installed it on two different laptops.&lt;br /&gt;
&lt;br /&gt;
I have never had everything work perfectly right out of the box, but I have never been frustrated for too long.  People have solved all of the basic problems more than once, and it has been just a matter of googling around long enough to debug the setup.&lt;br /&gt;
&lt;br /&gt;
All that has changed.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve found a bug that has defeated me.&lt;br /&gt;
&lt;br /&gt;
== Mediawiki 1.26, WAMPserver 2.5, and WAMPserver 3 ==&lt;br /&gt;
&lt;br /&gt;
== Error Messages ==&lt;br /&gt;
&lt;br /&gt;
=== Shorter version ===&lt;br /&gt;
&lt;br /&gt;
Sorry! This site is experiencing technical difficulties.&lt;br /&gt;
&lt;br /&gt;
Try waiting a few minutes and reloading.&lt;br /&gt;
&lt;br /&gt;
(Cannot access the database)&lt;br /&gt;
&lt;br /&gt;
=== With debugging and backtracking enabled ===&lt;br /&gt;
&lt;br /&gt;
Cannot access the database: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ())&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Backtrace:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
:  #0 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(842): &#039;&#039;&#039;DatabaseBase&#039;&#039;&#039;-&amp;gt;reportConnectionError(&#039;Unknown error (...&#039;)&lt;br /&gt;
:  #1 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(537): &#039;&#039;&#039;LoadBalancer&#039;&#039;&#039;-&amp;gt;reportConnectionError()&lt;br /&gt;
:  #2 C:\wamp\www\mediawiki\includes\GlobalFunctions.php(3631): LoadBalancer-&amp;gt;getConnection(-1, Array, false)&lt;br /&gt;
:  #3 C:\wamp\www\mediawiki\includes\User.php(1208): wfGetDB(-1)&lt;br /&gt;
:  #4 C:\wamp\www\mediawiki\includes\User.php(397): User-&amp;gt;loadFromDatabase(0)&lt;br /&gt;
:  #5 C:\wamp\www\mediawiki\includes\User.php(362): User-&amp;gt;loadFromId(0)&lt;br /&gt;
:  #6 C:\wamp\www\mediawiki\includes\User.php(2459): User-&amp;gt;load()&lt;br /&gt;
:  #7 C:\wamp\www\mediawiki\includes\User.php(1167): User-&amp;gt;getToken(false)&lt;br /&gt;
:  #8 C:\wamp\www\mediawiki\includes\User.php(365): User-&amp;gt;loadFromSession()&lt;br /&gt;
:  #9 C:\wamp\www\mediawiki\includes\User.php(2029): User-&amp;gt;load()&lt;br /&gt;
:  #10 C:\wamp\www\mediawiki\includes\User.php(3204): User-&amp;gt;getId()&lt;br /&gt;
:  #11 C:\wamp\www\mediawiki\includes\MediaWiki.php(627): User-&amp;gt;isLoggedIn()&lt;br /&gt;
:  #12 C:\wamp\www\mediawiki\includes\MediaWiki.php(476): MediaWiki-&amp;gt;main()&lt;br /&gt;
:  #13 C:\wamp\www\mediawiki\index.php(51): MediaWiki-&amp;gt;run()&lt;br /&gt;
:  #14 {main}&lt;br /&gt;
&lt;br /&gt;
:  reportConnectionError &amp;quot;Unknown error&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Failure message when MySQL is totally disabled ===&lt;br /&gt;
&lt;br /&gt;
Warning: mysqli::mysqli(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp\www\mediawiki\LocalSettings.php on line 152&lt;br /&gt;
&lt;br /&gt;
Connection failed: No connection could be made because the target machine actively refused it.&lt;br /&gt;
&lt;br /&gt;
== Not a code or configuration problem ==&lt;br /&gt;
&lt;br /&gt;
Except for a few times when I shot myself in the foot while debugging, the proof that the PHP code base and my configuration are correct is that I can immediately obtain the page I want by reloading the page.  &lt;br /&gt;
&lt;br /&gt;
It is only on the first call after a long time (five minutes? ten?) of not accessing the wiki that the problem occurs.&lt;br /&gt;
&lt;br /&gt;
== Timing is everything ==&lt;br /&gt;
&lt;br /&gt;
The most common time for the bug to bite is when I open my browser.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve got two tabs to pages on the local wiki in my collection of home pages.&lt;br /&gt;
&lt;br /&gt;
The first one usually fails if I&#039;ve had the browser closed for a while; the second never does.&lt;br /&gt;
&lt;br /&gt;
I dropped the second page from the set to see if that would help the first. &lt;br /&gt;
&lt;br /&gt;
It didn&#039;t.&lt;br /&gt;
&lt;br /&gt;
Once MySQL is awakened from its slumbers, all the links in the wiki work reasonably well--no worse than ever before--unless I spend a long time composing a page, and then the connection fails when I try to save the page.  Refresh the page, and it saves perfectly.&lt;br /&gt;
&lt;br /&gt;
Something somewhere keeps MySQL from answering the FIRST request for a connection in the time frame that Mediawiki expects.  After that, everything is normal enough until MySQL decides to fall asleep again.&lt;br /&gt;
&lt;br /&gt;
== Round up the usual suspects ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s some interaction between Windows, Apache, MySQL, and the Wikimedia routines that has got me down.&lt;br /&gt;
&lt;br /&gt;
Why can&#039;t we all just get along?&lt;br /&gt;
&lt;br /&gt;
The articles in the [[#Links|links below]] have got excellent information and links in them.  They cover pretty much everything I&#039;ve tried, and then some.  I&#039;m just going to list the failed fixes that float into mind:&lt;br /&gt;
&lt;br /&gt;
* turn off IPv6 on my machine&lt;br /&gt;
* have Apache listen only to 127.0.0.1:80&lt;br /&gt;
* bind MySQL to 127.0.0.1 &lt;br /&gt;
* turn off name resolution in MySQL&lt;br /&gt;
* change localhost to 127.0.0.1 everywhere I can to avoid DNS calls&lt;br /&gt;
* edit Hosts file to make sure localhost is defined&lt;br /&gt;
* enable opcache and install APCu&lt;br /&gt;
* turn off Zend debugger&lt;br /&gt;
* moved from WAMPserver 2.5 to 3&lt;br /&gt;
&lt;br /&gt;
Total failure, but intriguing: get MySQL to use a socket.  There are paths for it in the configuration files, but I&#039;ve never gotten it going.  I must do more googling!  It seems as though it SHOULD work.&lt;br /&gt;
&lt;br /&gt;
== Sysinfo ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
: BIOS Manufacturer: American Megatrends Inc.&lt;br /&gt;
: Release Date: 10/23/2012&lt;br /&gt;
: BIOS Version: ALASKA - 1072009&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: Board Product ID: Gigabyte 990FXA-UD3&lt;br /&gt;
&lt;br /&gt;
: AMD FX-8350 Eight-Core Processor, 4 Ghz&lt;br /&gt;
: 16 GB RAM&lt;br /&gt;
: 480 Gb SSHD&lt;br /&gt;
: 1 Tb HD&lt;br /&gt;
: 650 W power supply&lt;br /&gt;
: AMD Radeon HD 7700 with 2 Gb RAM&lt;br /&gt;
&lt;br /&gt;
Report Generated at: 1/8/2013 1:02:45 AM&lt;br /&gt;
&lt;br /&gt;
OK, so the machine is sneaking up on its third year in service.  It still gets a decent rating from me and Windows:&lt;br /&gt;
&lt;br /&gt;
[[File:Homebrew 5 performance.jpg]]&lt;br /&gt;
&lt;br /&gt;
And, as with everything else except for Wikimedia version and the WAMPserver versions, I haven&#039;t changed anything from last week, when all was well in wikiland.&lt;br /&gt;
&lt;br /&gt;
=== OS ===&lt;br /&gt;
&lt;br /&gt;
: Windows 7 Professional, 64-bit&lt;br /&gt;
: Service Pack 1&lt;br /&gt;
&lt;br /&gt;
=== Browser ===&lt;br /&gt;
&lt;br /&gt;
: Chrome 46.0.2490.86 m&lt;br /&gt;
&lt;br /&gt;
=== Software Guardians ===&lt;br /&gt;
&lt;br /&gt;
: Malware Bytes&lt;br /&gt;
::: Set to exclude 127.0.0.1, httpd.exe, and mysql.exe from inspection.&lt;br /&gt;
&lt;br /&gt;
: CylanceProtect&lt;br /&gt;
::: I&#039;ve got no control over this.  All I can say is that with MediaWiki 1.20, I had no connection problems.&lt;br /&gt;
&lt;br /&gt;
: Firewall&lt;br /&gt;
::: Made sure port 3306 is open.&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #1 ==&lt;br /&gt;
&lt;br /&gt;
Because the connection ALWAYS worked on the very next try after a failure, I thought that perhaps I could arrange a sacrificial connection to feed the ravenous Connection Monster; while it was chomping on the carcass, the real Mediawiki connection might sneak by unnoticed.&lt;br /&gt;
&lt;br /&gt;
So I put this in my LocalSettings.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$servername = &amp;quot;127.0.0.1&amp;quot;;&lt;br /&gt;
$username = &amp;quot;dbuser&amp;quot;;&lt;br /&gt;
$password = &amp;quot;dbuserpassword&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Create connection&lt;br /&gt;
$conn = new mysqli($servername, $username, $password);&lt;br /&gt;
&lt;br /&gt;
// Check connection&lt;br /&gt;
if ($conn-&amp;gt;connect_error) {&lt;br /&gt;
    die(&amp;quot;Connection failed: &amp;quot; . $conn-&amp;gt;connect_error);&lt;br /&gt;
} &lt;br /&gt;
#echo &amp;quot;Connected successfully&amp;quot;;&lt;br /&gt;
mysqli_close($conn);&lt;br /&gt;
#die(&amp;quot;test finished&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This idiotic connection hasn&#039;t ever failed yet.&lt;br /&gt;
&lt;br /&gt;
And the wiki page hasn&#039;t yet failed to connect afterward, either.&lt;br /&gt;
&lt;br /&gt;
Pasta faggiole!&lt;br /&gt;
&lt;br /&gt;
I hate it.&lt;br /&gt;
&lt;br /&gt;
But not as much as I hate seeing the &amp;quot;connection failed&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Not yet, anyway.&lt;br /&gt;
&lt;br /&gt;
Using the [http://php.net/manual/en/book.hrtime.php &#039;&#039;hrtime&#039;&#039; extension,] I can see that this little connection check only takes a couple of milliseconds, so it&#039;s not costing me huge time in loading pages.  &lt;br /&gt;
&lt;br /&gt;
But I hate it.&lt;br /&gt;
&lt;br /&gt;
== It&#039;s a feature, not a bug ==&lt;br /&gt;
&lt;br /&gt;
The MediaWiki wizards know &#039;that there is something awkward in &#039;&#039;&#039;LoadBalancer.php&#039;&#039;&#039;: [https://phabricator.wikimedia.org/T72223#1673869 &amp;quot;&#039;Unknown error&#039; in LoadBalancer-&amp;gt;reportConnectionError() hides a real database problem&amp;quot; (Sep 25 2015, 9:15 AM):]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Change 157488 abandoned by Hashar:&lt;br /&gt;
Do not hide real DB error on first connect&lt;br /&gt;
&lt;br /&gt;
Reason:&lt;br /&gt;
That would cause T31233 Broken failover for DB slave connection errors.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;The try/catch was done on purpose&#039;&#039;&#039;&#039;&#039;, see Tim comment on https://www.mediawiki.org/wiki/Special:Code/MediaWiki/90266#c20239 &lt;br /&gt;
&lt;br /&gt;
We have a task for a better fix T35036&lt;br /&gt;
&lt;br /&gt;
[https://gerrit.wikimedia.org/r/157488 Do not hide real DB error on first connect]&lt;br /&gt;
:: LoadBalancer should not silence database exception. Bug: 70223&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is not a problem on public linux production sites, such as this one (moleski.net) and another one that I run, even though they are, like localhost, single-server sites with no database slaves to worry about.&lt;br /&gt;
&lt;br /&gt;
There is &#039;&#039;something&#039;&#039; about the Windows environment that unsettles Mediawiki&#039;s database procedures ...&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #2 ==&lt;br /&gt;
&lt;br /&gt;
I&#039;ve commented out the &amp;quot;try ... catch&amp;quot; code and replaced with with the rejected simplification suggested by Saper.  I don&#039;t care that this simplification &amp;quot;would cause T31233 Broken failover for DB slave connection errors.&amp;quot; Not my circus, not my monkeys.  I&#039;m running this code on &#039;&#039;localhost.&#039;&#039;  There are no slave connections.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# MXM Cutting out &amp;quot;ugliest thing&amp;quot; and substituting another&#039;s guy&#039;s remedy&lt;br /&gt;
#		try {&lt;br /&gt;
#			$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
#		} catch ( DBConnectionError $e ) {&lt;br /&gt;
#			// FIXME: This is probably the ugliest thing I have ever done to&lt;br /&gt;
#			// PHP. I&#039;m half-expecting it to segfault, just out of disgust. -- TS&lt;br /&gt;
#			$db = $e-&amp;gt;db;&lt;br /&gt;
#                       die(&#039;MXM: yep, came through here.&#039;)&lt;br /&gt;
#		}&lt;br /&gt;
# MXM&lt;br /&gt;
$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
# MXM&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What difference does this difference make?  $db is not assigned to $e-&amp;gt;db if the connection fails.  I put some feedback in the &amp;quot;catch&amp;quot; block, to see if for some reason my system is taking that route.  After I rebooted, I got the confirmation that the program execution flowed through that branch.&lt;br /&gt;
&lt;br /&gt;
But making this change did not make all things well again.  On a cold boot the next day, all of my &amp;quot;technical difficulties&amp;quot; came crashing back.  By itself, Ugly Workaround #2 does not scratch the itch.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;What I don&#039;t know is why there is any problem on startup at all&#039;&#039;&#039;&#039;&#039;.  What is the difference between this setup and the one that hummed along for almost three years without any difficulty?  I can&#039;t disable Cylance to find out.  It is imposed on me from above.  In theory, I have configured Malware Bytes to ignore things served from localhost.  &lt;br /&gt;
&lt;br /&gt;
== Just the facts, Ma&#039;am. ==&lt;br /&gt;
&lt;br /&gt;
:: - My setup is slow on startup after a reboot.&lt;br /&gt;
:: - Mediawiki is not willing to wait for localhost to wake up.&lt;br /&gt;
:: - Ugly Workaround #1 does work around the problem, probably because it has no Mediawiki timer running but just sits there stupidly for hundreds of thousands of nanoseconds while something in the background preoccupies my system.  If I can find the timing loop for the connection, I can maybe develop a more elegant workaround.&lt;br /&gt;
&lt;br /&gt;
== Tweak MySQL ==&lt;br /&gt;
&lt;br /&gt;
; [https://bugs.mysql.com/bug.php?id=28805 &amp;quot;MySQL Service takes a very long time to start up.&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
: I&#039;ve set httpd and mysqld to run with administrator privileges after reading this article, FWIW.&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.mail-archive.com/mediawiki-commits@lists.wikimedia.org/msg283522.html &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;MediaWiki-commits&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;Gerrit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; Add support for connect_timeout -	change (mediawiki...PoolCounter).]&lt;br /&gt;
:: The intriguing line: &#039;&#039;we implement here what we already do for mysql connections: if we set a connection timeout to a very small value (in the order of magnitude of twice the RTT to the poolcounter server) and retry twice, we can have very fast failures in case one server goes down, and the failover to the other active servers would happen almost harmlessly.&#039;&#039;  &lt;br /&gt;
:: I&#039;m convinced this is a clue, but I haven&#039;t waded into the code to see what I might be able to play with.  &lt;br /&gt;
* [http://serverfault.com/questions/408550/connecting-to-mysql-from-php-is-extremely-slow &amp;quot;Connecting to MySQL from PHP is extremely slow.&amp;quot;]&lt;br /&gt;
:: David Random&#039;s essay on this page is superb.  It didn&#039;t fix what ailed me, but it made me feel that I was understanding the problem better.&lt;br /&gt;
* [https://ineed.coffee/1441/apache-php-mysql-slow-under-windows-8-how-to-fix/ &amp;quot;Apache, PHP, MySQL slow under Windows 8. How to fix.&amp;quot;]&lt;br /&gt;
* [http://stackoverflow.com/questions/8432601/wamp-xampp-is-responding-very-slow-over-localhost/17163207#17163207 &amp;quot;WAMP/XAMPP is responding very slow over localhost.&amp;quot;]&lt;br /&gt;
:: Contains an excellent set of links to various tips and tricks, as well as making some fresh suggestions.&lt;br /&gt;
* [http://127.0.0.1/mediawiki/api.php?action=query&amp;amp;meta=siteinfo&amp;amp;siprop=statistics&amp;amp;format=jsonfm Count jobs on my localhost.]  This won&#039;t do you any good or me any harm, if I&#039;m lucky.  This is a handy spot for me to drop this link to see whether jobs have accumulated on my local wiki.  They haven&#039;t.&lt;br /&gt;
[[Category:Computers]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16406</id>
		<title>WAMP, localhost, Mediawiki: Cannot access the database</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16406"/>
		<updated>2015-12-03T18:44:17Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;or &#039;&#039;&#039;&#039;&#039;The Bug that Ate a Week of My Life!&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mediawiki on localhost ==&lt;br /&gt;
&lt;br /&gt;
Since 2:42 PM on 14 March 2009, I have run a private wiki for myself on a WAMP stack--6.5 years and counting.&lt;br /&gt;
&lt;br /&gt;
I have migrated the wiki from one desktop to another and installed it on two different laptops.&lt;br /&gt;
&lt;br /&gt;
I have never had everything work perfectly right out of the box, but I have never been frustrated for too long.  People have solved all of the basic problems more than once, and it has been just a matter of googling around long enough to debug the setup.&lt;br /&gt;
&lt;br /&gt;
All that has changed.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve found a bug that has defeated me.&lt;br /&gt;
&lt;br /&gt;
== Mediawiki 1.26, WAMPserver 2.5, and WAMPserver 3 ==&lt;br /&gt;
&lt;br /&gt;
== Error Messages ==&lt;br /&gt;
&lt;br /&gt;
=== Shorter version ===&lt;br /&gt;
&lt;br /&gt;
Sorry! This site is experiencing technical difficulties.&lt;br /&gt;
&lt;br /&gt;
Try waiting a few minutes and reloading.&lt;br /&gt;
&lt;br /&gt;
(Cannot access the database)&lt;br /&gt;
&lt;br /&gt;
=== With debugging and backtracking enabled ===&lt;br /&gt;
&lt;br /&gt;
Cannot access the database: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ())&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Backtrace:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
:  #0 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(842): &#039;&#039;&#039;DatabaseBase&#039;&#039;&#039;-&amp;gt;reportConnectionError(&#039;Unknown error (...&#039;)&lt;br /&gt;
:  #1 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(537): &#039;&#039;&#039;LoadBalancer&#039;&#039;&#039;-&amp;gt;reportConnectionError()&lt;br /&gt;
:  #2 C:\wamp\www\mediawiki\includes\GlobalFunctions.php(3631): LoadBalancer-&amp;gt;getConnection(-1, Array, false)&lt;br /&gt;
:  #3 C:\wamp\www\mediawiki\includes\User.php(1208): wfGetDB(-1)&lt;br /&gt;
:  #4 C:\wamp\www\mediawiki\includes\User.php(397): User-&amp;gt;loadFromDatabase(0)&lt;br /&gt;
:  #5 C:\wamp\www\mediawiki\includes\User.php(362): User-&amp;gt;loadFromId(0)&lt;br /&gt;
:  #6 C:\wamp\www\mediawiki\includes\User.php(2459): User-&amp;gt;load()&lt;br /&gt;
:  #7 C:\wamp\www\mediawiki\includes\User.php(1167): User-&amp;gt;getToken(false)&lt;br /&gt;
:  #8 C:\wamp\www\mediawiki\includes\User.php(365): User-&amp;gt;loadFromSession()&lt;br /&gt;
:  #9 C:\wamp\www\mediawiki\includes\User.php(2029): User-&amp;gt;load()&lt;br /&gt;
:  #10 C:\wamp\www\mediawiki\includes\User.php(3204): User-&amp;gt;getId()&lt;br /&gt;
:  #11 C:\wamp\www\mediawiki\includes\MediaWiki.php(627): User-&amp;gt;isLoggedIn()&lt;br /&gt;
:  #12 C:\wamp\www\mediawiki\includes\MediaWiki.php(476): MediaWiki-&amp;gt;main()&lt;br /&gt;
:  #13 C:\wamp\www\mediawiki\index.php(51): MediaWiki-&amp;gt;run()&lt;br /&gt;
:  #14 {main}&lt;br /&gt;
&lt;br /&gt;
:  reportConnectionError &amp;quot;Unknown error&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Failure message when MySQL is totally disabled ===&lt;br /&gt;
&lt;br /&gt;
Warning: mysqli::mysqli(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp\www\mediawiki\LocalSettings.php on line 152&lt;br /&gt;
&lt;br /&gt;
Connection failed: No connection could be made because the target machine actively refused it.&lt;br /&gt;
&lt;br /&gt;
== Not a code or configuration problem ==&lt;br /&gt;
&lt;br /&gt;
Except for a few times when I shot myself in the foot while debugging, the proof that the PHP code base and my configuration are correct is that I can immediately obtain the page I want by reloading the page.  &lt;br /&gt;
&lt;br /&gt;
It is only on the first call after a long time (five minutes? ten?) of not accessing the wiki that the problem occurs.&lt;br /&gt;
&lt;br /&gt;
== Timing is everything ==&lt;br /&gt;
&lt;br /&gt;
The most common time for the bug to bite is when I open my browser.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve got two tabs to pages on the local wiki in my collection of home pages.&lt;br /&gt;
&lt;br /&gt;
The first one usually fails if I&#039;ve had the browser closed for a while; the second never does.&lt;br /&gt;
&lt;br /&gt;
I dropped the second page from the set to see if that would help the first. &lt;br /&gt;
&lt;br /&gt;
It didn&#039;t.&lt;br /&gt;
&lt;br /&gt;
Once MySQL is awakened from its slumbers, all the links in the wiki work reasonably well--no worse than ever before--unless I spend a long time composing a page, and then the connection fails when I try to save the page.  Refresh the page, and it saves perfectly.&lt;br /&gt;
&lt;br /&gt;
Something somewhere keeps MySQL from answering the FIRST request for a connection in the time frame that Mediawiki expects.  After that, everything is normal enough until MySQL decides to fall asleep again.&lt;br /&gt;
&lt;br /&gt;
== Round up the usual suspects ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s some interaction between Windows, Apache, MySQL, and the Wikimedia routines that has got me down.&lt;br /&gt;
&lt;br /&gt;
Why can&#039;t we all just get along?&lt;br /&gt;
&lt;br /&gt;
The articles in the [[#Links|links below]] have got excellent information and links in them.  They cover pretty much everything I&#039;ve tried, and then some.  I&#039;m just going to list the failed fixes that float into mind:&lt;br /&gt;
&lt;br /&gt;
* turn off IPv6 on my machine&lt;br /&gt;
* have Apache listen only to 127.0.0.1:80&lt;br /&gt;
* bind MySQL to 127.0.0.1 &lt;br /&gt;
* turn off name resolution in MySQL&lt;br /&gt;
* change localhost to 127.0.0.1 everywhere I can to avoid DNS calls&lt;br /&gt;
* edit Hosts file to make sure localhost is defined&lt;br /&gt;
* enable opcache and install APCu&lt;br /&gt;
* turn off Zend debugger&lt;br /&gt;
* moved from WAMPserver 2.5 to 3&lt;br /&gt;
&lt;br /&gt;
Total failure, but intriguing: get MySQL to use a socket.  There are paths for it in the configuration files, but I&#039;ve never gotten it going.  I must do more googling!  It seems as though it SHOULD work.&lt;br /&gt;
&lt;br /&gt;
== Sysinfo ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
: BIOS Manufacturer: American Megatrends Inc.&lt;br /&gt;
: Release Date: 10/23/2012&lt;br /&gt;
: BIOS Version: ALASKA - 1072009&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: Board Product ID: Gigabyte 990FXA-UD3&lt;br /&gt;
&lt;br /&gt;
: AMD FX-8350 Eight-Core Processor, 4 Ghz&lt;br /&gt;
: 16 GB RAM&lt;br /&gt;
: 480 Gb SSHD&lt;br /&gt;
: 1 Tb HD&lt;br /&gt;
: 650 W power supply&lt;br /&gt;
: AMD Radeon HD 7700 with 2 Gb RAM&lt;br /&gt;
&lt;br /&gt;
Report Generated at: 1/8/2013 1:02:45 AM&lt;br /&gt;
&lt;br /&gt;
OK, so the machine is sneaking up on its third year in service.  It still gets a decent rating from me and Windows:&lt;br /&gt;
&lt;br /&gt;
[[File:Homebrew 5 performance.jpg]]&lt;br /&gt;
&lt;br /&gt;
And, as with everything else except for Wikimedia version and the WAMPserver versions, I haven&#039;t changed anything from last week, when all was well in wikiland.&lt;br /&gt;
&lt;br /&gt;
=== OS ===&lt;br /&gt;
&lt;br /&gt;
: Windows 7 Professional, 64-bit&lt;br /&gt;
: Service Pack 1&lt;br /&gt;
&lt;br /&gt;
=== Browser ===&lt;br /&gt;
&lt;br /&gt;
: Chrome 46.0.2490.86 m&lt;br /&gt;
&lt;br /&gt;
=== Software Guardians ===&lt;br /&gt;
&lt;br /&gt;
: Malware Bytes&lt;br /&gt;
::: Set to exclude 127.0.0.1, httpd.exe, and mysql.exe from inspection.&lt;br /&gt;
&lt;br /&gt;
: CylanceProtect&lt;br /&gt;
::: I&#039;ve got no control over this.  All I can say is that with MediaWiki 1.20, I had no connection problems.&lt;br /&gt;
&lt;br /&gt;
: Firewall&lt;br /&gt;
::: Made sure port 3306 is open.&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #1 ==&lt;br /&gt;
&lt;br /&gt;
Because the connection ALWAYS worked on the very next try after a failure, I thought that perhaps I could arrange a sacrificial connection to feed the ravenous Connection Monster; while it was chomping on the carcass, the real Mediawiki connection might sneak by unnoticed.&lt;br /&gt;
&lt;br /&gt;
So I put this in my LocalSettings.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$servername = &amp;quot;127.0.0.1&amp;quot;;&lt;br /&gt;
$username = &amp;quot;dbuser&amp;quot;;&lt;br /&gt;
$password = &amp;quot;dbuserpassword&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Create connection&lt;br /&gt;
$conn = new mysqli($servername, $username, $password);&lt;br /&gt;
&lt;br /&gt;
// Check connection&lt;br /&gt;
if ($conn-&amp;gt;connect_error) {&lt;br /&gt;
    die(&amp;quot;Connection failed: &amp;quot; . $conn-&amp;gt;connect_error);&lt;br /&gt;
} &lt;br /&gt;
#echo &amp;quot;Connected successfully&amp;quot;;&lt;br /&gt;
mysqli_close($conn);&lt;br /&gt;
#die(&amp;quot;test finished&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This idiotic connection hasn&#039;t ever failed yet.&lt;br /&gt;
&lt;br /&gt;
And the wiki page hasn&#039;t yet failed to connect afterward, either.&lt;br /&gt;
&lt;br /&gt;
Pasta faggiole!&lt;br /&gt;
&lt;br /&gt;
I hate it.&lt;br /&gt;
&lt;br /&gt;
But not as much as I hate seeing the &amp;quot;connection failed&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Not yet, anyway.&lt;br /&gt;
&lt;br /&gt;
Using the [http://php.net/manual/en/book.hrtime.php &#039;&#039;hrtime&#039;&#039; extension,] I can see that this little connection check only takes a couple of milliseconds, so it&#039;s not costing me huge time in loading pages.  &lt;br /&gt;
&lt;br /&gt;
But I hate it.&lt;br /&gt;
&lt;br /&gt;
== It&#039;s a feature, not a bug ==&lt;br /&gt;
&lt;br /&gt;
The MediaWiki wizards know &#039;that there is something awkward in &#039;&#039;&#039;LoadBalancer.php&#039;&#039;&#039;: [https://phabricator.wikimedia.org/T72223#1673869 &amp;quot;&#039;Unknown error&#039; in LoadBalancer-&amp;gt;reportConnectionError() hides a real database problem&amp;quot; (Sep 25 2015, 9:15 AM):]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Change 157488 abandoned by Hashar:&lt;br /&gt;
Do not hide real DB error on first connect&lt;br /&gt;
&lt;br /&gt;
Reason:&lt;br /&gt;
That would cause T31233 Broken failover for DB slave connection errors.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;The try/catch was done on purpose&#039;&#039;&#039;&#039;&#039;, see Tim comment on https://www.mediawiki.org/wiki/Special:Code/MediaWiki/90266#c20239 &lt;br /&gt;
&lt;br /&gt;
We have a task for a better fix T35036&lt;br /&gt;
&lt;br /&gt;
[https://gerrit.wikimedia.org/r/157488 Do not hide real DB error on first connect]&lt;br /&gt;
:: LoadBalancer should not silence database exception. Bug: 70223&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is not a problem on public linux production sites, such as this one (moleski.net) and another one that I run, even though they are, like localhost, single-server sites with no database slaves to worry about.&lt;br /&gt;
&lt;br /&gt;
There is &#039;&#039;something&#039;&#039; about the Windows environment that unsettles Mediawiki&#039;s database procedures ...&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #2 ==&lt;br /&gt;
&lt;br /&gt;
I&#039;ve commented out the &amp;quot;try ... catch&amp;quot; code and replaced with with the rejected simplification suggested by Saper.  I don&#039;t care that this simplification &amp;quot;would cause T31233 Broken failover for DB slave connection errors.&amp;quot; Not my circus, not my monkeys.  I&#039;m running this code on &#039;&#039;localhost.&#039;&#039;  There are no slave connections.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# MXM Cutting out &amp;quot;ugliest thing&amp;quot; and substituting another&#039;s guy&#039;s remedy&lt;br /&gt;
#		try {&lt;br /&gt;
#			$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
#		} catch ( DBConnectionError $e ) {&lt;br /&gt;
#			// FIXME: This is probably the ugliest thing I have ever done to&lt;br /&gt;
#			// PHP. I&#039;m half-expecting it to segfault, just out of disgust. -- TS&lt;br /&gt;
#			$db = $e-&amp;gt;db;&lt;br /&gt;
#                       die(&#039;MXM: yep, came through here.&#039;)&lt;br /&gt;
#		}&lt;br /&gt;
# MXM&lt;br /&gt;
$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
# MXM&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What difference does this difference make?  $db is not assigned to $e-&amp;gt;db if the connection fails.  I put some feedback in the &amp;quot;catch&amp;quot; block, to see if for some reason my system is taking that route.  After I rebooted, I got the confirmation that the program execution flowed through that branch.&lt;br /&gt;
&lt;br /&gt;
But making this change did not make all things well again.  On a cold boot the next day, all of my &amp;quot;technical difficulties&amp;quot; came crashing back.  By itself, Ugly Workaround #2 does not scratch the itch.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;What I don&#039;t know is why there is any problem on startup at all&#039;&#039;&#039;&#039;&#039;.  What is the difference between this setup and the one that hummed along for almost three years without any difficulty?  I can&#039;t disable Cylance to find out.  It is imposed on me from above.  In theory, I have configured Malware Bytes to ignore things served from localhost.  &lt;br /&gt;
&lt;br /&gt;
== Just the facts, Ma&#039;am. ==&lt;br /&gt;
&lt;br /&gt;
:: - My setup is slow on startup after a reboot.&lt;br /&gt;
:: - Mediawiki is not willing to wait for localhost to wake up.&lt;br /&gt;
:: - Ugly Workaround #1 does work around the problem, probably because it has no Mediawiki timer running but just sits there stupidly for hundreds of thousands of nanoseconds while something in the background preoccupies my system.  If I can find the timing loop for the connection, I can maybe develop a more elegant workaround.&lt;br /&gt;
&lt;br /&gt;
== Tweak MySQL ==&lt;br /&gt;
&lt;br /&gt;
; [https://bugs.mysql.com/bug.php?id=28805 &amp;quot;MySQL Service takes a very long time to start up.&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
: I&#039;ve set httpd and mysqld to run with administrator privileges after reading this article, FWIW.&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.mail-archive.com/mediawiki-commits@lists.wikimedia.org/msg283522.html &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;MediaWiki-commits&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;Gerrit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; Add support for connect_timeout -	change (mediawiki...PoolCounter)]&lt;br /&gt;
:: The intriguing line: &#039;&#039;we implement here what we already do for mysql connections: if we set a connection timeout to a very small value (in the order of magnitude of twice the RTT to the poolcounter server) and retry twice, we can have very fast failures in case one server goes down, and the failover to the other active servers would happen almost harmlessly.&#039;&#039;  &lt;br /&gt;
:: I&#039;m convinced this is a clue, but I haven&#039;t waded into the code to see what I might be able to play with.  &lt;br /&gt;
* [http://serverfault.com/questions/408550/connecting-to-mysql-from-php-is-extremely-slow &amp;quot;Connecting to MySQL from PHP is extremely slow&amp;quot;]&lt;br /&gt;
:: David Random&#039;s essay on this page is superb.  It didn&#039;t fix what ailed me, but it made me feel that I was understanding the problem better.&lt;br /&gt;
* [https://ineed.coffee/1441/apache-php-mysql-slow-under-windows-8-how-to-fix/ &amp;quot;Apache, PHP, MySQL slow under Windows 8. How to fix.&amp;quot;]&lt;br /&gt;
* [http://stackoverflow.com/questions/8432601/wamp-xampp-is-responding-very-slow-over-localhost/17163207#17163207 &amp;quot;WAMP/XAMPP is responding very slow over localhost&amp;quot;]&lt;br /&gt;
:: Contains an excellent set of links to various tips and tricks, as well as making some fresh suggestions.&lt;br /&gt;
* [http://127.0.0.1/mediawiki/api.php?action=query&amp;amp;meta=siteinfo&amp;amp;siprop=statistics&amp;amp;format=jsonfm Count jobs on my localhost.]  This won&#039;t do you any good or me any harm, if I&#039;m lucky.  This is a handy spot for me to drop this link to see whether jobs have accumulated on my local wiki.  They haven&#039;t.&lt;br /&gt;
[[Category:Computers]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16405</id>
		<title>WAMP, localhost, Mediawiki: Cannot access the database</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16405"/>
		<updated>2015-12-03T12:48:20Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* Just the facts, Ma&amp;#039;am. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;or &#039;&#039;&#039;&#039;&#039;The Bug that Ate a Week of My Life!&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mediawiki on localhost ==&lt;br /&gt;
&lt;br /&gt;
Since 2:42 PM on 14 March 2009, I have run a private wiki for myself on a WAMP stack--6.5 years and counting.&lt;br /&gt;
&lt;br /&gt;
I have migrated the wiki from one desktop to another and installed it on two different laptops.&lt;br /&gt;
&lt;br /&gt;
I have never had everything work perfectly right out of the box, but I have never been frustrated for too long.  People have solved all of the basic problems more than once, and it has been just a matter of googling around long enough to debug the setup.&lt;br /&gt;
&lt;br /&gt;
All that has changed.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve found a bug that has defeated me.&lt;br /&gt;
&lt;br /&gt;
== Mediawiki 1.26, WAMPserver 2.5, and WAMPserver 3 ==&lt;br /&gt;
&lt;br /&gt;
== Error Messages ==&lt;br /&gt;
&lt;br /&gt;
=== Shorter version ===&lt;br /&gt;
&lt;br /&gt;
Sorry! This site is experiencing technical difficulties.&lt;br /&gt;
&lt;br /&gt;
Try waiting a few minutes and reloading.&lt;br /&gt;
&lt;br /&gt;
(Cannot access the database)&lt;br /&gt;
&lt;br /&gt;
=== With debugging and backtracking enabled ===&lt;br /&gt;
&lt;br /&gt;
Cannot access the database: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ())&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Backtrace:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
:  #0 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(842): &#039;&#039;&#039;DatabaseBase&#039;&#039;&#039;-&amp;gt;reportConnectionError(&#039;Unknown error (...&#039;)&lt;br /&gt;
:  #1 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(537): &#039;&#039;&#039;LoadBalancer&#039;&#039;&#039;-&amp;gt;reportConnectionError()&lt;br /&gt;
:  #2 C:\wamp\www\mediawiki\includes\GlobalFunctions.php(3631): LoadBalancer-&amp;gt;getConnection(-1, Array, false)&lt;br /&gt;
:  #3 C:\wamp\www\mediawiki\includes\User.php(1208): wfGetDB(-1)&lt;br /&gt;
:  #4 C:\wamp\www\mediawiki\includes\User.php(397): User-&amp;gt;loadFromDatabase(0)&lt;br /&gt;
:  #5 C:\wamp\www\mediawiki\includes\User.php(362): User-&amp;gt;loadFromId(0)&lt;br /&gt;
:  #6 C:\wamp\www\mediawiki\includes\User.php(2459): User-&amp;gt;load()&lt;br /&gt;
:  #7 C:\wamp\www\mediawiki\includes\User.php(1167): User-&amp;gt;getToken(false)&lt;br /&gt;
:  #8 C:\wamp\www\mediawiki\includes\User.php(365): User-&amp;gt;loadFromSession()&lt;br /&gt;
:  #9 C:\wamp\www\mediawiki\includes\User.php(2029): User-&amp;gt;load()&lt;br /&gt;
:  #10 C:\wamp\www\mediawiki\includes\User.php(3204): User-&amp;gt;getId()&lt;br /&gt;
:  #11 C:\wamp\www\mediawiki\includes\MediaWiki.php(627): User-&amp;gt;isLoggedIn()&lt;br /&gt;
:  #12 C:\wamp\www\mediawiki\includes\MediaWiki.php(476): MediaWiki-&amp;gt;main()&lt;br /&gt;
:  #13 C:\wamp\www\mediawiki\index.php(51): MediaWiki-&amp;gt;run()&lt;br /&gt;
:  #14 {main}&lt;br /&gt;
&lt;br /&gt;
:  reportConnectionError &amp;quot;Unknown error&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Failure message when MySQL is totally disabled ===&lt;br /&gt;
&lt;br /&gt;
Warning: mysqli::mysqli(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp\www\mediawiki\LocalSettings.php on line 152&lt;br /&gt;
&lt;br /&gt;
Connection failed: No connection could be made because the target machine actively refused it.&lt;br /&gt;
&lt;br /&gt;
== Not a code or configuration problem ==&lt;br /&gt;
&lt;br /&gt;
Except for a few times when I shot myself in the foot while debugging, the proof that the PHP code base and my configuration are correct is that I can immediately obtain the page I want by reloading the page.  &lt;br /&gt;
&lt;br /&gt;
It is only on the first call after a long time (five minutes? ten?) of not accessing the wiki that the problem occurs.&lt;br /&gt;
&lt;br /&gt;
== Timing is everything ==&lt;br /&gt;
&lt;br /&gt;
The most common time for the bug to bite is when I open my browser.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve got two tabs to pages on the local wiki in my collection of home pages.&lt;br /&gt;
&lt;br /&gt;
The first one usually fails if I&#039;ve had the browser closed for a while; the second never does.&lt;br /&gt;
&lt;br /&gt;
I dropped the second page from the set to see if that would help the first. &lt;br /&gt;
&lt;br /&gt;
It didn&#039;t.&lt;br /&gt;
&lt;br /&gt;
Once MySQL is awakened from its slumbers, all the links in the wiki work reasonably well--no worse than ever before--unless I spend a long time composing a page, and then the connection fails when I try to save the page.  Refresh the page, and it saves perfectly.&lt;br /&gt;
&lt;br /&gt;
Something somewhere keeps MySQL from answering the FIRST request for a connection in the time frame that Mediawiki expects.  After that, everything is normal enough until MySQL decides to fall asleep again.&lt;br /&gt;
&lt;br /&gt;
== Round up the usual suspects ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s some interaction between Windows, Apache, MySQL, and the Wikimedia routines that has got me down.&lt;br /&gt;
&lt;br /&gt;
Why can&#039;t we all just get along?&lt;br /&gt;
&lt;br /&gt;
The articles in the [[#Links|links below]] have got excellent information and links in them.  They cover pretty much everything I&#039;ve tried, and then some.  I&#039;m just going to list the failed fixes that float into mind:&lt;br /&gt;
&lt;br /&gt;
* turn off IPv6 on my machine&lt;br /&gt;
* have Apache listen only to 127.0.0.1:80&lt;br /&gt;
* bind MySQL to 127.0.0.1 &lt;br /&gt;
* turn off name resolution in MySQL&lt;br /&gt;
* change localhost to 127.0.0.1 everywhere I can to avoid DNS calls&lt;br /&gt;
* edit Hosts file to make sure localhost is defined&lt;br /&gt;
* enable opcache and install APCu&lt;br /&gt;
* turn off Zend debugger&lt;br /&gt;
* moved from WAMPserver 2.5 to 3&lt;br /&gt;
&lt;br /&gt;
Total failure, but intriguing: get MySQL to use a socket.  There are paths for it in the configuration files, but I&#039;ve never gotten it going.  I must do more googling!  It seems as though it SHOULD work.&lt;br /&gt;
&lt;br /&gt;
== Sysinfo ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
: BIOS Manufacturer: American Megatrends Inc.&lt;br /&gt;
: Release Date: 10/23/2012&lt;br /&gt;
: BIOS Version: ALASKA - 1072009&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: Board Product ID: Gigabyte 990FXA-UD3&lt;br /&gt;
&lt;br /&gt;
: AMD FX-8350 Eight-Core Processor, 4 Ghz&lt;br /&gt;
: 16 GB RAM&lt;br /&gt;
: 480 Gb SSHD&lt;br /&gt;
: 1 Tb HD&lt;br /&gt;
: 650 W power supply&lt;br /&gt;
: AMD Radeon HD 7700 with 2 Gb RAM&lt;br /&gt;
&lt;br /&gt;
Report Generated at: 1/8/2013 1:02:45 AM&lt;br /&gt;
&lt;br /&gt;
OK, so the machine is sneaking up on its third year in service.  It still gets a decent rating from me and Windows:&lt;br /&gt;
&lt;br /&gt;
[[File:Homebrew 5 performance.jpg]]&lt;br /&gt;
&lt;br /&gt;
And, as with everything else except for Wikimedia version and the WAMPserver versions, I haven&#039;t changed anything from last week, when all was well in wikiland.&lt;br /&gt;
&lt;br /&gt;
=== OS ===&lt;br /&gt;
&lt;br /&gt;
: Windows 7 Professional, 64-bit&lt;br /&gt;
: Service Pack 1&lt;br /&gt;
&lt;br /&gt;
=== Browser ===&lt;br /&gt;
&lt;br /&gt;
: Chrome 46.0.2490.86 m&lt;br /&gt;
&lt;br /&gt;
=== Software Guardians ===&lt;br /&gt;
&lt;br /&gt;
: Malware Bytes&lt;br /&gt;
::: Set to exclude 127.0.0.1, httpd.exe, and mysql.exe from inspection.&lt;br /&gt;
&lt;br /&gt;
: CylanceProtect&lt;br /&gt;
::: I&#039;ve got no control over this.  All I can say is that with MediaWiki 1.20, I had no connection problems.&lt;br /&gt;
&lt;br /&gt;
: Firewall&lt;br /&gt;
::: Made sure port 3306 is open.&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #1 ==&lt;br /&gt;
&lt;br /&gt;
Because the connection ALWAYS worked on the very next try after a failure, I thought that perhaps I could arrange a sacrificial connection to feed the ravenous Connection Monster; while it was chomping on the carcass, the real Mediawiki connection might sneak by unnoticed.&lt;br /&gt;
&lt;br /&gt;
So I put this in my LocalSettings.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$servername = &amp;quot;127.0.0.1&amp;quot;;&lt;br /&gt;
$username = &amp;quot;dbuser&amp;quot;;&lt;br /&gt;
$password = &amp;quot;dbuserpassword&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Create connection&lt;br /&gt;
$conn = new mysqli($servername, $username, $password);&lt;br /&gt;
&lt;br /&gt;
// Check connection&lt;br /&gt;
if ($conn-&amp;gt;connect_error) {&lt;br /&gt;
    die(&amp;quot;Connection failed: &amp;quot; . $conn-&amp;gt;connect_error);&lt;br /&gt;
} &lt;br /&gt;
#echo &amp;quot;Connected successfully&amp;quot;;&lt;br /&gt;
mysqli_close($conn);&lt;br /&gt;
#die(&amp;quot;test finished&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This idiotic connection hasn&#039;t ever failed yet.&lt;br /&gt;
&lt;br /&gt;
And the wiki page hasn&#039;t yet failed to connect afterward, either.&lt;br /&gt;
&lt;br /&gt;
Pasta faggiole!&lt;br /&gt;
&lt;br /&gt;
I hate it.&lt;br /&gt;
&lt;br /&gt;
But not as much as I hate seeing the &amp;quot;connection failed&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Not yet, anyway.&lt;br /&gt;
&lt;br /&gt;
Using the [http://php.net/manual/en/book.hrtime.php &#039;&#039;hrtime&#039;&#039; extension,] I can see that this little connection check only takes a couple of milliseconds, so it&#039;s not costing me huge time in loading pages.  &lt;br /&gt;
&lt;br /&gt;
But I hate it.&lt;br /&gt;
&lt;br /&gt;
== It&#039;s a feature, not a bug ==&lt;br /&gt;
&lt;br /&gt;
The MediaWiki wizards know &#039;that there is something awkward in &#039;&#039;&#039;LoadBalancer.php&#039;&#039;&#039;: [https://phabricator.wikimedia.org/T72223#1673869 &amp;quot;&#039;Unknown error&#039; in LoadBalancer-&amp;gt;reportConnectionError() hides a real database problem&amp;quot; (Sep 25 2015, 9:15 AM):]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Change 157488 abandoned by Hashar:&lt;br /&gt;
Do not hide real DB error on first connect&lt;br /&gt;
&lt;br /&gt;
Reason:&lt;br /&gt;
That would cause T31233 Broken failover for DB slave connection errors.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;The try/catch was done on purpose&#039;&#039;&#039;&#039;&#039;, see Tim comment on https://www.mediawiki.org/wiki/Special:Code/MediaWiki/90266#c20239 &lt;br /&gt;
&lt;br /&gt;
We have a task for a better fix T35036&lt;br /&gt;
&lt;br /&gt;
[https://gerrit.wikimedia.org/r/157488 Do not hide real DB error on first connect]&lt;br /&gt;
:: LoadBalancer should not silence database exception. Bug: 70223&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is not a problem on public linux production sites, such as this one (moleski.net) and another one that I run, even though they are, like localhost, single-server sites with no database slaves to worry about.&lt;br /&gt;
&lt;br /&gt;
There is &#039;&#039;something&#039;&#039; about the Windows environment that unsettles Mediawiki&#039;s database procedures ...&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #2 ==&lt;br /&gt;
&lt;br /&gt;
I&#039;ve commented out the &amp;quot;try ... catch&amp;quot; code and replaced with with the rejected simplification suggested by Saper.  I don&#039;t care that this simplification &amp;quot;would cause T31233 Broken failover for DB slave connection errors.&amp;quot; Not my circus, not my monkeys.  I&#039;m running this code on &#039;&#039;localhost.&#039;&#039;  There are no slave connections.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# MXM Cutting out &amp;quot;ugliest thing&amp;quot; and substituting another&#039;s guy&#039;s remedy&lt;br /&gt;
#		try {&lt;br /&gt;
#			$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
#		} catch ( DBConnectionError $e ) {&lt;br /&gt;
#			// FIXME: This is probably the ugliest thing I have ever done to&lt;br /&gt;
#			// PHP. I&#039;m half-expecting it to segfault, just out of disgust. -- TS&lt;br /&gt;
#			$db = $e-&amp;gt;db;&lt;br /&gt;
#                       die(&#039;MXM: yep, came through here.&#039;)&lt;br /&gt;
#		}&lt;br /&gt;
# MXM&lt;br /&gt;
$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
# MXM&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What difference does this difference make?  $db is not assigned to $e-&amp;gt;db if the connection fails.  I put some feedback in the &amp;quot;catch&amp;quot; block, to see if for some reason my system is taking that route.  After I rebooted, I got the confirmation that the program execution flowed through that branch.&lt;br /&gt;
&lt;br /&gt;
But making this change did not make all things well again.  On a cold boot the next day, all of my &amp;quot;technical difficulties&amp;quot; came crashing back.  By itself, Ugly Workaround #2 does not scratch the itch.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;What I don&#039;t know is why there is any problem on startup at all&#039;&#039;&#039;&#039;&#039;.  What is the difference between this setup and the one that hummed along for almost three years without any difficulty?  I can&#039;t disable Cylance to find out.  It is imposed on me from above.  In theory, I have configured Malware Bytes to ignore things served from localhost.  &lt;br /&gt;
&lt;br /&gt;
== Just the facts, Ma&#039;am. ==&lt;br /&gt;
&lt;br /&gt;
:: - My setup is slow on startup after a reboot.&lt;br /&gt;
:: - Mediawiki is not willing to wait for localhost to wake up.&lt;br /&gt;
:: - Ugly Workaround #1 does work around the problem, probably because it has no Mediawiki timer running but just sits there stupidly for hundreds of thousands of nanoseconds while something in the background preoccupies my system.  If I can find the timing loop for the connection, I can maybe develop a more elegant workaround.&lt;br /&gt;
&lt;br /&gt;
== Tweak MySQL ==&lt;br /&gt;
&lt;br /&gt;
; [https://bugs.mysql.com/bug.php?id=28805 &amp;quot;MySQL Service takes a very long time to start up.&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
: I&#039;ve set httpd and mysqld to run with administrator privileges after reading this article, FWIW.&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.mail-archive.com/mediawiki-commits@lists.wikimedia.org/msg283522.html &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;MediaWiki-commits&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;Gerrit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; Add support for connect_timeout -	change (mediawiki...PoolCounter)]&lt;br /&gt;
:: The intriguing line: &#039;&#039;we implement here what we already do for mysql connections: if we set a connection timeout to a very small value (in the order of magnitude of twice the RTT to the poolcounter server) and retry twice, we can have very fast failures in case one server goes down, and the failover to the other active servers would happen almost harmlessly.&#039;&#039;  &lt;br /&gt;
:: I&#039;m convinced this is a clue, but I haven&#039;t waded into the code to see what I might be able to play with.  &lt;br /&gt;
* [http://serverfault.com/questions/408550/connecting-to-mysql-from-php-is-extremely-slow &amp;quot;Connecting to MySQL from PHP is extremely slow&amp;quot;]&lt;br /&gt;
:: David Random&#039;s essay on this page is superb.  It didn&#039;t fix what ailed me, but it made me feel that I was understanding the problem better.&lt;br /&gt;
* [https://ineed.coffee/1441/apache-php-mysql-slow-under-windows-8-how-to-fix/ &amp;quot;Apache, PHP, MySQL slow under Windows 8. How to fix.&amp;quot;]&lt;br /&gt;
:: Contains an excellent set of links to various tips and tricks, as well as making some fresh suggestions.&lt;br /&gt;
* [http://127.0.0.1/mediawiki/api.php?action=query&amp;amp;meta=siteinfo&amp;amp;siprop=statistics&amp;amp;format=jsonfm Count jobs on my localhost.]  This won&#039;t do you any good or me any harm, if I&#039;m lucky.  This is a handy spot for me to drop this link to see whether jobs have accumulated on my local wiki.  They haven&#039;t.&lt;br /&gt;
[[Category:Computers]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16404</id>
		<title>WAMP, localhost, Mediawiki: Cannot access the database</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16404"/>
		<updated>2015-12-03T12:37:03Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* Just the facts, Ma&amp;#039;am. */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;or &#039;&#039;&#039;&#039;&#039;The Bug that Ate a Week of My Life!&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mediawiki on localhost ==&lt;br /&gt;
&lt;br /&gt;
Since 2:42 PM on 14 March 2009, I have run a private wiki for myself on a WAMP stack--6.5 years and counting.&lt;br /&gt;
&lt;br /&gt;
I have migrated the wiki from one desktop to another and installed it on two different laptops.&lt;br /&gt;
&lt;br /&gt;
I have never had everything work perfectly right out of the box, but I have never been frustrated for too long.  People have solved all of the basic problems more than once, and it has been just a matter of googling around long enough to debug the setup.&lt;br /&gt;
&lt;br /&gt;
All that has changed.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve found a bug that has defeated me.&lt;br /&gt;
&lt;br /&gt;
== Mediawiki 1.26, WAMPserver 2.5, and WAMPserver 3 ==&lt;br /&gt;
&lt;br /&gt;
== Error Messages ==&lt;br /&gt;
&lt;br /&gt;
=== Shorter version ===&lt;br /&gt;
&lt;br /&gt;
Sorry! This site is experiencing technical difficulties.&lt;br /&gt;
&lt;br /&gt;
Try waiting a few minutes and reloading.&lt;br /&gt;
&lt;br /&gt;
(Cannot access the database)&lt;br /&gt;
&lt;br /&gt;
=== With debugging and backtracking enabled ===&lt;br /&gt;
&lt;br /&gt;
Cannot access the database: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ())&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Backtrace:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
:  #0 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(842): &#039;&#039;&#039;DatabaseBase&#039;&#039;&#039;-&amp;gt;reportConnectionError(&#039;Unknown error (...&#039;)&lt;br /&gt;
:  #1 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(537): &#039;&#039;&#039;LoadBalancer&#039;&#039;&#039;-&amp;gt;reportConnectionError()&lt;br /&gt;
:  #2 C:\wamp\www\mediawiki\includes\GlobalFunctions.php(3631): LoadBalancer-&amp;gt;getConnection(-1, Array, false)&lt;br /&gt;
:  #3 C:\wamp\www\mediawiki\includes\User.php(1208): wfGetDB(-1)&lt;br /&gt;
:  #4 C:\wamp\www\mediawiki\includes\User.php(397): User-&amp;gt;loadFromDatabase(0)&lt;br /&gt;
:  #5 C:\wamp\www\mediawiki\includes\User.php(362): User-&amp;gt;loadFromId(0)&lt;br /&gt;
:  #6 C:\wamp\www\mediawiki\includes\User.php(2459): User-&amp;gt;load()&lt;br /&gt;
:  #7 C:\wamp\www\mediawiki\includes\User.php(1167): User-&amp;gt;getToken(false)&lt;br /&gt;
:  #8 C:\wamp\www\mediawiki\includes\User.php(365): User-&amp;gt;loadFromSession()&lt;br /&gt;
:  #9 C:\wamp\www\mediawiki\includes\User.php(2029): User-&amp;gt;load()&lt;br /&gt;
:  #10 C:\wamp\www\mediawiki\includes\User.php(3204): User-&amp;gt;getId()&lt;br /&gt;
:  #11 C:\wamp\www\mediawiki\includes\MediaWiki.php(627): User-&amp;gt;isLoggedIn()&lt;br /&gt;
:  #12 C:\wamp\www\mediawiki\includes\MediaWiki.php(476): MediaWiki-&amp;gt;main()&lt;br /&gt;
:  #13 C:\wamp\www\mediawiki\index.php(51): MediaWiki-&amp;gt;run()&lt;br /&gt;
:  #14 {main}&lt;br /&gt;
&lt;br /&gt;
:  reportConnectionError &amp;quot;Unknown error&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Failure message when MySQL is totally disabled ===&lt;br /&gt;
&lt;br /&gt;
Warning: mysqli::mysqli(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp\www\mediawiki\LocalSettings.php on line 152&lt;br /&gt;
&lt;br /&gt;
Connection failed: No connection could be made because the target machine actively refused it.&lt;br /&gt;
&lt;br /&gt;
== Not a code or configuration problem ==&lt;br /&gt;
&lt;br /&gt;
Except for a few times when I shot myself in the foot while debugging, the proof that the PHP code base and my configuration are correct is that I can immediately obtain the page I want by reloading the page.  &lt;br /&gt;
&lt;br /&gt;
It is only on the first call after a long time (five minutes? ten?) of not accessing the wiki that the problem occurs.&lt;br /&gt;
&lt;br /&gt;
== Timing is everything ==&lt;br /&gt;
&lt;br /&gt;
The most common time for the bug to bite is when I open my browser.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve got two tabs to pages on the local wiki in my collection of home pages.&lt;br /&gt;
&lt;br /&gt;
The first one usually fails if I&#039;ve had the browser closed for a while; the second never does.&lt;br /&gt;
&lt;br /&gt;
I dropped the second page from the set to see if that would help the first. &lt;br /&gt;
&lt;br /&gt;
It didn&#039;t.&lt;br /&gt;
&lt;br /&gt;
Once MySQL is awakened from its slumbers, all the links in the wiki work reasonably well--no worse than ever before--unless I spend a long time composing a page, and then the connection fails when I try to save the page.  Refresh the page, and it saves perfectly.&lt;br /&gt;
&lt;br /&gt;
Something somewhere keeps MySQL from answering the FIRST request for a connection in the time frame that Mediawiki expects.  After that, everything is normal enough until MySQL decides to fall asleep again.&lt;br /&gt;
&lt;br /&gt;
== Round up the usual suspects ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s some interaction between Windows, Apache, MySQL, and the Wikimedia routines that has got me down.&lt;br /&gt;
&lt;br /&gt;
Why can&#039;t we all just get along?&lt;br /&gt;
&lt;br /&gt;
The articles in the [[#Links|links below]] have got excellent information and links in them.  They cover pretty much everything I&#039;ve tried, and then some.  I&#039;m just going to list the failed fixes that float into mind:&lt;br /&gt;
&lt;br /&gt;
* turn off IPv6 on my machine&lt;br /&gt;
* have Apache listen only to 127.0.0.1:80&lt;br /&gt;
* bind MySQL to 127.0.0.1 &lt;br /&gt;
* turn off name resolution in MySQL&lt;br /&gt;
* change localhost to 127.0.0.1 everywhere I can to avoid DNS calls&lt;br /&gt;
* edit Hosts file to make sure localhost is defined&lt;br /&gt;
* enable opcache and install APCu&lt;br /&gt;
* turn off Zend debugger&lt;br /&gt;
* moved from WAMPserver 2.5 to 3&lt;br /&gt;
&lt;br /&gt;
Total failure, but intriguing: get MySQL to use a socket.  There are paths for it in the configuration files, but I&#039;ve never gotten it going.  I must do more googling!  It seems as though it SHOULD work.&lt;br /&gt;
&lt;br /&gt;
== Sysinfo ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
: BIOS Manufacturer: American Megatrends Inc.&lt;br /&gt;
: Release Date: 10/23/2012&lt;br /&gt;
: BIOS Version: ALASKA - 1072009&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: Board Product ID: Gigabyte 990FXA-UD3&lt;br /&gt;
&lt;br /&gt;
: AMD FX-8350 Eight-Core Processor, 4 Ghz&lt;br /&gt;
: 16 GB RAM&lt;br /&gt;
: 480 Gb SSHD&lt;br /&gt;
: 1 Tb HD&lt;br /&gt;
: 650 W power supply&lt;br /&gt;
: AMD Radeon HD 7700 with 2 Gb RAM&lt;br /&gt;
&lt;br /&gt;
Report Generated at: 1/8/2013 1:02:45 AM&lt;br /&gt;
&lt;br /&gt;
OK, so the machine is sneaking up on its third year in service.  It still gets a decent rating from me and Windows:&lt;br /&gt;
&lt;br /&gt;
[[File:Homebrew 5 performance.jpg]]&lt;br /&gt;
&lt;br /&gt;
And, as with everything else except for Wikimedia version and the WAMPserver versions, I haven&#039;t changed anything from last week, when all was well in wikiland.&lt;br /&gt;
&lt;br /&gt;
=== OS ===&lt;br /&gt;
&lt;br /&gt;
: Windows 7 Professional, 64-bit&lt;br /&gt;
: Service Pack 1&lt;br /&gt;
&lt;br /&gt;
=== Browser ===&lt;br /&gt;
&lt;br /&gt;
: Chrome 46.0.2490.86 m&lt;br /&gt;
&lt;br /&gt;
=== Software Guardians ===&lt;br /&gt;
&lt;br /&gt;
: Malware Bytes&lt;br /&gt;
::: Set to exclude 127.0.0.1, httpd.exe, and mysql.exe from inspection.&lt;br /&gt;
&lt;br /&gt;
: CylanceProtect&lt;br /&gt;
::: I&#039;ve got no control over this.  All I can say is that with MediaWiki 1.20, I had no connection problems.&lt;br /&gt;
&lt;br /&gt;
: Firewall&lt;br /&gt;
::: Made sure port 3306 is open.&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #1 ==&lt;br /&gt;
&lt;br /&gt;
Because the connection ALWAYS worked on the very next try after a failure, I thought that perhaps I could arrange a sacrificial connection to feed the ravenous Connection Monster; while it was chomping on the carcass, the real Mediawiki connection might sneak by unnoticed.&lt;br /&gt;
&lt;br /&gt;
So I put this in my LocalSettings.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$servername = &amp;quot;127.0.0.1&amp;quot;;&lt;br /&gt;
$username = &amp;quot;dbuser&amp;quot;;&lt;br /&gt;
$password = &amp;quot;dbuserpassword&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Create connection&lt;br /&gt;
$conn = new mysqli($servername, $username, $password);&lt;br /&gt;
&lt;br /&gt;
// Check connection&lt;br /&gt;
if ($conn-&amp;gt;connect_error) {&lt;br /&gt;
    die(&amp;quot;Connection failed: &amp;quot; . $conn-&amp;gt;connect_error);&lt;br /&gt;
} &lt;br /&gt;
#echo &amp;quot;Connected successfully&amp;quot;;&lt;br /&gt;
mysqli_close($conn);&lt;br /&gt;
#die(&amp;quot;test finished&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This idiotic connection hasn&#039;t ever failed yet.&lt;br /&gt;
&lt;br /&gt;
And the wiki page hasn&#039;t yet failed to connect afterward, either.&lt;br /&gt;
&lt;br /&gt;
Pasta faggiole!&lt;br /&gt;
&lt;br /&gt;
I hate it.&lt;br /&gt;
&lt;br /&gt;
But not as much as I hate seeing the &amp;quot;connection failed&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Not yet, anyway.&lt;br /&gt;
&lt;br /&gt;
Using the [http://php.net/manual/en/book.hrtime.php &#039;&#039;hrtime&#039;&#039; extension,] I can see that this little connection check only takes a couple of milliseconds, so it&#039;s not costing me huge time in loading pages.  &lt;br /&gt;
&lt;br /&gt;
But I hate it.&lt;br /&gt;
&lt;br /&gt;
== It&#039;s a feature, not a bug ==&lt;br /&gt;
&lt;br /&gt;
The MediaWiki wizards know &#039;that there is something awkward in &#039;&#039;&#039;LoadBalancer.php&#039;&#039;&#039;: [https://phabricator.wikimedia.org/T72223#1673869 &amp;quot;&#039;Unknown error&#039; in LoadBalancer-&amp;gt;reportConnectionError() hides a real database problem&amp;quot; (Sep 25 2015, 9:15 AM):]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Change 157488 abandoned by Hashar:&lt;br /&gt;
Do not hide real DB error on first connect&lt;br /&gt;
&lt;br /&gt;
Reason:&lt;br /&gt;
That would cause T31233 Broken failover for DB slave connection errors.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;The try/catch was done on purpose&#039;&#039;&#039;&#039;&#039;, see Tim comment on https://www.mediawiki.org/wiki/Special:Code/MediaWiki/90266#c20239 &lt;br /&gt;
&lt;br /&gt;
We have a task for a better fix T35036&lt;br /&gt;
&lt;br /&gt;
[https://gerrit.wikimedia.org/r/157488 Do not hide real DB error on first connect]&lt;br /&gt;
:: LoadBalancer should not silence database exception. Bug: 70223&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is not a problem on public linux production sites, such as this one (moleski.net) and another one that I run, even though they are, like localhost, single-server sites with no database slaves to worry about.&lt;br /&gt;
&lt;br /&gt;
There is &#039;&#039;something&#039;&#039; about the Windows environment that unsettles Mediawiki&#039;s database procedures ...&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #2 ==&lt;br /&gt;
&lt;br /&gt;
I&#039;ve commented out the &amp;quot;try ... catch&amp;quot; code and replaced with with the rejected simplification suggested by Saper.  I don&#039;t care that this simplification &amp;quot;would cause T31233 Broken failover for DB slave connection errors.&amp;quot; Not my circus, not my monkeys.  I&#039;m running this code on &#039;&#039;localhost.&#039;&#039;  There are no slave connections.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# MXM Cutting out &amp;quot;ugliest thing&amp;quot; and substituting another&#039;s guy&#039;s remedy&lt;br /&gt;
#		try {&lt;br /&gt;
#			$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
#		} catch ( DBConnectionError $e ) {&lt;br /&gt;
#			// FIXME: This is probably the ugliest thing I have ever done to&lt;br /&gt;
#			// PHP. I&#039;m half-expecting it to segfault, just out of disgust. -- TS&lt;br /&gt;
#			$db = $e-&amp;gt;db;&lt;br /&gt;
#                       die(&#039;MXM: yep, came through here.&#039;)&lt;br /&gt;
#		}&lt;br /&gt;
# MXM&lt;br /&gt;
$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
# MXM&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What difference does this difference make?  $db is not assigned to $e-&amp;gt;db if the connection fails.  I put some feedback in the &amp;quot;catch&amp;quot; block, to see if for some reason my system is taking that route.  After I rebooted, I got the confirmation that the program execution flowed through that branch.&lt;br /&gt;
&lt;br /&gt;
But making this change did not make all things well again.  On a cold boot the next day, all of my &amp;quot;technical difficulties&amp;quot; came crashing back.  By itself, Ugly Workaround #2 does not scratch the itch.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;What I don&#039;t know is why there is any problem on startup at all&#039;&#039;&#039;&#039;&#039;.  What is the difference between this setup and the one that hummed along for almost three years without any difficulty?  I can&#039;t disable Cylance to find out.  It is imposed on me from above.  In theory, I have configured Malware Bytes to ignore things served from localhost.  &lt;br /&gt;
&lt;br /&gt;
== Just the facts, Ma&#039;am. ==&lt;br /&gt;
&lt;br /&gt;
:: - My setup is slow on startup after a reboot.&lt;br /&gt;
:: - Mediawiki is not willing to wait for localhost to wake up.&lt;br /&gt;
:: - Ugly Workaround #1 does work around the problem, probably because it has no Mediawiki timer running but just sits there stupidly for hundreds of thousands of nanoseconds while something in the background preoccupies my system.  If I can find the timing loop for the connection, I can maybe develop a more elegant workaround.&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.mail-archive.com/mediawiki-commits@lists.wikimedia.org/msg283522.html &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;MediaWiki-commits&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;Gerrit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; Add support for connect_timeout -	change (mediawiki...PoolCounter)]&lt;br /&gt;
:: The intriguing line: &#039;&#039;we implement here what we already do for mysql connections: if we set a connection timeout to a very small value (in the order of magnitude of twice the RTT to the poolcounter server) and retry twice, we can have very fast failures in case one server goes down, and the failover to the other active servers would happen almost harmlessly.&#039;&#039;  &lt;br /&gt;
:: I&#039;m convinced this is a clue, but I haven&#039;t waded into the code to see what I might be able to play with.  &lt;br /&gt;
* [http://serverfault.com/questions/408550/connecting-to-mysql-from-php-is-extremely-slow &amp;quot;Connecting to MySQL from PHP is extremely slow&amp;quot;]&lt;br /&gt;
:: David Random&#039;s essay on this page is superb.  It didn&#039;t fix what ailed me, but it made me feel that I was understanding the problem better.&lt;br /&gt;
* [https://ineed.coffee/1441/apache-php-mysql-slow-under-windows-8-how-to-fix/ &amp;quot;Apache, PHP, MySQL slow under Windows 8. How to fix.&amp;quot;]&lt;br /&gt;
:: Contains an excellent set of links to various tips and tricks, as well as making some fresh suggestions.&lt;br /&gt;
* [http://127.0.0.1/mediawiki/api.php?action=query&amp;amp;meta=siteinfo&amp;amp;siprop=statistics&amp;amp;format=jsonfm Count jobs on my localhost.]  This won&#039;t do you any good or me any harm, if I&#039;m lucky.  This is a handy spot for me to drop this link to see whether jobs have accumulated on my local wiki.  They haven&#039;t.&lt;br /&gt;
[[Category:Computers]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16403</id>
		<title>WAMP, localhost, Mediawiki: Cannot access the database</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16403"/>
		<updated>2015-12-03T12:33:46Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* Ugly Workaround #2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;or &#039;&#039;&#039;&#039;&#039;The Bug that Ate a Week of My Life!&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mediawiki on localhost ==&lt;br /&gt;
&lt;br /&gt;
Since 2:42 PM on 14 March 2009, I have run a private wiki for myself on a WAMP stack--6.5 years and counting.&lt;br /&gt;
&lt;br /&gt;
I have migrated the wiki from one desktop to another and installed it on two different laptops.&lt;br /&gt;
&lt;br /&gt;
I have never had everything work perfectly right out of the box, but I have never been frustrated for too long.  People have solved all of the basic problems more than once, and it has been just a matter of googling around long enough to debug the setup.&lt;br /&gt;
&lt;br /&gt;
All that has changed.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve found a bug that has defeated me.&lt;br /&gt;
&lt;br /&gt;
== Mediawiki 1.26, WAMPserver 2.5, and WAMPserver 3 ==&lt;br /&gt;
&lt;br /&gt;
== Error Messages ==&lt;br /&gt;
&lt;br /&gt;
=== Shorter version ===&lt;br /&gt;
&lt;br /&gt;
Sorry! This site is experiencing technical difficulties.&lt;br /&gt;
&lt;br /&gt;
Try waiting a few minutes and reloading.&lt;br /&gt;
&lt;br /&gt;
(Cannot access the database)&lt;br /&gt;
&lt;br /&gt;
=== With debugging and backtracking enabled ===&lt;br /&gt;
&lt;br /&gt;
Cannot access the database: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ())&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Backtrace:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
:  #0 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(842): &#039;&#039;&#039;DatabaseBase&#039;&#039;&#039;-&amp;gt;reportConnectionError(&#039;Unknown error (...&#039;)&lt;br /&gt;
:  #1 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(537): &#039;&#039;&#039;LoadBalancer&#039;&#039;&#039;-&amp;gt;reportConnectionError()&lt;br /&gt;
:  #2 C:\wamp\www\mediawiki\includes\GlobalFunctions.php(3631): LoadBalancer-&amp;gt;getConnection(-1, Array, false)&lt;br /&gt;
:  #3 C:\wamp\www\mediawiki\includes\User.php(1208): wfGetDB(-1)&lt;br /&gt;
:  #4 C:\wamp\www\mediawiki\includes\User.php(397): User-&amp;gt;loadFromDatabase(0)&lt;br /&gt;
:  #5 C:\wamp\www\mediawiki\includes\User.php(362): User-&amp;gt;loadFromId(0)&lt;br /&gt;
:  #6 C:\wamp\www\mediawiki\includes\User.php(2459): User-&amp;gt;load()&lt;br /&gt;
:  #7 C:\wamp\www\mediawiki\includes\User.php(1167): User-&amp;gt;getToken(false)&lt;br /&gt;
:  #8 C:\wamp\www\mediawiki\includes\User.php(365): User-&amp;gt;loadFromSession()&lt;br /&gt;
:  #9 C:\wamp\www\mediawiki\includes\User.php(2029): User-&amp;gt;load()&lt;br /&gt;
:  #10 C:\wamp\www\mediawiki\includes\User.php(3204): User-&amp;gt;getId()&lt;br /&gt;
:  #11 C:\wamp\www\mediawiki\includes\MediaWiki.php(627): User-&amp;gt;isLoggedIn()&lt;br /&gt;
:  #12 C:\wamp\www\mediawiki\includes\MediaWiki.php(476): MediaWiki-&amp;gt;main()&lt;br /&gt;
:  #13 C:\wamp\www\mediawiki\index.php(51): MediaWiki-&amp;gt;run()&lt;br /&gt;
:  #14 {main}&lt;br /&gt;
&lt;br /&gt;
:  reportConnectionError &amp;quot;Unknown error&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Failure message when MySQL is totally disabled ===&lt;br /&gt;
&lt;br /&gt;
Warning: mysqli::mysqli(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp\www\mediawiki\LocalSettings.php on line 152&lt;br /&gt;
&lt;br /&gt;
Connection failed: No connection could be made because the target machine actively refused it.&lt;br /&gt;
&lt;br /&gt;
== Not a code or configuration problem ==&lt;br /&gt;
&lt;br /&gt;
Except for a few times when I shot myself in the foot while debugging, the proof that the PHP code base and my configuration are correct is that I can immediately obtain the page I want by reloading the page.  &lt;br /&gt;
&lt;br /&gt;
It is only on the first call after a long time (five minutes? ten?) of not accessing the wiki that the problem occurs.&lt;br /&gt;
&lt;br /&gt;
== Timing is everything ==&lt;br /&gt;
&lt;br /&gt;
The most common time for the bug to bite is when I open my browser.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve got two tabs to pages on the local wiki in my collection of home pages.&lt;br /&gt;
&lt;br /&gt;
The first one usually fails if I&#039;ve had the browser closed for a while; the second never does.&lt;br /&gt;
&lt;br /&gt;
I dropped the second page from the set to see if that would help the first. &lt;br /&gt;
&lt;br /&gt;
It didn&#039;t.&lt;br /&gt;
&lt;br /&gt;
Once MySQL is awakened from its slumbers, all the links in the wiki work reasonably well--no worse than ever before--unless I spend a long time composing a page, and then the connection fails when I try to save the page.  Refresh the page, and it saves perfectly.&lt;br /&gt;
&lt;br /&gt;
Something somewhere keeps MySQL from answering the FIRST request for a connection in the time frame that Mediawiki expects.  After that, everything is normal enough until MySQL decides to fall asleep again.&lt;br /&gt;
&lt;br /&gt;
== Round up the usual suspects ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s some interaction between Windows, Apache, MySQL, and the Wikimedia routines that has got me down.&lt;br /&gt;
&lt;br /&gt;
Why can&#039;t we all just get along?&lt;br /&gt;
&lt;br /&gt;
The articles in the [[#Links|links below]] have got excellent information and links in them.  They cover pretty much everything I&#039;ve tried, and then some.  I&#039;m just going to list the failed fixes that float into mind:&lt;br /&gt;
&lt;br /&gt;
* turn off IPv6 on my machine&lt;br /&gt;
* have Apache listen only to 127.0.0.1:80&lt;br /&gt;
* bind MySQL to 127.0.0.1 &lt;br /&gt;
* turn off name resolution in MySQL&lt;br /&gt;
* change localhost to 127.0.0.1 everywhere I can to avoid DNS calls&lt;br /&gt;
* edit Hosts file to make sure localhost is defined&lt;br /&gt;
* enable opcache and install APCu&lt;br /&gt;
* turn off Zend debugger&lt;br /&gt;
* moved from WAMPserver 2.5 to 3&lt;br /&gt;
&lt;br /&gt;
Total failure, but intriguing: get MySQL to use a socket.  There are paths for it in the configuration files, but I&#039;ve never gotten it going.  I must do more googling!  It seems as though it SHOULD work.&lt;br /&gt;
&lt;br /&gt;
== Sysinfo ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
: BIOS Manufacturer: American Megatrends Inc.&lt;br /&gt;
: Release Date: 10/23/2012&lt;br /&gt;
: BIOS Version: ALASKA - 1072009&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: Board Product ID: Gigabyte 990FXA-UD3&lt;br /&gt;
&lt;br /&gt;
: AMD FX-8350 Eight-Core Processor, 4 Ghz&lt;br /&gt;
: 16 GB RAM&lt;br /&gt;
: 480 Gb SSHD&lt;br /&gt;
: 1 Tb HD&lt;br /&gt;
: 650 W power supply&lt;br /&gt;
: AMD Radeon HD 7700 with 2 Gb RAM&lt;br /&gt;
&lt;br /&gt;
Report Generated at: 1/8/2013 1:02:45 AM&lt;br /&gt;
&lt;br /&gt;
OK, so the machine is sneaking up on its third year in service.  It still gets a decent rating from me and Windows:&lt;br /&gt;
&lt;br /&gt;
[[File:Homebrew 5 performance.jpg]]&lt;br /&gt;
&lt;br /&gt;
And, as with everything else except for Wikimedia version and the WAMPserver versions, I haven&#039;t changed anything from last week, when all was well in wikiland.&lt;br /&gt;
&lt;br /&gt;
=== OS ===&lt;br /&gt;
&lt;br /&gt;
: Windows 7 Professional, 64-bit&lt;br /&gt;
: Service Pack 1&lt;br /&gt;
&lt;br /&gt;
=== Browser ===&lt;br /&gt;
&lt;br /&gt;
: Chrome 46.0.2490.86 m&lt;br /&gt;
&lt;br /&gt;
=== Software Guardians ===&lt;br /&gt;
&lt;br /&gt;
: Malware Bytes&lt;br /&gt;
::: Set to exclude 127.0.0.1, httpd.exe, and mysql.exe from inspection.&lt;br /&gt;
&lt;br /&gt;
: CylanceProtect&lt;br /&gt;
::: I&#039;ve got no control over this.  All I can say is that with MediaWiki 1.20, I had no connection problems.&lt;br /&gt;
&lt;br /&gt;
: Firewall&lt;br /&gt;
::: Made sure port 3306 is open.&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #1 ==&lt;br /&gt;
&lt;br /&gt;
Because the connection ALWAYS worked on the very next try after a failure, I thought that perhaps I could arrange a sacrificial connection to feed the ravenous Connection Monster; while it was chomping on the carcass, the real Mediawiki connection might sneak by unnoticed.&lt;br /&gt;
&lt;br /&gt;
So I put this in my LocalSettings.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$servername = &amp;quot;127.0.0.1&amp;quot;;&lt;br /&gt;
$username = &amp;quot;dbuser&amp;quot;;&lt;br /&gt;
$password = &amp;quot;dbuserpassword&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Create connection&lt;br /&gt;
$conn = new mysqli($servername, $username, $password);&lt;br /&gt;
&lt;br /&gt;
// Check connection&lt;br /&gt;
if ($conn-&amp;gt;connect_error) {&lt;br /&gt;
    die(&amp;quot;Connection failed: &amp;quot; . $conn-&amp;gt;connect_error);&lt;br /&gt;
} &lt;br /&gt;
#echo &amp;quot;Connected successfully&amp;quot;;&lt;br /&gt;
mysqli_close($conn);&lt;br /&gt;
#die(&amp;quot;test finished&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This idiotic connection hasn&#039;t ever failed yet.&lt;br /&gt;
&lt;br /&gt;
And the wiki page hasn&#039;t yet failed to connect afterward, either.&lt;br /&gt;
&lt;br /&gt;
Pasta faggiole!&lt;br /&gt;
&lt;br /&gt;
I hate it.&lt;br /&gt;
&lt;br /&gt;
But not as much as I hate seeing the &amp;quot;connection failed&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Not yet, anyway.&lt;br /&gt;
&lt;br /&gt;
Using the [http://php.net/manual/en/book.hrtime.php &#039;&#039;hrtime&#039;&#039; extension,] I can see that this little connection check only takes a couple of milliseconds, so it&#039;s not costing me huge time in loading pages.  &lt;br /&gt;
&lt;br /&gt;
But I hate it.&lt;br /&gt;
&lt;br /&gt;
== It&#039;s a feature, not a bug ==&lt;br /&gt;
&lt;br /&gt;
The MediaWiki wizards know &#039;that there is something awkward in &#039;&#039;&#039;LoadBalancer.php&#039;&#039;&#039;: [https://phabricator.wikimedia.org/T72223#1673869 &amp;quot;&#039;Unknown error&#039; in LoadBalancer-&amp;gt;reportConnectionError() hides a real database problem&amp;quot; (Sep 25 2015, 9:15 AM):]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Change 157488 abandoned by Hashar:&lt;br /&gt;
Do not hide real DB error on first connect&lt;br /&gt;
&lt;br /&gt;
Reason:&lt;br /&gt;
That would cause T31233 Broken failover for DB slave connection errors.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;The try/catch was done on purpose&#039;&#039;&#039;&#039;&#039;, see Tim comment on https://www.mediawiki.org/wiki/Special:Code/MediaWiki/90266#c20239 &lt;br /&gt;
&lt;br /&gt;
We have a task for a better fix T35036&lt;br /&gt;
&lt;br /&gt;
[https://gerrit.wikimedia.org/r/157488 Do not hide real DB error on first connect]&lt;br /&gt;
:: LoadBalancer should not silence database exception. Bug: 70223&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is not a problem on public linux production sites, such as this one (moleski.net) and another one that I run, even though they are, like localhost, single-server sites with no database slaves to worry about.&lt;br /&gt;
&lt;br /&gt;
There is &#039;&#039;something&#039;&#039; about the Windows environment that unsettles Mediawiki&#039;s database procedures ...&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #2 ==&lt;br /&gt;
&lt;br /&gt;
I&#039;ve commented out the &amp;quot;try ... catch&amp;quot; code and replaced with with the rejected simplification suggested by Saper.  I don&#039;t care that this simplification &amp;quot;would cause T31233 Broken failover for DB slave connection errors.&amp;quot; Not my circus, not my monkeys.  I&#039;m running this code on &#039;&#039;localhost.&#039;&#039;  There are no slave connections.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# MXM Cutting out &amp;quot;ugliest thing&amp;quot; and substituting another&#039;s guy&#039;s remedy&lt;br /&gt;
#		try {&lt;br /&gt;
#			$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
#		} catch ( DBConnectionError $e ) {&lt;br /&gt;
#			// FIXME: This is probably the ugliest thing I have ever done to&lt;br /&gt;
#			// PHP. I&#039;m half-expecting it to segfault, just out of disgust. -- TS&lt;br /&gt;
#			$db = $e-&amp;gt;db;&lt;br /&gt;
#                       die(&#039;MXM: yep, came through here.&#039;)&lt;br /&gt;
#		}&lt;br /&gt;
# MXM&lt;br /&gt;
$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
# MXM&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What difference does this difference make?  $db is not assigned to $e-&amp;gt;db if the connection fails.  I put some feedback in the &amp;quot;catch&amp;quot; block, to see if for some reason my system is taking that route.  After I rebooted, I got the confirmation that the program execution flowed through that branch.&lt;br /&gt;
&lt;br /&gt;
But making this change did not make all things well again.  On a cold boot the next day, all of my &amp;quot;technical difficulties&amp;quot; came crashing back.  By itself, Ugly Workaround #2 does not scratch the itch.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;What I don&#039;t know is why there is any problem on startup at all&#039;&#039;&#039;&#039;&#039;.  What is the difference between this setup and the one that hummed along for almost three years without any difficulty?  I can&#039;t disable Cylance to find out.  It is imposed on me from above.  In theory, I have configured Malware Bytes to ignore things served from localhost.  &lt;br /&gt;
&lt;br /&gt;
== Just the facts, Ma&#039;am. ==&lt;br /&gt;
&lt;br /&gt;
:: - My setup is slow on startup after a reboot.&lt;br /&gt;
:: - Mediawiki is not willing to wait for localhost to wake up.&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.mail-archive.com/mediawiki-commits@lists.wikimedia.org/msg283522.html &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;MediaWiki-commits&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;Gerrit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; Add support for connect_timeout -	change (mediawiki...PoolCounter)]&lt;br /&gt;
:: The intriguing line: &#039;&#039;we implement here what we already do for mysql connections: if we set a connection timeout to a very small value (in the order of magnitude of twice the RTT to the poolcounter server) and retry twice, we can have very fast failures in case one server goes down, and the failover to the other active servers would happen almost harmlessly.&#039;&#039;  &lt;br /&gt;
:: I&#039;m convinced this is a clue, but I haven&#039;t waded into the code to see what I might be able to play with.  &lt;br /&gt;
* [http://serverfault.com/questions/408550/connecting-to-mysql-from-php-is-extremely-slow &amp;quot;Connecting to MySQL from PHP is extremely slow&amp;quot;]&lt;br /&gt;
:: David Random&#039;s essay on this page is superb.  It didn&#039;t fix what ailed me, but it made me feel that I was understanding the problem better.&lt;br /&gt;
* [https://ineed.coffee/1441/apache-php-mysql-slow-under-windows-8-how-to-fix/ &amp;quot;Apache, PHP, MySQL slow under Windows 8. How to fix.&amp;quot;]&lt;br /&gt;
:: Contains an excellent set of links to various tips and tricks, as well as making some fresh suggestions.&lt;br /&gt;
* [http://127.0.0.1/mediawiki/api.php?action=query&amp;amp;meta=siteinfo&amp;amp;siprop=statistics&amp;amp;format=jsonfm Count jobs on my localhost.]  This won&#039;t do you any good or me any harm, if I&#039;m lucky.  This is a handy spot for me to drop this link to see whether jobs have accumulated on my local wiki.  They haven&#039;t.&lt;br /&gt;
[[Category:Computers]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16402</id>
		<title>WAMP, localhost, Mediawiki: Cannot access the database</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16402"/>
		<updated>2015-12-03T04:31:09Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* Ugly Workaround #2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;or &#039;&#039;&#039;&#039;&#039;The Bug that Ate a Week of My Life!&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mediawiki on localhost ==&lt;br /&gt;
&lt;br /&gt;
Since 2:42 PM on 14 March 2009, I have run a private wiki for myself on a WAMP stack--6.5 years and counting.&lt;br /&gt;
&lt;br /&gt;
I have migrated the wiki from one desktop to another and installed it on two different laptops.&lt;br /&gt;
&lt;br /&gt;
I have never had everything work perfectly right out of the box, but I have never been frustrated for too long.  People have solved all of the basic problems more than once, and it has been just a matter of googling around long enough to debug the setup.&lt;br /&gt;
&lt;br /&gt;
All that has changed.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve found a bug that has defeated me.&lt;br /&gt;
&lt;br /&gt;
== Mediawiki 1.26, WAMPserver 2.5, and WAMPserver 3 ==&lt;br /&gt;
&lt;br /&gt;
== Error Messages ==&lt;br /&gt;
&lt;br /&gt;
=== Shorter version ===&lt;br /&gt;
&lt;br /&gt;
Sorry! This site is experiencing technical difficulties.&lt;br /&gt;
&lt;br /&gt;
Try waiting a few minutes and reloading.&lt;br /&gt;
&lt;br /&gt;
(Cannot access the database)&lt;br /&gt;
&lt;br /&gt;
=== With debugging and backtracking enabled ===&lt;br /&gt;
&lt;br /&gt;
Cannot access the database: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ())&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Backtrace:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
:  #0 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(842): &#039;&#039;&#039;DatabaseBase&#039;&#039;&#039;-&amp;gt;reportConnectionError(&#039;Unknown error (...&#039;)&lt;br /&gt;
:  #1 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(537): &#039;&#039;&#039;LoadBalancer&#039;&#039;&#039;-&amp;gt;reportConnectionError()&lt;br /&gt;
:  #2 C:\wamp\www\mediawiki\includes\GlobalFunctions.php(3631): LoadBalancer-&amp;gt;getConnection(-1, Array, false)&lt;br /&gt;
:  #3 C:\wamp\www\mediawiki\includes\User.php(1208): wfGetDB(-1)&lt;br /&gt;
:  #4 C:\wamp\www\mediawiki\includes\User.php(397): User-&amp;gt;loadFromDatabase(0)&lt;br /&gt;
:  #5 C:\wamp\www\mediawiki\includes\User.php(362): User-&amp;gt;loadFromId(0)&lt;br /&gt;
:  #6 C:\wamp\www\mediawiki\includes\User.php(2459): User-&amp;gt;load()&lt;br /&gt;
:  #7 C:\wamp\www\mediawiki\includes\User.php(1167): User-&amp;gt;getToken(false)&lt;br /&gt;
:  #8 C:\wamp\www\mediawiki\includes\User.php(365): User-&amp;gt;loadFromSession()&lt;br /&gt;
:  #9 C:\wamp\www\mediawiki\includes\User.php(2029): User-&amp;gt;load()&lt;br /&gt;
:  #10 C:\wamp\www\mediawiki\includes\User.php(3204): User-&amp;gt;getId()&lt;br /&gt;
:  #11 C:\wamp\www\mediawiki\includes\MediaWiki.php(627): User-&amp;gt;isLoggedIn()&lt;br /&gt;
:  #12 C:\wamp\www\mediawiki\includes\MediaWiki.php(476): MediaWiki-&amp;gt;main()&lt;br /&gt;
:  #13 C:\wamp\www\mediawiki\index.php(51): MediaWiki-&amp;gt;run()&lt;br /&gt;
:  #14 {main}&lt;br /&gt;
&lt;br /&gt;
:  reportConnectionError &amp;quot;Unknown error&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Failure message when MySQL is totally disabled ===&lt;br /&gt;
&lt;br /&gt;
Warning: mysqli::mysqli(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp\www\mediawiki\LocalSettings.php on line 152&lt;br /&gt;
&lt;br /&gt;
Connection failed: No connection could be made because the target machine actively refused it.&lt;br /&gt;
&lt;br /&gt;
== Not a code or configuration problem ==&lt;br /&gt;
&lt;br /&gt;
Except for a few times when I shot myself in the foot while debugging, the proof that the PHP code base and my configuration are correct is that I can immediately obtain the page I want by reloading the page.  &lt;br /&gt;
&lt;br /&gt;
It is only on the first call after a long time (five minutes? ten?) of not accessing the wiki that the problem occurs.&lt;br /&gt;
&lt;br /&gt;
== Timing is everything ==&lt;br /&gt;
&lt;br /&gt;
The most common time for the bug to bite is when I open my browser.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve got two tabs to pages on the local wiki in my collection of home pages.&lt;br /&gt;
&lt;br /&gt;
The first one usually fails if I&#039;ve had the browser closed for a while; the second never does.&lt;br /&gt;
&lt;br /&gt;
I dropped the second page from the set to see if that would help the first. &lt;br /&gt;
&lt;br /&gt;
It didn&#039;t.&lt;br /&gt;
&lt;br /&gt;
Once MySQL is awakened from its slumbers, all the links in the wiki work reasonably well--no worse than ever before--unless I spend a long time composing a page, and then the connection fails when I try to save the page.  Refresh the page, and it saves perfectly.&lt;br /&gt;
&lt;br /&gt;
Something somewhere keeps MySQL from answering the FIRST request for a connection in the time frame that Mediawiki expects.  After that, everything is normal enough until MySQL decides to fall asleep again.&lt;br /&gt;
&lt;br /&gt;
== Round up the usual suspects ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s some interaction between Windows, Apache, MySQL, and the Wikimedia routines that has got me down.&lt;br /&gt;
&lt;br /&gt;
Why can&#039;t we all just get along?&lt;br /&gt;
&lt;br /&gt;
The articles in the [[#Links|links below]] have got excellent information and links in them.  They cover pretty much everything I&#039;ve tried, and then some.  I&#039;m just going to list the failed fixes that float into mind:&lt;br /&gt;
&lt;br /&gt;
* turn off IPv6 on my machine&lt;br /&gt;
* have Apache listen only to 127.0.0.1:80&lt;br /&gt;
* bind MySQL to 127.0.0.1 &lt;br /&gt;
* turn off name resolution in MySQL&lt;br /&gt;
* change localhost to 127.0.0.1 everywhere I can to avoid DNS calls&lt;br /&gt;
* edit Hosts file to make sure localhost is defined&lt;br /&gt;
* enable opcache and install APCu&lt;br /&gt;
* turn off Zend debugger&lt;br /&gt;
* moved from WAMPserver 2.5 to 3&lt;br /&gt;
&lt;br /&gt;
Total failure, but intriguing: get MySQL to use a socket.  There are paths for it in the configuration files, but I&#039;ve never gotten it going.  I must do more googling!  It seems as though it SHOULD work.&lt;br /&gt;
&lt;br /&gt;
== Sysinfo ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
: BIOS Manufacturer: American Megatrends Inc.&lt;br /&gt;
: Release Date: 10/23/2012&lt;br /&gt;
: BIOS Version: ALASKA - 1072009&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: Board Product ID: Gigabyte 990FXA-UD3&lt;br /&gt;
&lt;br /&gt;
: AMD FX-8350 Eight-Core Processor, 4 Ghz&lt;br /&gt;
: 16 GB RAM&lt;br /&gt;
: 480 Gb SSHD&lt;br /&gt;
: 1 Tb HD&lt;br /&gt;
: 650 W power supply&lt;br /&gt;
: AMD Radeon HD 7700 with 2 Gb RAM&lt;br /&gt;
&lt;br /&gt;
Report Generated at: 1/8/2013 1:02:45 AM&lt;br /&gt;
&lt;br /&gt;
OK, so the machine is sneaking up on its third year in service.  It still gets a decent rating from me and Windows:&lt;br /&gt;
&lt;br /&gt;
[[File:Homebrew 5 performance.jpg]]&lt;br /&gt;
&lt;br /&gt;
And, as with everything else except for Wikimedia version and the WAMPserver versions, I haven&#039;t changed anything from last week, when all was well in wikiland.&lt;br /&gt;
&lt;br /&gt;
=== OS ===&lt;br /&gt;
&lt;br /&gt;
: Windows 7 Professional, 64-bit&lt;br /&gt;
: Service Pack 1&lt;br /&gt;
&lt;br /&gt;
=== Browser ===&lt;br /&gt;
&lt;br /&gt;
: Chrome 46.0.2490.86 m&lt;br /&gt;
&lt;br /&gt;
=== Software Guardians ===&lt;br /&gt;
&lt;br /&gt;
: Malware Bytes&lt;br /&gt;
::: Set to exclude 127.0.0.1, httpd.exe, and mysql.exe from inspection.&lt;br /&gt;
&lt;br /&gt;
: CylanceProtect&lt;br /&gt;
::: I&#039;ve got no control over this.  All I can say is that with MediaWiki 1.20, I had no connection problems.&lt;br /&gt;
&lt;br /&gt;
: Firewall&lt;br /&gt;
::: Made sure port 3306 is open.&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #1 ==&lt;br /&gt;
&lt;br /&gt;
Because the connection ALWAYS worked on the very next try after a failure, I thought that perhaps I could arrange a sacrificial connection to feed the ravenous Connection Monster; while it was chomping on the carcass, the real Mediawiki connection might sneak by unnoticed.&lt;br /&gt;
&lt;br /&gt;
So I put this in my LocalSettings.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$servername = &amp;quot;127.0.0.1&amp;quot;;&lt;br /&gt;
$username = &amp;quot;dbuser&amp;quot;;&lt;br /&gt;
$password = &amp;quot;dbuserpassword&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Create connection&lt;br /&gt;
$conn = new mysqli($servername, $username, $password);&lt;br /&gt;
&lt;br /&gt;
// Check connection&lt;br /&gt;
if ($conn-&amp;gt;connect_error) {&lt;br /&gt;
    die(&amp;quot;Connection failed: &amp;quot; . $conn-&amp;gt;connect_error);&lt;br /&gt;
} &lt;br /&gt;
#echo &amp;quot;Connected successfully&amp;quot;;&lt;br /&gt;
mysqli_close($conn);&lt;br /&gt;
#die(&amp;quot;test finished&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This idiotic connection hasn&#039;t ever failed yet.&lt;br /&gt;
&lt;br /&gt;
And the wiki page hasn&#039;t yet failed to connect afterward, either.&lt;br /&gt;
&lt;br /&gt;
Pasta faggiole!&lt;br /&gt;
&lt;br /&gt;
I hate it.&lt;br /&gt;
&lt;br /&gt;
But not as much as I hate seeing the &amp;quot;connection failed&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Not yet, anyway.&lt;br /&gt;
&lt;br /&gt;
Using the [http://php.net/manual/en/book.hrtime.php &#039;&#039;hrtime&#039;&#039; extension,] I can see that this little connection check only takes a couple of milliseconds, so it&#039;s not costing me huge time in loading pages.  &lt;br /&gt;
&lt;br /&gt;
But I hate it.&lt;br /&gt;
&lt;br /&gt;
== It&#039;s a feature, not a bug ==&lt;br /&gt;
&lt;br /&gt;
The MediaWiki wizards know &#039;that there is something awkward in &#039;&#039;&#039;LoadBalancer.php&#039;&#039;&#039;: [https://phabricator.wikimedia.org/T72223#1673869 &amp;quot;&#039;Unknown error&#039; in LoadBalancer-&amp;gt;reportConnectionError() hides a real database problem&amp;quot; (Sep 25 2015, 9:15 AM):]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Change 157488 abandoned by Hashar:&lt;br /&gt;
Do not hide real DB error on first connect&lt;br /&gt;
&lt;br /&gt;
Reason:&lt;br /&gt;
That would cause T31233 Broken failover for DB slave connection errors.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;The try/catch was done on purpose&#039;&#039;&#039;&#039;&#039;, see Tim comment on https://www.mediawiki.org/wiki/Special:Code/MediaWiki/90266#c20239 &lt;br /&gt;
&lt;br /&gt;
We have a task for a better fix T35036&lt;br /&gt;
&lt;br /&gt;
[https://gerrit.wikimedia.org/r/157488 Do not hide real DB error on first connect]&lt;br /&gt;
:: LoadBalancer should not silence database exception. Bug: 70223&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is not a problem on public linux production sites, such as this one (moleski.net) and another one that I run, even though they are, like localhost, single-server sites with no database slaves to worry about.&lt;br /&gt;
&lt;br /&gt;
There is &#039;&#039;something&#039;&#039; about the Windows environment that unsettles Mediawiki&#039;s database procedures ...&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #2 ==&lt;br /&gt;
&lt;br /&gt;
I&#039;ve commented out the &amp;quot;try ... catch&amp;quot; code and replaced with with the rejected simplification suggested by Saper.  I don&#039;t care that this simplification &amp;quot;would cause T31233 Broken failover for DB slave connection errors.&amp;quot; Not my circus, not my monkeys.  I&#039;m running this code on &#039;&#039;localhost.&#039;&#039;  There are no slave connections.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# MXM Cutting out &amp;quot;ugliest thing&amp;quot; and substituting another&#039;s guy&#039;s remedy&lt;br /&gt;
#		try {&lt;br /&gt;
#			$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
#		} catch ( DBConnectionError $e ) {&lt;br /&gt;
#			// FIXME: This is probably the ugliest thing I have ever done to&lt;br /&gt;
#			// PHP. I&#039;m half-expecting it to segfault, just out of disgust. -- TS&lt;br /&gt;
#			$db = $e-&amp;gt;db;&lt;br /&gt;
#                       die(&#039;MXM: yep, came through here.&#039;)&lt;br /&gt;
#		}&lt;br /&gt;
# MXM&lt;br /&gt;
$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
# MXM&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What difference does this difference make?  $db is not assigned to $e-&amp;gt;db if the connection fails.  I put some feedback in the &amp;quot;catch&amp;quot; block, to see if for some reason my system is taking that route.  After I rebooted, I got the confirmation that the program execution flowed through that branch.&lt;br /&gt;
&lt;br /&gt;
What I don&#039;t know is why there is any problem on startup at all.  What is the difference between this setup and the one that hummed along for almost three years without any difficulty?&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.mail-archive.com/mediawiki-commits@lists.wikimedia.org/msg283522.html &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;MediaWiki-commits&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;Gerrit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; Add support for connect_timeout -	change (mediawiki...PoolCounter)]&lt;br /&gt;
:: The intriguing line: &#039;&#039;we implement here what we already do for mysql connections: if we set a connection timeout to a very small value (in the order of magnitude of twice the RTT to the poolcounter server) and retry twice, we can have very fast failures in case one server goes down, and the failover to the other active servers would happen almost harmlessly.&#039;&#039;  &lt;br /&gt;
:: I&#039;m convinced this is a clue, but I haven&#039;t waded into the code to see what I might be able to play with.  &lt;br /&gt;
* [http://serverfault.com/questions/408550/connecting-to-mysql-from-php-is-extremely-slow &amp;quot;Connecting to MySQL from PHP is extremely slow&amp;quot;]&lt;br /&gt;
:: David Random&#039;s essay on this page is superb.  It didn&#039;t fix what ailed me, but it made me feel that I was understanding the problem better.&lt;br /&gt;
* [https://ineed.coffee/1441/apache-php-mysql-slow-under-windows-8-how-to-fix/ &amp;quot;Apache, PHP, MySQL slow under Windows 8. How to fix.&amp;quot;]&lt;br /&gt;
:: Contains an excellent set of links to various tips and tricks, as well as making some fresh suggestions.&lt;br /&gt;
* [http://127.0.0.1/mediawiki/api.php?action=query&amp;amp;meta=siteinfo&amp;amp;siprop=statistics&amp;amp;format=jsonfm Count jobs on my localhost.]  This won&#039;t do you any good or me any harm, if I&#039;m lucky.  This is a handy spot for me to drop this link to see whether jobs have accumulated on my local wiki.  They haven&#039;t.&lt;br /&gt;
[[Category:Computers]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16401</id>
		<title>WAMP, localhost, Mediawiki: Cannot access the database</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16401"/>
		<updated>2015-12-03T03:29:35Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* Ugly Workaround #2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;or &#039;&#039;&#039;&#039;&#039;The Bug that Ate a Week of My Life!&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mediawiki on localhost ==&lt;br /&gt;
&lt;br /&gt;
Since 2:42 PM on 14 March 2009, I have run a private wiki for myself on a WAMP stack--6.5 years and counting.&lt;br /&gt;
&lt;br /&gt;
I have migrated the wiki from one desktop to another and installed it on two different laptops.&lt;br /&gt;
&lt;br /&gt;
I have never had everything work perfectly right out of the box, but I have never been frustrated for too long.  People have solved all of the basic problems more than once, and it has been just a matter of googling around long enough to debug the setup.&lt;br /&gt;
&lt;br /&gt;
All that has changed.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve found a bug that has defeated me.&lt;br /&gt;
&lt;br /&gt;
== Mediawiki 1.26, WAMPserver 2.5, and WAMPserver 3 ==&lt;br /&gt;
&lt;br /&gt;
== Error Messages ==&lt;br /&gt;
&lt;br /&gt;
=== Shorter version ===&lt;br /&gt;
&lt;br /&gt;
Sorry! This site is experiencing technical difficulties.&lt;br /&gt;
&lt;br /&gt;
Try waiting a few minutes and reloading.&lt;br /&gt;
&lt;br /&gt;
(Cannot access the database)&lt;br /&gt;
&lt;br /&gt;
=== With debugging and backtracking enabled ===&lt;br /&gt;
&lt;br /&gt;
Cannot access the database: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ())&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Backtrace:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
:  #0 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(842): &#039;&#039;&#039;DatabaseBase&#039;&#039;&#039;-&amp;gt;reportConnectionError(&#039;Unknown error (...&#039;)&lt;br /&gt;
:  #1 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(537): &#039;&#039;&#039;LoadBalancer&#039;&#039;&#039;-&amp;gt;reportConnectionError()&lt;br /&gt;
:  #2 C:\wamp\www\mediawiki\includes\GlobalFunctions.php(3631): LoadBalancer-&amp;gt;getConnection(-1, Array, false)&lt;br /&gt;
:  #3 C:\wamp\www\mediawiki\includes\User.php(1208): wfGetDB(-1)&lt;br /&gt;
:  #4 C:\wamp\www\mediawiki\includes\User.php(397): User-&amp;gt;loadFromDatabase(0)&lt;br /&gt;
:  #5 C:\wamp\www\mediawiki\includes\User.php(362): User-&amp;gt;loadFromId(0)&lt;br /&gt;
:  #6 C:\wamp\www\mediawiki\includes\User.php(2459): User-&amp;gt;load()&lt;br /&gt;
:  #7 C:\wamp\www\mediawiki\includes\User.php(1167): User-&amp;gt;getToken(false)&lt;br /&gt;
:  #8 C:\wamp\www\mediawiki\includes\User.php(365): User-&amp;gt;loadFromSession()&lt;br /&gt;
:  #9 C:\wamp\www\mediawiki\includes\User.php(2029): User-&amp;gt;load()&lt;br /&gt;
:  #10 C:\wamp\www\mediawiki\includes\User.php(3204): User-&amp;gt;getId()&lt;br /&gt;
:  #11 C:\wamp\www\mediawiki\includes\MediaWiki.php(627): User-&amp;gt;isLoggedIn()&lt;br /&gt;
:  #12 C:\wamp\www\mediawiki\includes\MediaWiki.php(476): MediaWiki-&amp;gt;main()&lt;br /&gt;
:  #13 C:\wamp\www\mediawiki\index.php(51): MediaWiki-&amp;gt;run()&lt;br /&gt;
:  #14 {main}&lt;br /&gt;
&lt;br /&gt;
:  reportConnectionError &amp;quot;Unknown error&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Failure message when MySQL is totally disabled ===&lt;br /&gt;
&lt;br /&gt;
Warning: mysqli::mysqli(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp\www\mediawiki\LocalSettings.php on line 152&lt;br /&gt;
&lt;br /&gt;
Connection failed: No connection could be made because the target machine actively refused it.&lt;br /&gt;
&lt;br /&gt;
== Not a code or configuration problem ==&lt;br /&gt;
&lt;br /&gt;
Except for a few times when I shot myself in the foot while debugging, the proof that the PHP code base and my configuration are correct is that I can immediately obtain the page I want by reloading the page.  &lt;br /&gt;
&lt;br /&gt;
It is only on the first call after a long time (five minutes? ten?) of not accessing the wiki that the problem occurs.&lt;br /&gt;
&lt;br /&gt;
== Timing is everything ==&lt;br /&gt;
&lt;br /&gt;
The most common time for the bug to bite is when I open my browser.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve got two tabs to pages on the local wiki in my collection of home pages.&lt;br /&gt;
&lt;br /&gt;
The first one usually fails if I&#039;ve had the browser closed for a while; the second never does.&lt;br /&gt;
&lt;br /&gt;
I dropped the second page from the set to see if that would help the first. &lt;br /&gt;
&lt;br /&gt;
It didn&#039;t.&lt;br /&gt;
&lt;br /&gt;
Once MySQL is awakened from its slumbers, all the links in the wiki work reasonably well--no worse than ever before--unless I spend a long time composing a page, and then the connection fails when I try to save the page.  Refresh the page, and it saves perfectly.&lt;br /&gt;
&lt;br /&gt;
Something somewhere keeps MySQL from answering the FIRST request for a connection in the time frame that Mediawiki expects.  After that, everything is normal enough until MySQL decides to fall asleep again.&lt;br /&gt;
&lt;br /&gt;
== Round up the usual suspects ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s some interaction between Windows, Apache, MySQL, and the Wikimedia routines that has got me down.&lt;br /&gt;
&lt;br /&gt;
Why can&#039;t we all just get along?&lt;br /&gt;
&lt;br /&gt;
The articles in the [[#Links|links below]] have got excellent information and links in them.  They cover pretty much everything I&#039;ve tried, and then some.  I&#039;m just going to list the failed fixes that float into mind:&lt;br /&gt;
&lt;br /&gt;
* turn off IPv6 on my machine&lt;br /&gt;
* have Apache listen only to 127.0.0.1:80&lt;br /&gt;
* bind MySQL to 127.0.0.1 &lt;br /&gt;
* turn off name resolution in MySQL&lt;br /&gt;
* change localhost to 127.0.0.1 everywhere I can to avoid DNS calls&lt;br /&gt;
* edit Hosts file to make sure localhost is defined&lt;br /&gt;
* enable opcache and install APCu&lt;br /&gt;
* turn off Zend debugger&lt;br /&gt;
* moved from WAMPserver 2.5 to 3&lt;br /&gt;
&lt;br /&gt;
Total failure, but intriguing: get MySQL to use a socket.  There are paths for it in the configuration files, but I&#039;ve never gotten it going.  I must do more googling!  It seems as though it SHOULD work.&lt;br /&gt;
&lt;br /&gt;
== Sysinfo ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
: BIOS Manufacturer: American Megatrends Inc.&lt;br /&gt;
: Release Date: 10/23/2012&lt;br /&gt;
: BIOS Version: ALASKA - 1072009&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: Board Product ID: Gigabyte 990FXA-UD3&lt;br /&gt;
&lt;br /&gt;
: AMD FX-8350 Eight-Core Processor, 4 Ghz&lt;br /&gt;
: 16 GB RAM&lt;br /&gt;
: 480 Gb SSHD&lt;br /&gt;
: 1 Tb HD&lt;br /&gt;
: 650 W power supply&lt;br /&gt;
: AMD Radeon HD 7700 with 2 Gb RAM&lt;br /&gt;
&lt;br /&gt;
Report Generated at: 1/8/2013 1:02:45 AM&lt;br /&gt;
&lt;br /&gt;
OK, so the machine is sneaking up on its third year in service.  It still gets a decent rating from me and Windows:&lt;br /&gt;
&lt;br /&gt;
[[File:Homebrew 5 performance.jpg]]&lt;br /&gt;
&lt;br /&gt;
And, as with everything else except for Wikimedia version and the WAMPserver versions, I haven&#039;t changed anything from last week, when all was well in wikiland.&lt;br /&gt;
&lt;br /&gt;
=== OS ===&lt;br /&gt;
&lt;br /&gt;
: Windows 7 Professional, 64-bit&lt;br /&gt;
: Service Pack 1&lt;br /&gt;
&lt;br /&gt;
=== Browser ===&lt;br /&gt;
&lt;br /&gt;
: Chrome 46.0.2490.86 m&lt;br /&gt;
&lt;br /&gt;
=== Software Guardians ===&lt;br /&gt;
&lt;br /&gt;
: Malware Bytes&lt;br /&gt;
::: Set to exclude 127.0.0.1, httpd.exe, and mysql.exe from inspection.&lt;br /&gt;
&lt;br /&gt;
: CylanceProtect&lt;br /&gt;
::: I&#039;ve got no control over this.  All I can say is that with MediaWiki 1.20, I had no connection problems.&lt;br /&gt;
&lt;br /&gt;
: Firewall&lt;br /&gt;
::: Made sure port 3306 is open.&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #1 ==&lt;br /&gt;
&lt;br /&gt;
Because the connection ALWAYS worked on the very next try after a failure, I thought that perhaps I could arrange a sacrificial connection to feed the ravenous Connection Monster; while it was chomping on the carcass, the real Mediawiki connection might sneak by unnoticed.&lt;br /&gt;
&lt;br /&gt;
So I put this in my LocalSettings.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$servername = &amp;quot;127.0.0.1&amp;quot;;&lt;br /&gt;
$username = &amp;quot;dbuser&amp;quot;;&lt;br /&gt;
$password = &amp;quot;dbuserpassword&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Create connection&lt;br /&gt;
$conn = new mysqli($servername, $username, $password);&lt;br /&gt;
&lt;br /&gt;
// Check connection&lt;br /&gt;
if ($conn-&amp;gt;connect_error) {&lt;br /&gt;
    die(&amp;quot;Connection failed: &amp;quot; . $conn-&amp;gt;connect_error);&lt;br /&gt;
} &lt;br /&gt;
#echo &amp;quot;Connected successfully&amp;quot;;&lt;br /&gt;
mysqli_close($conn);&lt;br /&gt;
#die(&amp;quot;test finished&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This idiotic connection hasn&#039;t ever failed yet.&lt;br /&gt;
&lt;br /&gt;
And the wiki page hasn&#039;t yet failed to connect afterward, either.&lt;br /&gt;
&lt;br /&gt;
Pasta faggiole!&lt;br /&gt;
&lt;br /&gt;
I hate it.&lt;br /&gt;
&lt;br /&gt;
But not as much as I hate seeing the &amp;quot;connection failed&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Not yet, anyway.&lt;br /&gt;
&lt;br /&gt;
Using the [http://php.net/manual/en/book.hrtime.php &#039;&#039;hrtime&#039;&#039; extension,] I can see that this little connection check only takes a couple of milliseconds, so it&#039;s not costing me huge time in loading pages.  &lt;br /&gt;
&lt;br /&gt;
But I hate it.&lt;br /&gt;
&lt;br /&gt;
== It&#039;s a feature, not a bug ==&lt;br /&gt;
&lt;br /&gt;
The MediaWiki wizards know &#039;that there is something awkward in &#039;&#039;&#039;LoadBalancer.php&#039;&#039;&#039;: [https://phabricator.wikimedia.org/T72223#1673869 &amp;quot;&#039;Unknown error&#039; in LoadBalancer-&amp;gt;reportConnectionError() hides a real database problem&amp;quot; (Sep 25 2015, 9:15 AM):]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Change 157488 abandoned by Hashar:&lt;br /&gt;
Do not hide real DB error on first connect&lt;br /&gt;
&lt;br /&gt;
Reason:&lt;br /&gt;
That would cause T31233 Broken failover for DB slave connection errors.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;The try/catch was done on purpose&#039;&#039;&#039;&#039;&#039;, see Tim comment on https://www.mediawiki.org/wiki/Special:Code/MediaWiki/90266#c20239 &lt;br /&gt;
&lt;br /&gt;
We have a task for a better fix T35036&lt;br /&gt;
&lt;br /&gt;
[https://gerrit.wikimedia.org/r/157488 Do not hide real DB error on first connect]&lt;br /&gt;
:: LoadBalancer should not silence database exception. Bug: 70223&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is not a problem on public linux production sites, such as this one (moleski.net) and another one that I run, even though they are, like localhost, single-server sites with no database slaves to worry about.&lt;br /&gt;
&lt;br /&gt;
There is &#039;&#039;something&#039;&#039; about the Windows environment that unsettles Mediawiki&#039;s database procedures ...&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #2 ==&lt;br /&gt;
&lt;br /&gt;
I&#039;ve commented out the &amp;quot;try ... catch&amp;quot; code and replaced with with the rejected simplification suggested by Saper.  I don&#039;t care that this simplification &amp;quot;would cause T31233 Broken failover for DB slave connection errors.&amp;quot; Not my circus, not my monkeys.  I&#039;m running this code on &#039;&#039;localhost.&#039;&#039;  There are no slave connections.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# MXM Cutting out &amp;quot;ugliest thing&amp;quot; and substituting another&#039;s guy&#039;s remedy&lt;br /&gt;
#		try {&lt;br /&gt;
#			$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
#		} catch ( DBConnectionError $e ) {&lt;br /&gt;
#			// FIXME: This is probably the ugliest thing I have ever done to&lt;br /&gt;
#			// PHP. I&#039;m half-expecting it to segfault, just out of disgust. -- TS&lt;br /&gt;
#			$db = $e-&amp;gt;db;&lt;br /&gt;
#		}&lt;br /&gt;
# MXM&lt;br /&gt;
$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
# MXM&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
What difference does this difference make?  $db is not assigned to $e-&amp;gt;db if the connection fails.  I could put some feedback in the &amp;quot;catch&amp;quot; code to see if for some reason my system is taking that route.&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.mail-archive.com/mediawiki-commits@lists.wikimedia.org/msg283522.html &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;MediaWiki-commits&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;Gerrit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; Add support for connect_timeout -	change (mediawiki...PoolCounter)]&lt;br /&gt;
:: The intriguing line: &#039;&#039;we implement here what we already do for mysql connections: if we set a connection timeout to a very small value (in the order of magnitude of twice the RTT to the poolcounter server) and retry twice, we can have very fast failures in case one server goes down, and the failover to the other active servers would happen almost harmlessly.&#039;&#039;  &lt;br /&gt;
:: I&#039;m convinced this is a clue, but I haven&#039;t waded into the code to see what I might be able to play with.  &lt;br /&gt;
* [http://serverfault.com/questions/408550/connecting-to-mysql-from-php-is-extremely-slow &amp;quot;Connecting to MySQL from PHP is extremely slow&amp;quot;]&lt;br /&gt;
:: David Random&#039;s essay on this page is superb.  It didn&#039;t fix what ailed me, but it made me feel that I was understanding the problem better.&lt;br /&gt;
* [https://ineed.coffee/1441/apache-php-mysql-slow-under-windows-8-how-to-fix/ &amp;quot;Apache, PHP, MySQL slow under Windows 8. How to fix.&amp;quot;]&lt;br /&gt;
:: Contains an excellent set of links to various tips and tricks, as well as making some fresh suggestions.&lt;br /&gt;
* [http://127.0.0.1/mediawiki/api.php?action=query&amp;amp;meta=siteinfo&amp;amp;siprop=statistics&amp;amp;format=jsonfm Count jobs on my localhost.]  This won&#039;t do you any good or me any harm, if I&#039;m lucky.  This is a handy spot for me to drop this link to see whether jobs have accumulated on my local wiki.  They haven&#039;t.&lt;br /&gt;
[[Category:Computers]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16400</id>
		<title>WAMP, localhost, Mediawiki: Cannot access the database</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16400"/>
		<updated>2015-12-03T03:25:20Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* It&amp;#039;s a feature, not a bug */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;or &#039;&#039;&#039;&#039;&#039;The Bug that Ate a Week of My Life!&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mediawiki on localhost ==&lt;br /&gt;
&lt;br /&gt;
Since 2:42 PM on 14 March 2009, I have run a private wiki for myself on a WAMP stack--6.5 years and counting.&lt;br /&gt;
&lt;br /&gt;
I have migrated the wiki from one desktop to another and installed it on two different laptops.&lt;br /&gt;
&lt;br /&gt;
I have never had everything work perfectly right out of the box, but I have never been frustrated for too long.  People have solved all of the basic problems more than once, and it has been just a matter of googling around long enough to debug the setup.&lt;br /&gt;
&lt;br /&gt;
All that has changed.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve found a bug that has defeated me.&lt;br /&gt;
&lt;br /&gt;
== Mediawiki 1.26, WAMPserver 2.5, and WAMPserver 3 ==&lt;br /&gt;
&lt;br /&gt;
== Error Messages ==&lt;br /&gt;
&lt;br /&gt;
=== Shorter version ===&lt;br /&gt;
&lt;br /&gt;
Sorry! This site is experiencing technical difficulties.&lt;br /&gt;
&lt;br /&gt;
Try waiting a few minutes and reloading.&lt;br /&gt;
&lt;br /&gt;
(Cannot access the database)&lt;br /&gt;
&lt;br /&gt;
=== With debugging and backtracking enabled ===&lt;br /&gt;
&lt;br /&gt;
Cannot access the database: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ())&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Backtrace:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
:  #0 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(842): &#039;&#039;&#039;DatabaseBase&#039;&#039;&#039;-&amp;gt;reportConnectionError(&#039;Unknown error (...&#039;)&lt;br /&gt;
:  #1 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(537): &#039;&#039;&#039;LoadBalancer&#039;&#039;&#039;-&amp;gt;reportConnectionError()&lt;br /&gt;
:  #2 C:\wamp\www\mediawiki\includes\GlobalFunctions.php(3631): LoadBalancer-&amp;gt;getConnection(-1, Array, false)&lt;br /&gt;
:  #3 C:\wamp\www\mediawiki\includes\User.php(1208): wfGetDB(-1)&lt;br /&gt;
:  #4 C:\wamp\www\mediawiki\includes\User.php(397): User-&amp;gt;loadFromDatabase(0)&lt;br /&gt;
:  #5 C:\wamp\www\mediawiki\includes\User.php(362): User-&amp;gt;loadFromId(0)&lt;br /&gt;
:  #6 C:\wamp\www\mediawiki\includes\User.php(2459): User-&amp;gt;load()&lt;br /&gt;
:  #7 C:\wamp\www\mediawiki\includes\User.php(1167): User-&amp;gt;getToken(false)&lt;br /&gt;
:  #8 C:\wamp\www\mediawiki\includes\User.php(365): User-&amp;gt;loadFromSession()&lt;br /&gt;
:  #9 C:\wamp\www\mediawiki\includes\User.php(2029): User-&amp;gt;load()&lt;br /&gt;
:  #10 C:\wamp\www\mediawiki\includes\User.php(3204): User-&amp;gt;getId()&lt;br /&gt;
:  #11 C:\wamp\www\mediawiki\includes\MediaWiki.php(627): User-&amp;gt;isLoggedIn()&lt;br /&gt;
:  #12 C:\wamp\www\mediawiki\includes\MediaWiki.php(476): MediaWiki-&amp;gt;main()&lt;br /&gt;
:  #13 C:\wamp\www\mediawiki\index.php(51): MediaWiki-&amp;gt;run()&lt;br /&gt;
:  #14 {main}&lt;br /&gt;
&lt;br /&gt;
:  reportConnectionError &amp;quot;Unknown error&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Failure message when MySQL is totally disabled ===&lt;br /&gt;
&lt;br /&gt;
Warning: mysqli::mysqli(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp\www\mediawiki\LocalSettings.php on line 152&lt;br /&gt;
&lt;br /&gt;
Connection failed: No connection could be made because the target machine actively refused it.&lt;br /&gt;
&lt;br /&gt;
== Not a code or configuration problem ==&lt;br /&gt;
&lt;br /&gt;
Except for a few times when I shot myself in the foot while debugging, the proof that the PHP code base and my configuration are correct is that I can immediately obtain the page I want by reloading the page.  &lt;br /&gt;
&lt;br /&gt;
It is only on the first call after a long time (five minutes? ten?) of not accessing the wiki that the problem occurs.&lt;br /&gt;
&lt;br /&gt;
== Timing is everything ==&lt;br /&gt;
&lt;br /&gt;
The most common time for the bug to bite is when I open my browser.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve got two tabs to pages on the local wiki in my collection of home pages.&lt;br /&gt;
&lt;br /&gt;
The first one usually fails if I&#039;ve had the browser closed for a while; the second never does.&lt;br /&gt;
&lt;br /&gt;
I dropped the second page from the set to see if that would help the first. &lt;br /&gt;
&lt;br /&gt;
It didn&#039;t.&lt;br /&gt;
&lt;br /&gt;
Once MySQL is awakened from its slumbers, all the links in the wiki work reasonably well--no worse than ever before--unless I spend a long time composing a page, and then the connection fails when I try to save the page.  Refresh the page, and it saves perfectly.&lt;br /&gt;
&lt;br /&gt;
Something somewhere keeps MySQL from answering the FIRST request for a connection in the time frame that Mediawiki expects.  After that, everything is normal enough until MySQL decides to fall asleep again.&lt;br /&gt;
&lt;br /&gt;
== Round up the usual suspects ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s some interaction between Windows, Apache, MySQL, and the Wikimedia routines that has got me down.&lt;br /&gt;
&lt;br /&gt;
Why can&#039;t we all just get along?&lt;br /&gt;
&lt;br /&gt;
The articles in the [[#Links|links below]] have got excellent information and links in them.  They cover pretty much everything I&#039;ve tried, and then some.  I&#039;m just going to list the failed fixes that float into mind:&lt;br /&gt;
&lt;br /&gt;
* turn off IPv6 on my machine&lt;br /&gt;
* have Apache listen only to 127.0.0.1:80&lt;br /&gt;
* bind MySQL to 127.0.0.1 &lt;br /&gt;
* turn off name resolution in MySQL&lt;br /&gt;
* change localhost to 127.0.0.1 everywhere I can to avoid DNS calls&lt;br /&gt;
* edit Hosts file to make sure localhost is defined&lt;br /&gt;
* enable opcache and install APCu&lt;br /&gt;
* turn off Zend debugger&lt;br /&gt;
* moved from WAMPserver 2.5 to 3&lt;br /&gt;
&lt;br /&gt;
Total failure, but intriguing: get MySQL to use a socket.  There are paths for it in the configuration files, but I&#039;ve never gotten it going.  I must do more googling!  It seems as though it SHOULD work.&lt;br /&gt;
&lt;br /&gt;
== Sysinfo ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
: BIOS Manufacturer: American Megatrends Inc.&lt;br /&gt;
: Release Date: 10/23/2012&lt;br /&gt;
: BIOS Version: ALASKA - 1072009&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: Board Product ID: Gigabyte 990FXA-UD3&lt;br /&gt;
&lt;br /&gt;
: AMD FX-8350 Eight-Core Processor, 4 Ghz&lt;br /&gt;
: 16 GB RAM&lt;br /&gt;
: 480 Gb SSHD&lt;br /&gt;
: 1 Tb HD&lt;br /&gt;
: 650 W power supply&lt;br /&gt;
: AMD Radeon HD 7700 with 2 Gb RAM&lt;br /&gt;
&lt;br /&gt;
Report Generated at: 1/8/2013 1:02:45 AM&lt;br /&gt;
&lt;br /&gt;
OK, so the machine is sneaking up on its third year in service.  It still gets a decent rating from me and Windows:&lt;br /&gt;
&lt;br /&gt;
[[File:Homebrew 5 performance.jpg]]&lt;br /&gt;
&lt;br /&gt;
And, as with everything else except for Wikimedia version and the WAMPserver versions, I haven&#039;t changed anything from last week, when all was well in wikiland.&lt;br /&gt;
&lt;br /&gt;
=== OS ===&lt;br /&gt;
&lt;br /&gt;
: Windows 7 Professional, 64-bit&lt;br /&gt;
: Service Pack 1&lt;br /&gt;
&lt;br /&gt;
=== Browser ===&lt;br /&gt;
&lt;br /&gt;
: Chrome 46.0.2490.86 m&lt;br /&gt;
&lt;br /&gt;
=== Software Guardians ===&lt;br /&gt;
&lt;br /&gt;
: Malware Bytes&lt;br /&gt;
::: Set to exclude 127.0.0.1, httpd.exe, and mysql.exe from inspection.&lt;br /&gt;
&lt;br /&gt;
: CylanceProtect&lt;br /&gt;
::: I&#039;ve got no control over this.  All I can say is that with MediaWiki 1.20, I had no connection problems.&lt;br /&gt;
&lt;br /&gt;
: Firewall&lt;br /&gt;
::: Made sure port 3306 is open.&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #1 ==&lt;br /&gt;
&lt;br /&gt;
Because the connection ALWAYS worked on the very next try after a failure, I thought that perhaps I could arrange a sacrificial connection to feed the ravenous Connection Monster; while it was chomping on the carcass, the real Mediawiki connection might sneak by unnoticed.&lt;br /&gt;
&lt;br /&gt;
So I put this in my LocalSettings.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$servername = &amp;quot;127.0.0.1&amp;quot;;&lt;br /&gt;
$username = &amp;quot;dbuser&amp;quot;;&lt;br /&gt;
$password = &amp;quot;dbuserpassword&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Create connection&lt;br /&gt;
$conn = new mysqli($servername, $username, $password);&lt;br /&gt;
&lt;br /&gt;
// Check connection&lt;br /&gt;
if ($conn-&amp;gt;connect_error) {&lt;br /&gt;
    die(&amp;quot;Connection failed: &amp;quot; . $conn-&amp;gt;connect_error);&lt;br /&gt;
} &lt;br /&gt;
#echo &amp;quot;Connected successfully&amp;quot;;&lt;br /&gt;
mysqli_close($conn);&lt;br /&gt;
#die(&amp;quot;test finished&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This idiotic connection hasn&#039;t ever failed yet.&lt;br /&gt;
&lt;br /&gt;
And the wiki page hasn&#039;t yet failed to connect afterward, either.&lt;br /&gt;
&lt;br /&gt;
Pasta faggiole!&lt;br /&gt;
&lt;br /&gt;
I hate it.&lt;br /&gt;
&lt;br /&gt;
But not as much as I hate seeing the &amp;quot;connection failed&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Not yet, anyway.&lt;br /&gt;
&lt;br /&gt;
Using the [http://php.net/manual/en/book.hrtime.php &#039;&#039;hrtime&#039;&#039; extension,] I can see that this little connection check only takes a couple of milliseconds, so it&#039;s not costing me huge time in loading pages.  &lt;br /&gt;
&lt;br /&gt;
But I hate it.&lt;br /&gt;
&lt;br /&gt;
== It&#039;s a feature, not a bug ==&lt;br /&gt;
&lt;br /&gt;
The MediaWiki wizards know &#039;that there is something awkward in &#039;&#039;&#039;LoadBalancer.php&#039;&#039;&#039;: [https://phabricator.wikimedia.org/T72223#1673869 &amp;quot;&#039;Unknown error&#039; in LoadBalancer-&amp;gt;reportConnectionError() hides a real database problem&amp;quot; (Sep 25 2015, 9:15 AM):]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Change 157488 abandoned by Hashar:&lt;br /&gt;
Do not hide real DB error on first connect&lt;br /&gt;
&lt;br /&gt;
Reason:&lt;br /&gt;
That would cause T31233 Broken failover for DB slave connection errors.&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;&#039;&#039;The try/catch was done on purpose&#039;&#039;&#039;&#039;&#039;, see Tim comment on https://www.mediawiki.org/wiki/Special:Code/MediaWiki/90266#c20239 &lt;br /&gt;
&lt;br /&gt;
We have a task for a better fix T35036&lt;br /&gt;
&lt;br /&gt;
[https://gerrit.wikimedia.org/r/157488 Do not hide real DB error on first connect]&lt;br /&gt;
:: LoadBalancer should not silence database exception. Bug: 70223&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This is not a problem on public linux production sites, such as this one (moleski.net) and another one that I run, even though they are, like localhost, single-server sites with no database slaves to worry about.&lt;br /&gt;
&lt;br /&gt;
There is &#039;&#039;something&#039;&#039; about the Windows environment that unsettles Mediawiki&#039;s database procedures ...&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #2 ==&lt;br /&gt;
&lt;br /&gt;
I&#039;ve commented out the &amp;quot;try ... catch&amp;quot; code and replaced with with the rejected simplification suggested by Saper.  I don&#039;t care that this simplification &amp;quot;would cause T31233 Broken failover for DB slave connection errors.&amp;quot; Not my circus, not my monkeys.  I&#039;m running this code on &#039;&#039;localhost.&#039;&#039;  There are no slave connections.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# MXM Cutting out &amp;quot;ugliest thing&amp;quot; and substituting another&#039;s guy&#039;s remedy&lt;br /&gt;
#		try {&lt;br /&gt;
#			$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
#		} catch ( DBConnectionError $e ) {&lt;br /&gt;
#			// FIXME: This is probably the ugliest thing I have ever done to&lt;br /&gt;
#			// PHP. I&#039;m half-expecting it to segfault, just out of disgust. -- TS&lt;br /&gt;
#			$db = $e-&amp;gt;db;&lt;br /&gt;
#		}&lt;br /&gt;
# MXM&lt;br /&gt;
$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
# MXM&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.mail-archive.com/mediawiki-commits@lists.wikimedia.org/msg283522.html &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;MediaWiki-commits&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;Gerrit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; Add support for connect_timeout -	change (mediawiki...PoolCounter)]&lt;br /&gt;
:: The intriguing line: &#039;&#039;we implement here what we already do for mysql connections: if we set a connection timeout to a very small value (in the order of magnitude of twice the RTT to the poolcounter server) and retry twice, we can have very fast failures in case one server goes down, and the failover to the other active servers would happen almost harmlessly.&#039;&#039;  &lt;br /&gt;
:: I&#039;m convinced this is a clue, but I haven&#039;t waded into the code to see what I might be able to play with.  &lt;br /&gt;
* [http://serverfault.com/questions/408550/connecting-to-mysql-from-php-is-extremely-slow &amp;quot;Connecting to MySQL from PHP is extremely slow&amp;quot;]&lt;br /&gt;
:: David Random&#039;s essay on this page is superb.  It didn&#039;t fix what ailed me, but it made me feel that I was understanding the problem better.&lt;br /&gt;
* [https://ineed.coffee/1441/apache-php-mysql-slow-under-windows-8-how-to-fix/ &amp;quot;Apache, PHP, MySQL slow under Windows 8. How to fix.&amp;quot;]&lt;br /&gt;
:: Contains an excellent set of links to various tips and tricks, as well as making some fresh suggestions.&lt;br /&gt;
* [http://127.0.0.1/mediawiki/api.php?action=query&amp;amp;meta=siteinfo&amp;amp;siprop=statistics&amp;amp;format=jsonfm Count jobs on my localhost.]  This won&#039;t do you any good or me any harm, if I&#039;m lucky.  This is a handy spot for me to drop this link to see whether jobs have accumulated on my local wiki.  They haven&#039;t.&lt;br /&gt;
[[Category:Computers]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16399</id>
		<title>WAMP, localhost, Mediawiki: Cannot access the database</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16399"/>
		<updated>2015-12-03T01:48:09Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;or &#039;&#039;&#039;&#039;&#039;The Bug that Ate a Week of My Life!&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mediawiki on localhost ==&lt;br /&gt;
&lt;br /&gt;
Since 2:42 PM on 14 March 2009, I have run a private wiki for myself on a WAMP stack--6.5 years and counting.&lt;br /&gt;
&lt;br /&gt;
I have migrated the wiki from one desktop to another and installed it on two different laptops.&lt;br /&gt;
&lt;br /&gt;
I have never had everything work perfectly right out of the box, but I have never been frustrated for too long.  People have solved all of the basic problems more than once, and it has been just a matter of googling around long enough to debug the setup.&lt;br /&gt;
&lt;br /&gt;
All that has changed.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve found a bug that has defeated me.&lt;br /&gt;
&lt;br /&gt;
== Mediawiki 1.26, WAMPserver 2.5, and WAMPserver 3 ==&lt;br /&gt;
&lt;br /&gt;
== Error Messages ==&lt;br /&gt;
&lt;br /&gt;
=== Shorter version ===&lt;br /&gt;
&lt;br /&gt;
Sorry! This site is experiencing technical difficulties.&lt;br /&gt;
&lt;br /&gt;
Try waiting a few minutes and reloading.&lt;br /&gt;
&lt;br /&gt;
(Cannot access the database)&lt;br /&gt;
&lt;br /&gt;
=== With debugging and backtracking enabled ===&lt;br /&gt;
&lt;br /&gt;
Cannot access the database: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ())&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Backtrace:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
:  #0 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(842): &#039;&#039;&#039;DatabaseBase&#039;&#039;&#039;-&amp;gt;reportConnectionError(&#039;Unknown error (...&#039;)&lt;br /&gt;
:  #1 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(537): &#039;&#039;&#039;LoadBalancer&#039;&#039;&#039;-&amp;gt;reportConnectionError()&lt;br /&gt;
:  #2 C:\wamp\www\mediawiki\includes\GlobalFunctions.php(3631): LoadBalancer-&amp;gt;getConnection(-1, Array, false)&lt;br /&gt;
:  #3 C:\wamp\www\mediawiki\includes\User.php(1208): wfGetDB(-1)&lt;br /&gt;
:  #4 C:\wamp\www\mediawiki\includes\User.php(397): User-&amp;gt;loadFromDatabase(0)&lt;br /&gt;
:  #5 C:\wamp\www\mediawiki\includes\User.php(362): User-&amp;gt;loadFromId(0)&lt;br /&gt;
:  #6 C:\wamp\www\mediawiki\includes\User.php(2459): User-&amp;gt;load()&lt;br /&gt;
:  #7 C:\wamp\www\mediawiki\includes\User.php(1167): User-&amp;gt;getToken(false)&lt;br /&gt;
:  #8 C:\wamp\www\mediawiki\includes\User.php(365): User-&amp;gt;loadFromSession()&lt;br /&gt;
:  #9 C:\wamp\www\mediawiki\includes\User.php(2029): User-&amp;gt;load()&lt;br /&gt;
:  #10 C:\wamp\www\mediawiki\includes\User.php(3204): User-&amp;gt;getId()&lt;br /&gt;
:  #11 C:\wamp\www\mediawiki\includes\MediaWiki.php(627): User-&amp;gt;isLoggedIn()&lt;br /&gt;
:  #12 C:\wamp\www\mediawiki\includes\MediaWiki.php(476): MediaWiki-&amp;gt;main()&lt;br /&gt;
:  #13 C:\wamp\www\mediawiki\index.php(51): MediaWiki-&amp;gt;run()&lt;br /&gt;
:  #14 {main}&lt;br /&gt;
&lt;br /&gt;
:  reportConnectionError &amp;quot;Unknown error&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Failure message when MySQL is totally disabled ===&lt;br /&gt;
&lt;br /&gt;
Warning: mysqli::mysqli(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp\www\mediawiki\LocalSettings.php on line 152&lt;br /&gt;
&lt;br /&gt;
Connection failed: No connection could be made because the target machine actively refused it.&lt;br /&gt;
&lt;br /&gt;
== Not a code or configuration problem ==&lt;br /&gt;
&lt;br /&gt;
Except for a few times when I shot myself in the foot while debugging, the proof that the PHP code base and my configuration are correct is that I can immediately obtain the page I want by reloading the page.  &lt;br /&gt;
&lt;br /&gt;
It is only on the first call after a long time (five minutes? ten?) of not accessing the wiki that the problem occurs.&lt;br /&gt;
&lt;br /&gt;
== Timing is everything ==&lt;br /&gt;
&lt;br /&gt;
The most common time for the bug to bite is when I open my browser.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve got two tabs to pages on the local wiki in my collection of home pages.&lt;br /&gt;
&lt;br /&gt;
The first one usually fails if I&#039;ve had the browser closed for a while; the second never does.&lt;br /&gt;
&lt;br /&gt;
I dropped the second page from the set to see if that would help the first. &lt;br /&gt;
&lt;br /&gt;
It didn&#039;t.&lt;br /&gt;
&lt;br /&gt;
Once MySQL is awakened from its slumbers, all the links in the wiki work reasonably well--no worse than ever before--unless I spend a long time composing a page, and then the connection fails when I try to save the page.  Refresh the page, and it saves perfectly.&lt;br /&gt;
&lt;br /&gt;
Something somewhere keeps MySQL from answering the FIRST request for a connection in the time frame that Mediawiki expects.  After that, everything is normal enough until MySQL decides to fall asleep again.&lt;br /&gt;
&lt;br /&gt;
== Round up the usual suspects ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s some interaction between Windows, Apache, MySQL, and the Wikimedia routines that has got me down.&lt;br /&gt;
&lt;br /&gt;
Why can&#039;t we all just get along?&lt;br /&gt;
&lt;br /&gt;
The articles in the [[#Links|links below]] have got excellent information and links in them.  They cover pretty much everything I&#039;ve tried, and then some.  I&#039;m just going to list the failed fixes that float into mind:&lt;br /&gt;
&lt;br /&gt;
* turn off IPv6 on my machine&lt;br /&gt;
* have Apache listen only to 127.0.0.1:80&lt;br /&gt;
* bind MySQL to 127.0.0.1 &lt;br /&gt;
* turn off name resolution in MySQL&lt;br /&gt;
* change localhost to 127.0.0.1 everywhere I can to avoid DNS calls&lt;br /&gt;
* edit Hosts file to make sure localhost is defined&lt;br /&gt;
* enable opcache and install APCu&lt;br /&gt;
* turn off Zend debugger&lt;br /&gt;
* moved from WAMPserver 2.5 to 3&lt;br /&gt;
&lt;br /&gt;
Total failure, but intriguing: get MySQL to use a socket.  There are paths for it in the configuration files, but I&#039;ve never gotten it going.  I must do more googling!  It seems as though it SHOULD work.&lt;br /&gt;
&lt;br /&gt;
== Sysinfo ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
: BIOS Manufacturer: American Megatrends Inc.&lt;br /&gt;
: Release Date: 10/23/2012&lt;br /&gt;
: BIOS Version: ALASKA - 1072009&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: Board Product ID: Gigabyte 990FXA-UD3&lt;br /&gt;
&lt;br /&gt;
: AMD FX-8350 Eight-Core Processor, 4 Ghz&lt;br /&gt;
: 16 GB RAM&lt;br /&gt;
: 480 Gb SSHD&lt;br /&gt;
: 1 Tb HD&lt;br /&gt;
: 650 W power supply&lt;br /&gt;
: AMD Radeon HD 7700 with 2 Gb RAM&lt;br /&gt;
&lt;br /&gt;
Report Generated at: 1/8/2013 1:02:45 AM&lt;br /&gt;
&lt;br /&gt;
OK, so the machine is sneaking up on its third year in service.  It still gets a decent rating from me and Windows:&lt;br /&gt;
&lt;br /&gt;
[[File:Homebrew 5 performance.jpg]]&lt;br /&gt;
&lt;br /&gt;
And, as with everything else except for Wikimedia version and the WAMPserver versions, I haven&#039;t changed anything from last week, when all was well in wikiland.&lt;br /&gt;
&lt;br /&gt;
=== OS ===&lt;br /&gt;
&lt;br /&gt;
: Windows 7 Professional, 64-bit&lt;br /&gt;
: Service Pack 1&lt;br /&gt;
&lt;br /&gt;
=== Browser ===&lt;br /&gt;
&lt;br /&gt;
: Chrome 46.0.2490.86 m&lt;br /&gt;
&lt;br /&gt;
=== Software Guardians ===&lt;br /&gt;
&lt;br /&gt;
: Malware Bytes&lt;br /&gt;
::: Set to exclude 127.0.0.1, httpd.exe, and mysql.exe from inspection.&lt;br /&gt;
&lt;br /&gt;
: CylanceProtect&lt;br /&gt;
::: I&#039;ve got no control over this.  All I can say is that with MediaWiki 1.20, I had no connection problems.&lt;br /&gt;
&lt;br /&gt;
: Firewall&lt;br /&gt;
::: Made sure port 3306 is open.&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #1 ==&lt;br /&gt;
&lt;br /&gt;
Because the connection ALWAYS worked on the very next try after a failure, I thought that perhaps I could arrange a sacrificial connection to feed the ravenous Connection Monster; while it was chomping on the carcass, the real Mediawiki connection might sneak by unnoticed.&lt;br /&gt;
&lt;br /&gt;
So I put this in my LocalSettings.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$servername = &amp;quot;127.0.0.1&amp;quot;;&lt;br /&gt;
$username = &amp;quot;dbuser&amp;quot;;&lt;br /&gt;
$password = &amp;quot;dbuserpassword&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Create connection&lt;br /&gt;
$conn = new mysqli($servername, $username, $password);&lt;br /&gt;
&lt;br /&gt;
// Check connection&lt;br /&gt;
if ($conn-&amp;gt;connect_error) {&lt;br /&gt;
    die(&amp;quot;Connection failed: &amp;quot; . $conn-&amp;gt;connect_error);&lt;br /&gt;
} &lt;br /&gt;
#echo &amp;quot;Connected successfully&amp;quot;;&lt;br /&gt;
mysqli_close($conn);&lt;br /&gt;
#die(&amp;quot;test finished&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This idiotic connection hasn&#039;t ever failed yet.&lt;br /&gt;
&lt;br /&gt;
And the wiki page hasn&#039;t yet failed to connect afterward, either.&lt;br /&gt;
&lt;br /&gt;
Pasta faggiole!&lt;br /&gt;
&lt;br /&gt;
I hate it.&lt;br /&gt;
&lt;br /&gt;
But not as much as I hate seeing the &amp;quot;connection failed&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Not yet, anyway.&lt;br /&gt;
&lt;br /&gt;
Using the [http://php.net/manual/en/book.hrtime.php &#039;&#039;hrtime&#039;&#039; extension,] I can see that this little connection check only takes a couple of milliseconds, so it&#039;s not costing me huge time in loading pages.  &lt;br /&gt;
&lt;br /&gt;
But I hate it.&lt;br /&gt;
&lt;br /&gt;
== It&#039;s a feature, not a bug ==&lt;br /&gt;
&lt;br /&gt;
The MediaWiki wizards know about this.&lt;br /&gt;
&lt;br /&gt;
There is something awkward in &#039;&#039;&#039;LoadBalancer.php&#039;&#039;&#039;: [https://phabricator.wikimedia.org/T72223#1673869 &amp;quot;&#039;Unknown error&#039; in LoadBalancer-&amp;gt;reportConnectionError() hides a real database problem&amp;quot; (Sep 25 2015, 9:15 AM):]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Change 157488 abandoned by Hashar:&lt;br /&gt;
Do not hide real DB error on first connect&lt;br /&gt;
&lt;br /&gt;
Reason:&lt;br /&gt;
That would cause T31233 Broken failover for DB slave connection errors.&lt;br /&gt;
&lt;br /&gt;
The try/catch was done on purpose, see Tim comment on https://www.mediawiki.org/wiki/Special:Code/MediaWiki/90266#c20239 &lt;br /&gt;
&lt;br /&gt;
We have a task for a better fix T35036&lt;br /&gt;
&lt;br /&gt;
[https://gerrit.wikimedia.org/r/157488 Do not hide real DB error on first connect]&lt;br /&gt;
:: LoadBalancer should not silence database exception. Bug: 70223&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #2 ==&lt;br /&gt;
&lt;br /&gt;
I&#039;ve commented out the &amp;quot;try ... catch&amp;quot; code and replaced with with the rejected simplification suggested by Saper.  I don&#039;t care that this simplification &amp;quot;would cause T31233 Broken failover for DB slave connection errors.&amp;quot; Not my circus, not my monkeys.  I&#039;m running this code on &#039;&#039;localhost.&#039;&#039;  There are no slave connections.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# MXM Cutting out &amp;quot;ugliest thing&amp;quot; and substituting another&#039;s guy&#039;s remedy&lt;br /&gt;
#		try {&lt;br /&gt;
#			$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
#		} catch ( DBConnectionError $e ) {&lt;br /&gt;
#			// FIXME: This is probably the ugliest thing I have ever done to&lt;br /&gt;
#			// PHP. I&#039;m half-expecting it to segfault, just out of disgust. -- TS&lt;br /&gt;
#			$db = $e-&amp;gt;db;&lt;br /&gt;
#		}&lt;br /&gt;
# MXM&lt;br /&gt;
$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
# MXM&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.mail-archive.com/mediawiki-commits@lists.wikimedia.org/msg283522.html &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;MediaWiki-commits&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;Gerrit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; Add support for connect_timeout -	change (mediawiki...PoolCounter)]&lt;br /&gt;
:: The intriguing line: &#039;&#039;we implement here what we already do for mysql connections: if we set a connection timeout to a very small value (in the order of magnitude of twice the RTT to the poolcounter server) and retry twice, we can have very fast failures in case one server goes down, and the failover to the other active servers would happen almost harmlessly.&#039;&#039;  &lt;br /&gt;
:: I&#039;m convinced this is a clue, but I haven&#039;t waded into the code to see what I might be able to play with.  &lt;br /&gt;
* [http://serverfault.com/questions/408550/connecting-to-mysql-from-php-is-extremely-slow &amp;quot;Connecting to MySQL from PHP is extremely slow&amp;quot;]&lt;br /&gt;
:: David Random&#039;s essay on this page is superb.  It didn&#039;t fix what ailed me, but it made me feel that I was understanding the problem better.&lt;br /&gt;
* [https://ineed.coffee/1441/apache-php-mysql-slow-under-windows-8-how-to-fix/ &amp;quot;Apache, PHP, MySQL slow under Windows 8. How to fix.&amp;quot;]&lt;br /&gt;
:: Contains an excellent set of links to various tips and tricks, as well as making some fresh suggestions.&lt;br /&gt;
* [http://127.0.0.1/mediawiki/api.php?action=query&amp;amp;meta=siteinfo&amp;amp;siprop=statistics&amp;amp;format=jsonfm Count jobs on my localhost.]  This won&#039;t do you any good or me any harm, if I&#039;m lucky.  This is a handy spot for me to drop this link to see whether jobs have accumulated on my local wiki.  They haven&#039;t.&lt;br /&gt;
[[Category:Computers]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16398</id>
		<title>WAMP, localhost, Mediawiki: Cannot access the database</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16398"/>
		<updated>2015-12-03T01:47:14Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;or &#039;&#039;&#039;&#039;&#039;The Bug that Ate a Week of My Life!&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mediawiki on localhost ==&lt;br /&gt;
&lt;br /&gt;
Since 2:42 PM on 14 March 2009, I have run a private wiki for myself on a WAMP stack--6.5 years and counting.&lt;br /&gt;
&lt;br /&gt;
I have migrated the wiki from one desktop to another and installed it on two different laptops.&lt;br /&gt;
&lt;br /&gt;
I have never had everything work perfectly right out of the box, but I have never been frustrated for too long.  People have solved all of the basic problems more than once, and it has been just a matter of googling around long enough to debug the setup.&lt;br /&gt;
&lt;br /&gt;
All that has changed.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve found a bug that has defeated me.&lt;br /&gt;
&lt;br /&gt;
== Mediawiki 1.26, WAMPserver 2.5, and WAMPserver 3 ==&lt;br /&gt;
&lt;br /&gt;
== Error Messages ==&lt;br /&gt;
&lt;br /&gt;
=== Shorter version ===&lt;br /&gt;
&lt;br /&gt;
Sorry! This site is experiencing technical difficulties.&lt;br /&gt;
&lt;br /&gt;
Try waiting a few minutes and reloading.&lt;br /&gt;
&lt;br /&gt;
(Cannot access the database)&lt;br /&gt;
&lt;br /&gt;
=== With debugging and backtracking enabled ===&lt;br /&gt;
&lt;br /&gt;
Cannot access the database: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ())&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Backtrace:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
:  #0 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(842): &#039;&#039;&#039;DatabaseBase&#039;&#039;&#039;-&amp;gt;reportConnectionError(&#039;Unknown error (...&#039;)&lt;br /&gt;
:  #1 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(537): &#039;&#039;&#039;LoadBalancer&#039;&#039;&#039;-&amp;gt;reportConnectionError()&lt;br /&gt;
:  #2 C:\wamp\www\mediawiki\includes\GlobalFunctions.php(3631): LoadBalancer-&amp;gt;getConnection(-1, Array, false)&lt;br /&gt;
:  #3 C:\wamp\www\mediawiki\includes\User.php(1208): wfGetDB(-1)&lt;br /&gt;
:  #4 C:\wamp\www\mediawiki\includes\User.php(397): User-&amp;gt;loadFromDatabase(0)&lt;br /&gt;
:  #5 C:\wamp\www\mediawiki\includes\User.php(362): User-&amp;gt;loadFromId(0)&lt;br /&gt;
:  #6 C:\wamp\www\mediawiki\includes\User.php(2459): User-&amp;gt;load()&lt;br /&gt;
:  #7 C:\wamp\www\mediawiki\includes\User.php(1167): User-&amp;gt;getToken(false)&lt;br /&gt;
:  #8 C:\wamp\www\mediawiki\includes\User.php(365): User-&amp;gt;loadFromSession()&lt;br /&gt;
:  #9 C:\wamp\www\mediawiki\includes\User.php(2029): User-&amp;gt;load()&lt;br /&gt;
:  #10 C:\wamp\www\mediawiki\includes\User.php(3204): User-&amp;gt;getId()&lt;br /&gt;
:  #11 C:\wamp\www\mediawiki\includes\MediaWiki.php(627): User-&amp;gt;isLoggedIn()&lt;br /&gt;
:  #12 C:\wamp\www\mediawiki\includes\MediaWiki.php(476): MediaWiki-&amp;gt;main()&lt;br /&gt;
:  #13 C:\wamp\www\mediawiki\index.php(51): MediaWiki-&amp;gt;run()&lt;br /&gt;
:  #14 {main}&lt;br /&gt;
&lt;br /&gt;
:  reportConnectionError &amp;quot;Unknown error&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Failure message when MySQL is totally disabled ===&lt;br /&gt;
&lt;br /&gt;
Warning: mysqli::mysqli(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp\www\mediawiki\LocalSettings.php on line 152&lt;br /&gt;
&lt;br /&gt;
Connection failed: No connection could be made because the target machine actively refused it.&lt;br /&gt;
&lt;br /&gt;
== Not a code or configuration problem ==&lt;br /&gt;
&lt;br /&gt;
Except for a few times when I shot myself in the foot while debugging, the proof that the PHP code base and my configuration are correct is that I can immediately obtain the page I want by reloading the page.  &lt;br /&gt;
&lt;br /&gt;
It is only on the first call after a long time (five minutes? ten?) of not accessing the wiki that the problem occurs.&lt;br /&gt;
&lt;br /&gt;
== Timing is everything ==&lt;br /&gt;
&lt;br /&gt;
The most common time for the bug to bite is when I open my browser.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve got two tabs to pages on the local wiki in my collection of home pages.&lt;br /&gt;
&lt;br /&gt;
The first one usually fails if I&#039;ve had the browser closed for a while; the second never does.&lt;br /&gt;
&lt;br /&gt;
I dropped the second page from the set to see if that would help the first. &lt;br /&gt;
&lt;br /&gt;
It didn&#039;t.&lt;br /&gt;
&lt;br /&gt;
Once MySQL is awakened from its slumbers, all the links in the wiki work reasonably well--no worse than ever before--unless I spend a long time composing a page, and then the connection fails when I try to save the page.  Refresh the page, and it saves perfectly.&lt;br /&gt;
&lt;br /&gt;
Something somewhere keeps MySQL from answering the FIRST request for a connection in the time frame that Mediawiki expects.  After that, everything is normal enough until MySQL decides to fall asleep again.&lt;br /&gt;
&lt;br /&gt;
== Round up the usual suspects ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s some interaction between Windows, Apache, MySQL, and the Wikimedia routines that has got me down.&lt;br /&gt;
&lt;br /&gt;
Why can&#039;t we all just get along?&lt;br /&gt;
&lt;br /&gt;
The articles in the [[#Links|links below]] have got excellent information and links in them.  They cover pretty much everything I&#039;ve tried, and then some.  I&#039;m just going to list the failed fixes that float into mind:&lt;br /&gt;
&lt;br /&gt;
* turn off IPv6 on my machine&lt;br /&gt;
* have Apache listen only to 127.0.0.1:80&lt;br /&gt;
* bind MySQL to 127.0.0.1 &lt;br /&gt;
* turn off name resolution in MySQL&lt;br /&gt;
* change localhost to 127.0.0.1 everywhere I can to avoid DNS calls&lt;br /&gt;
* edit Hosts file to make sure localhost is defined&lt;br /&gt;
* enable opcache and install APCu&lt;br /&gt;
* turn off Zend debugger&lt;br /&gt;
* moved from WAMPserver 2.5 to 3&lt;br /&gt;
&lt;br /&gt;
Total failure, but intriguing: get MySQL to use a socket.  There are paths for it in the configuration files, but I&#039;ve never gotten it going.  I must do more googling!  It seems as though it SHOULD work.&lt;br /&gt;
&lt;br /&gt;
== Sysinfo ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
: BIOS Manufacturer: American Megatrends Inc.&lt;br /&gt;
: Release Date: 10/23/2012&lt;br /&gt;
: BIOS Version: ALASKA - 1072009&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: Board Product ID: Gigabyte 990FXA-UD3&lt;br /&gt;
&lt;br /&gt;
: AMD FX-8350 Eight-Core Processor, 4 Ghz&lt;br /&gt;
: 16 GB RAM&lt;br /&gt;
: 480 Gb SSHD&lt;br /&gt;
: 1 Tb HD&lt;br /&gt;
: 650 W power supply&lt;br /&gt;
: AMD Radeon HD 7700 with 2 Gb RAM&lt;br /&gt;
&lt;br /&gt;
Report Generated at: 1/8/2013 1:02:45 AM&lt;br /&gt;
&lt;br /&gt;
OK, so the machine is sneaking up on its third year in service.  It still gets a decent rating from me and Windows:&lt;br /&gt;
&lt;br /&gt;
[[File:Homebrew 5 performance.jpg]]&lt;br /&gt;
&lt;br /&gt;
And, as with everything else except for Wikimedia version and the WAMPserver versions, I haven&#039;t changed anything from last week, when all was well in wikiland.&lt;br /&gt;
&lt;br /&gt;
=== OS ===&lt;br /&gt;
&lt;br /&gt;
: Windows 7 Professional, 64-bit&lt;br /&gt;
: Service Pack 1&lt;br /&gt;
&lt;br /&gt;
=== Browser ===&lt;br /&gt;
&lt;br /&gt;
: Chrome 46.0.2490.86 m&lt;br /&gt;
&lt;br /&gt;
=== Software Guardians ===&lt;br /&gt;
&lt;br /&gt;
: Malware Bytes&lt;br /&gt;
::: Set to exclude 127.0.0.1, httpd.exe, and mysql.exe from inspection.&lt;br /&gt;
&lt;br /&gt;
: CylanceProtect&lt;br /&gt;
::: I&#039;ve got no control over this.  All I can say is that with MediaWiki 1.20, I had no connection problems.&lt;br /&gt;
&lt;br /&gt;
: Firewall&lt;br /&gt;
::: Made sure port 3306 is open.&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #1 ==&lt;br /&gt;
&lt;br /&gt;
Because the connection ALWAYS worked on the very next try after a failure, I thought that perhaps I could arrange a sacrificial connection to feed the ravenous Connection Monster; while it was chomping on the carcass, the real Mediawiki connection might sneak by unnoticed.&lt;br /&gt;
&lt;br /&gt;
So I put this in my LocalSettings.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$servername = &amp;quot;127.0.0.1&amp;quot;;&lt;br /&gt;
$username = &amp;quot;dbuser&amp;quot;;&lt;br /&gt;
$password = &amp;quot;dbuserpassword&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Create connection&lt;br /&gt;
$conn = new mysqli($servername, $username, $password);&lt;br /&gt;
&lt;br /&gt;
// Check connection&lt;br /&gt;
if ($conn-&amp;gt;connect_error) {&lt;br /&gt;
    die(&amp;quot;Connection failed: &amp;quot; . $conn-&amp;gt;connect_error);&lt;br /&gt;
} &lt;br /&gt;
#echo &amp;quot;Connected successfully&amp;quot;;&lt;br /&gt;
mysqli_close($conn);&lt;br /&gt;
#die(&amp;quot;test finished&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This idiotic connection hasn&#039;t ever failed yet.&lt;br /&gt;
&lt;br /&gt;
And the wiki page hasn&#039;t yet failed to connect afterward, either.&lt;br /&gt;
&lt;br /&gt;
Pasta faggiole!&lt;br /&gt;
&lt;br /&gt;
I hate it.&lt;br /&gt;
&lt;br /&gt;
But not as much as I hate seeing the &amp;quot;connection failed&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Not yet, anyway.&lt;br /&gt;
&lt;br /&gt;
Using the [http://php.net/manual/en/book.hrtime.php &#039;&#039;hrtime&#039;&#039; extension,] I can see that this little connection check only takes a couple of milliseconds, so it&#039;s not costing me huge time in loading pages.  &lt;br /&gt;
&lt;br /&gt;
But I hate it.&lt;br /&gt;
&lt;br /&gt;
== It&#039;s a feature, not a bug ==&lt;br /&gt;
&lt;br /&gt;
The MediaWiki wizards know about this.&lt;br /&gt;
&lt;br /&gt;
There is something awkward in &#039;&#039;&#039;LoadBalancer.php&#039;&#039;&#039;: [https://phabricator.wikimedia.org/T72223#1673869 &amp;quot;&#039;Unknown error&#039; in LoadBalancer-&amp;gt;reportConnectionError() hides a real database problem&amp;quot; (Sep 25 2015, 9:15 AM):]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Change 157488 abandoned by Hashar:&lt;br /&gt;
Do not hide real DB error on first connect&lt;br /&gt;
&lt;br /&gt;
Reason:&lt;br /&gt;
That would cause T31233 Broken failover for DB slave connection errors.&lt;br /&gt;
&lt;br /&gt;
The try/catch was done on purpose, see Tim comment on https://www.mediawiki.org/wiki/Special:Code/MediaWiki/90266#c20239 &lt;br /&gt;
&lt;br /&gt;
We have a task for a better fix T35036&lt;br /&gt;
&lt;br /&gt;
[https://gerrit.wikimedia.org/r/157488 Do not hide real DB error on first connect]&lt;br /&gt;
:: LoadBalancer should not silence database exception. Bug: 70223&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #2 ==&lt;br /&gt;
&lt;br /&gt;
I&#039;ve commented out the &amp;quot;try ... catch&amp;quot; code and replaced with with the rejected simplification suggested by Saper.  I don&#039;t care that this simplification &amp;quot;would cause T31233 Broken failover for DB slave connection errors.&amp;quot; Not my circus, not my monkeys.  I&#039;m running this code on &#039;&#039;localhost.&#039;&#039;  There are no slave connections.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# MXM Cutting out &amp;quot;ugliest thing&amp;quot; and substituting another&#039;s guy&#039;s remedy&lt;br /&gt;
#		try {&lt;br /&gt;
#			$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
#		} catch ( DBConnectionError $e ) {&lt;br /&gt;
#			// FIXME: This is probably the ugliest thing I have ever done to&lt;br /&gt;
#			// PHP. I&#039;m half-expecting it to segfault, just out of disgust. -- TS&lt;br /&gt;
#			$db = $e-&amp;gt;db;&lt;br /&gt;
#		}&lt;br /&gt;
# MXM&lt;br /&gt;
$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
# MXM&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.mail-archive.com/mediawiki-commits@lists.wikimedia.org/msg283522.html &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;MediaWiki-commits&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;Gerrit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; Add support for connect_timeout -	change (mediawiki...PoolCounter)]&lt;br /&gt;
:: The intriguing line: &#039;&#039;we implement here what we already do for mysql connections: if we set a connection timeout to a very small value (in the order of magnitude of twice the RTT to the poolcounter server) and retry twice, we can have very fast failures in case one server goes down, and the failover to the other active servers would happen almost harmlessly.&#039;&#039;  &lt;br /&gt;
:: I&#039;m convinced this is a clue, but I haven&#039;t waded into the code to see what I might be able to play with.  &lt;br /&gt;
* [http://serverfault.com/questions/408550/connecting-to-mysql-from-php-is-extremely-slow &amp;quot;Connecting to MySQL from PHP is extremely slow&amp;quot;]&lt;br /&gt;
:: David Random&#039;s essay on this page is superb.  It didn&#039;t fix what ailed me, but it made me feel that I was understanding the problem better.&lt;br /&gt;
* [https://ineed.coffee/1441/apache-php-mysql-slow-under-windows-8-how-to-fix/ &amp;quot;Apache, PHP, MySQL slow under Windows 8. How to fix.&amp;quot;]&lt;br /&gt;
:: Contains an excellent set of links to various tips and tricks, as well as making some fresh suggestions.&lt;br /&gt;
* [http://127.0.0.1/mediawiki/api.php?action=query&amp;amp;meta=siteinfo&amp;amp;siprop=statistics&amp;amp;format=jsonfm Count jobs on my localhost.]  This won&#039;t do you any good or me any harm, if I&#039;m lucky.&lt;br /&gt;
[[Category:Computers]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16397</id>
		<title>WAMP, localhost, Mediawiki: Cannot access the database</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16397"/>
		<updated>2015-12-03T01:46:54Z</updated>

		<summary type="html">&lt;p&gt;Laura: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;or &#039;&#039;&#039;&#039;&#039;The Bug that Ate a Week of My Life!&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mediawiki on localhost ==&lt;br /&gt;
&lt;br /&gt;
Since 2:42 PM on 14 March 2009, I have run a private wiki for myself on a WAMP stack--6.5 years and counting.&lt;br /&gt;
&lt;br /&gt;
I have migrated the wiki from one desktop to another and installed it on two different laptops.&lt;br /&gt;
&lt;br /&gt;
I have never had everything work perfectly right out of the box, but I have never been frustrated for too long.  People have solved all of the basic problems more than once, and it has been just a matter of googling around long enough to debug the setup.&lt;br /&gt;
&lt;br /&gt;
All that has changed.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve found a bug that has defeated me.&lt;br /&gt;
&lt;br /&gt;
== Mediawiki 1.26, WAMPserver 2.5, and WAMPserver 3 ==&lt;br /&gt;
&lt;br /&gt;
== Error Messages ==&lt;br /&gt;
&lt;br /&gt;
=== Shorter version ===&lt;br /&gt;
&lt;br /&gt;
Sorry! This site is experiencing technical difficulties.&lt;br /&gt;
&lt;br /&gt;
Try waiting a few minutes and reloading.&lt;br /&gt;
&lt;br /&gt;
(Cannot access the database)&lt;br /&gt;
&lt;br /&gt;
=== With debugging and backtracking enabled ===&lt;br /&gt;
&lt;br /&gt;
Cannot access the database: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ())&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Backtrace:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
:  #0 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(842): &#039;&#039;&#039;DatabaseBase&#039;&#039;&#039;-&amp;gt;reportConnectionError(&#039;Unknown error (...&#039;)&lt;br /&gt;
:  #1 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(537): &#039;&#039;&#039;LoadBalancer&#039;&#039;&#039;-&amp;gt;reportConnectionError()&lt;br /&gt;
:  #2 C:\wamp\www\mediawiki\includes\GlobalFunctions.php(3631): LoadBalancer-&amp;gt;getConnection(-1, Array, false)&lt;br /&gt;
:  #3 C:\wamp\www\mediawiki\includes\User.php(1208): wfGetDB(-1)&lt;br /&gt;
:  #4 C:\wamp\www\mediawiki\includes\User.php(397): User-&amp;gt;loadFromDatabase(0)&lt;br /&gt;
:  #5 C:\wamp\www\mediawiki\includes\User.php(362): User-&amp;gt;loadFromId(0)&lt;br /&gt;
:  #6 C:\wamp\www\mediawiki\includes\User.php(2459): User-&amp;gt;load()&lt;br /&gt;
:  #7 C:\wamp\www\mediawiki\includes\User.php(1167): User-&amp;gt;getToken(false)&lt;br /&gt;
:  #8 C:\wamp\www\mediawiki\includes\User.php(365): User-&amp;gt;loadFromSession()&lt;br /&gt;
:  #9 C:\wamp\www\mediawiki\includes\User.php(2029): User-&amp;gt;load()&lt;br /&gt;
:  #10 C:\wamp\www\mediawiki\includes\User.php(3204): User-&amp;gt;getId()&lt;br /&gt;
:  #11 C:\wamp\www\mediawiki\includes\MediaWiki.php(627): User-&amp;gt;isLoggedIn()&lt;br /&gt;
:  #12 C:\wamp\www\mediawiki\includes\MediaWiki.php(476): MediaWiki-&amp;gt;main()&lt;br /&gt;
:  #13 C:\wamp\www\mediawiki\index.php(51): MediaWiki-&amp;gt;run()&lt;br /&gt;
:  #14 {main}&lt;br /&gt;
&lt;br /&gt;
:  reportConnectionError &amp;quot;Unknown error&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Failure message when MySQL is totally disabled ===&lt;br /&gt;
&lt;br /&gt;
Warning: mysqli::mysqli(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp\www\mediawiki\LocalSettings.php on line 152&lt;br /&gt;
&lt;br /&gt;
Connection failed: No connection could be made because the target machine actively refused it.&lt;br /&gt;
&lt;br /&gt;
== Not a code or configuration problem ==&lt;br /&gt;
&lt;br /&gt;
Except for a few times when I shot myself in the foot while debugging, the proof that the PHP code base and my configuration are correct is that I can immediately obtain the page I want by reloading the page.  &lt;br /&gt;
&lt;br /&gt;
It is only on the first call after a long time (five minutes? ten?) of not accessing the wiki that the problem occurs.&lt;br /&gt;
&lt;br /&gt;
== Timing is everything ==&lt;br /&gt;
&lt;br /&gt;
The most common time for the bug to bite is when I open my browser.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve got two tabs to pages on the local wiki in my collection of home pages.&lt;br /&gt;
&lt;br /&gt;
The first one usually fails if I&#039;ve had the browser closed for a while; the second never does.&lt;br /&gt;
&lt;br /&gt;
I dropped the second page from the set to see if that would help the first. &lt;br /&gt;
&lt;br /&gt;
It didn&#039;t.&lt;br /&gt;
&lt;br /&gt;
Once MySQL is awakened from its slumbers, all the links in the wiki work reasonably well--no worse than ever before--unless I spend a long time composing a page, and then the connection fails when I try to save the page.  Refresh the page, and it saves perfectly.&lt;br /&gt;
&lt;br /&gt;
Something somewhere keeps MySQL from answering the FIRST request for a connection in the time frame that Mediawiki expects.  After that, everything is normal enough until MySQL decides to fall asleep again.&lt;br /&gt;
&lt;br /&gt;
== Round up the usual suspects ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s some interaction between Windows, Apache, MySQL, and the Wikimedia routines that has got me down.&lt;br /&gt;
&lt;br /&gt;
Why can&#039;t we all just get along?&lt;br /&gt;
&lt;br /&gt;
The articles in the [[#Links|links below]] have got excellent information and links in them.  They cover pretty much everything I&#039;ve tried, and then some.  I&#039;m just going to list the failed fixes that float into mind:&lt;br /&gt;
&lt;br /&gt;
* turn off IPv6 on my machine&lt;br /&gt;
* have Apache listen only to 127.0.0.1:80&lt;br /&gt;
* bind MySQL to 127.0.0.1 &lt;br /&gt;
* turn off name resolution in MySQL&lt;br /&gt;
* change localhost to 127.0.0.1 everywhere I can to avoid DNS calls&lt;br /&gt;
* edit Hosts file to make sure localhost is defined&lt;br /&gt;
* enable opcache and install APCu&lt;br /&gt;
* turn off Zend debugger&lt;br /&gt;
* moved from WAMPserver 2.5 to 3&lt;br /&gt;
&lt;br /&gt;
Total failure, but intriguing: get MySQL to use a socket.  There are paths for it in the configuration files, but I&#039;ve never gotten it going.  I must do more googling!  It seems as though it SHOULD work.&lt;br /&gt;
&lt;br /&gt;
== Sysinfo ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
: BIOS Manufacturer: American Megatrends Inc.&lt;br /&gt;
: Release Date: 10/23/2012&lt;br /&gt;
: BIOS Version: ALASKA - 1072009&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: Board Product ID: Gigabyte 990FXA-UD3&lt;br /&gt;
&lt;br /&gt;
: AMD FX-8350 Eight-Core Processor, 4 Ghz&lt;br /&gt;
: 16 GB RAM&lt;br /&gt;
: 480 Gb SSHD&lt;br /&gt;
: 1 Tb HD&lt;br /&gt;
: 650 W power supply&lt;br /&gt;
: AMD Radeon HD 7700 with 2 Gb RAM&lt;br /&gt;
&lt;br /&gt;
Report Generated at: 1/8/2013 1:02:45 AM&lt;br /&gt;
&lt;br /&gt;
OK, so the machine is sneaking up on its third year in service.  It still gets a decent rating from me and Windows:&lt;br /&gt;
&lt;br /&gt;
[[File:Homebrew 5 performance.jpg]]&lt;br /&gt;
&lt;br /&gt;
And, as with everything else except for Wikimedia version and the WAMPserver versions, I haven&#039;t changed anything from last week, when all was well in wikiland.&lt;br /&gt;
&lt;br /&gt;
=== OS ===&lt;br /&gt;
&lt;br /&gt;
: Windows 7 Professional, 64-bit&lt;br /&gt;
: Service Pack 1&lt;br /&gt;
&lt;br /&gt;
=== Browser ===&lt;br /&gt;
&lt;br /&gt;
: Chrome 46.0.2490.86 m&lt;br /&gt;
&lt;br /&gt;
=== Software Guardians ===&lt;br /&gt;
&lt;br /&gt;
: Malware Bytes&lt;br /&gt;
::: Set to exclude 127.0.0.1, httpd.exe, and mysql.exe from inspection.&lt;br /&gt;
&lt;br /&gt;
: CylanceProtect&lt;br /&gt;
::: I&#039;ve got no control over this.  All I can say is that with MediaWiki 1.20, I had no connection problems.&lt;br /&gt;
&lt;br /&gt;
: Firewall&lt;br /&gt;
::: Made sure port 3306 is open.&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #1 ==&lt;br /&gt;
&lt;br /&gt;
Because the connection ALWAYS worked on the very next try after a failure, I thought that perhaps I could arrange a sacrificial connection to feed the ravenous Connection Monster; while it was chomping on the carcass, the real Mediawiki connection might sneak by unnoticed.&lt;br /&gt;
&lt;br /&gt;
So I put this in my LocalSettings.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$servername = &amp;quot;127.0.0.1&amp;quot;;&lt;br /&gt;
$username = &amp;quot;dbuser&amp;quot;;&lt;br /&gt;
$password = &amp;quot;dbuserpassword&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Create connection&lt;br /&gt;
$conn = new mysqli($servername, $username, $password);&lt;br /&gt;
&lt;br /&gt;
// Check connection&lt;br /&gt;
if ($conn-&amp;gt;connect_error) {&lt;br /&gt;
    die(&amp;quot;Connection failed: &amp;quot; . $conn-&amp;gt;connect_error);&lt;br /&gt;
} &lt;br /&gt;
#echo &amp;quot;Connected successfully&amp;quot;;&lt;br /&gt;
mysqli_close($conn);&lt;br /&gt;
#die(&amp;quot;test finished&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This idiotic connection hasn&#039;t ever failed yet.&lt;br /&gt;
&lt;br /&gt;
And the wiki page hasn&#039;t yet failed to connect afterward, either.&lt;br /&gt;
&lt;br /&gt;
Pasta faggiole!&lt;br /&gt;
&lt;br /&gt;
I hate it.&lt;br /&gt;
&lt;br /&gt;
But not as much as I hate seeing the &amp;quot;connection failed&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Not yet, anyway.&lt;br /&gt;
&lt;br /&gt;
Using the [http://php.net/manual/en/book.hrtime.php &#039;&#039;hrtime&#039;&#039; extension,] I can see that this little connection check only takes a couple of milliseconds, so it&#039;s not costing me huge time in loading pages.  &lt;br /&gt;
&lt;br /&gt;
But I hate it.&lt;br /&gt;
&lt;br /&gt;
== It&#039;s a feature, not a bug ==&lt;br /&gt;
&lt;br /&gt;
The MediaWiki wizards know about this.&lt;br /&gt;
&lt;br /&gt;
There is something awkward in &#039;&#039;&#039;LoadBalancer.php&#039;&#039;&#039;: [https://phabricator.wikimedia.org/T72223#1673869 &amp;quot;&#039;Unknown error&#039; in LoadBalancer-&amp;gt;reportConnectionError() hides a real database problem&amp;quot; (Sep 25 2015, 9:15 AM):]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Change 157488 abandoned by Hashar:&lt;br /&gt;
Do not hide real DB error on first connect&lt;br /&gt;
&lt;br /&gt;
Reason:&lt;br /&gt;
That would cause T31233 Broken failover for DB slave connection errors.&lt;br /&gt;
&lt;br /&gt;
The try/catch was done on purpose, see Tim comment on https://www.mediawiki.org/wiki/Special:Code/MediaWiki/90266#c20239 &lt;br /&gt;
&lt;br /&gt;
We have a task for a better fix T35036&lt;br /&gt;
&lt;br /&gt;
[https://gerrit.wikimedia.org/r/157488 Do not hide real DB error on first connect]&lt;br /&gt;
:: LoadBalancer should not silence database exception. Bug: 70223&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #2 ==&lt;br /&gt;
&lt;br /&gt;
I&#039;ve commented out the &amp;quot;try ... catch&amp;quot; code and replaced with with the rejected simplification suggested by Saper.  I don&#039;t care that this simplification &amp;quot;would cause T31233 Broken failover for DB slave connection errors.&amp;quot; Not my circus, not my monkeys.  I&#039;m running this code on &#039;&#039;localhost.&#039;&#039;  There are no slave connections.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# MXM Cutting out &amp;quot;ugliest thing&amp;quot; and substituting another&#039;s guy&#039;s remedy&lt;br /&gt;
#		try {&lt;br /&gt;
#			$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
#		} catch ( DBConnectionError $e ) {&lt;br /&gt;
#			// FIXME: This is probably the ugliest thing I have ever done to&lt;br /&gt;
#			// PHP. I&#039;m half-expecting it to segfault, just out of disgust. -- TS&lt;br /&gt;
#			$db = $e-&amp;gt;db;&lt;br /&gt;
#		}&lt;br /&gt;
# MXM&lt;br /&gt;
$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
# MXM&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.mail-archive.com/mediawiki-commits@lists.wikimedia.org/msg283522.html &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;MediaWiki-commits&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;Gerrit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; Add support for connect_timeout -	change (mediawiki...PoolCounter)]&lt;br /&gt;
:: The intriguing line: &#039;&#039;we implement here what we already do for mysql connections: if we set a connection timeout to a very small value (in the order of magnitude of twice the RTT to the poolcounter server) and retry twice, we can have very fast failures in case one server goes down, and the failover to the other active servers would happen almost harmlessly.&#039;&#039;  &lt;br /&gt;
:: I&#039;m convinced this is a clue, but I haven&#039;t waded into the code to see what I might be able to play with.  &lt;br /&gt;
* [http://serverfault.com/questions/408550/connecting-to-mysql-from-php-is-extremely-slow &amp;quot;Connecting to MySQL from PHP is extremely slow&amp;quot;]&lt;br /&gt;
:: David Random&#039;s essay on this page is superb.  It didn&#039;t fix what ailed me, but it made me feel that I was understanding the problem better.&lt;br /&gt;
* [https://ineed.coffee/1441/apache-php-mysql-slow-under-windows-8-how-to-fix/ &amp;quot;Apache, PHP, MySQL slow under Windows 8. How to fix.&amp;quot;]&lt;br /&gt;
:: Contains an excellent set of links to various tips and tricks, as well as making some fresh suggestions.&lt;br /&gt;
* [http://127.0.0.1/mediawiki/api.php?action=query&amp;amp;meta=siteinfo&amp;amp;siprop=statistics&amp;amp;format=jsonfm Count jobs on my localhost.  This won&#039;t do you any good or me any harm, if I&#039;m lucky.]&lt;br /&gt;
[[Category:Computers]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16396</id>
		<title>WAMP, localhost, Mediawiki: Cannot access the database</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16396"/>
		<updated>2015-12-03T01:24:26Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* It&amp;#039;s a feature, not a bug */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;or &#039;&#039;&#039;&#039;&#039;The Bug that Ate a Week of My Life!&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mediawiki on localhost ==&lt;br /&gt;
&lt;br /&gt;
Since 2:42 PM on 14 March 2009, I have run a private wiki for myself on a WAMP stack--6.5 years and counting.&lt;br /&gt;
&lt;br /&gt;
I have migrated the wiki from one desktop to another and installed it on two different laptops.&lt;br /&gt;
&lt;br /&gt;
I have never had everything work perfectly right out of the box, but I have never been frustrated for too long.  People have solved all of the basic problems more than once, and it has been just a matter of googling around long enough to debug the setup.&lt;br /&gt;
&lt;br /&gt;
All that has changed.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve found a bug that has defeated me.&lt;br /&gt;
&lt;br /&gt;
== Mediawiki 1.26, WAMPserver 2.5, and WAMPserver 3 ==&lt;br /&gt;
&lt;br /&gt;
== Error Messages ==&lt;br /&gt;
&lt;br /&gt;
=== Shorter version ===&lt;br /&gt;
&lt;br /&gt;
Sorry! This site is experiencing technical difficulties.&lt;br /&gt;
&lt;br /&gt;
Try waiting a few minutes and reloading.&lt;br /&gt;
&lt;br /&gt;
(Cannot access the database)&lt;br /&gt;
&lt;br /&gt;
=== With debugging and backtracking enabled ===&lt;br /&gt;
&lt;br /&gt;
Cannot access the database: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ())&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Backtrace:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
:  #0 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(842): &#039;&#039;&#039;DatabaseBase&#039;&#039;&#039;-&amp;gt;reportConnectionError(&#039;Unknown error (...&#039;)&lt;br /&gt;
:  #1 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(537): &#039;&#039;&#039;LoadBalancer&#039;&#039;&#039;-&amp;gt;reportConnectionError()&lt;br /&gt;
:  #2 C:\wamp\www\mediawiki\includes\GlobalFunctions.php(3631): LoadBalancer-&amp;gt;getConnection(-1, Array, false)&lt;br /&gt;
:  #3 C:\wamp\www\mediawiki\includes\User.php(1208): wfGetDB(-1)&lt;br /&gt;
:  #4 C:\wamp\www\mediawiki\includes\User.php(397): User-&amp;gt;loadFromDatabase(0)&lt;br /&gt;
:  #5 C:\wamp\www\mediawiki\includes\User.php(362): User-&amp;gt;loadFromId(0)&lt;br /&gt;
:  #6 C:\wamp\www\mediawiki\includes\User.php(2459): User-&amp;gt;load()&lt;br /&gt;
:  #7 C:\wamp\www\mediawiki\includes\User.php(1167): User-&amp;gt;getToken(false)&lt;br /&gt;
:  #8 C:\wamp\www\mediawiki\includes\User.php(365): User-&amp;gt;loadFromSession()&lt;br /&gt;
:  #9 C:\wamp\www\mediawiki\includes\User.php(2029): User-&amp;gt;load()&lt;br /&gt;
:  #10 C:\wamp\www\mediawiki\includes\User.php(3204): User-&amp;gt;getId()&lt;br /&gt;
:  #11 C:\wamp\www\mediawiki\includes\MediaWiki.php(627): User-&amp;gt;isLoggedIn()&lt;br /&gt;
:  #12 C:\wamp\www\mediawiki\includes\MediaWiki.php(476): MediaWiki-&amp;gt;main()&lt;br /&gt;
:  #13 C:\wamp\www\mediawiki\index.php(51): MediaWiki-&amp;gt;run()&lt;br /&gt;
:  #14 {main}&lt;br /&gt;
&lt;br /&gt;
:  reportConnectionError &amp;quot;Unknown error&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Failure message when MySQL is totally disabled ===&lt;br /&gt;
&lt;br /&gt;
Warning: mysqli::mysqli(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp\www\mediawiki\LocalSettings.php on line 152&lt;br /&gt;
&lt;br /&gt;
Connection failed: No connection could be made because the target machine actively refused it.&lt;br /&gt;
&lt;br /&gt;
== Not a code or configuration problem ==&lt;br /&gt;
&lt;br /&gt;
Except for a few times when I shot myself in the foot while debugging, the proof that the PHP code base and my configuration are correct is that I can immediately obtain the page I want by reloading the page.  &lt;br /&gt;
&lt;br /&gt;
It is only on the first call after a long time (five minutes? ten?) of not accessing the wiki that the problem occurs.&lt;br /&gt;
&lt;br /&gt;
== Timing is everything ==&lt;br /&gt;
&lt;br /&gt;
The most common time for the bug to bite is when I open my browser.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve got two tabs to pages on the local wiki in my collection of home pages.&lt;br /&gt;
&lt;br /&gt;
The first one usually fails if I&#039;ve had the browser closed for a while; the second never does.&lt;br /&gt;
&lt;br /&gt;
I dropped the second page from the set to see if that would help the first. &lt;br /&gt;
&lt;br /&gt;
It didn&#039;t.&lt;br /&gt;
&lt;br /&gt;
Once MySQL is awakened from its slumbers, all the links in the wiki work reasonably well--no worse than ever before--unless I spend a long time composing a page, and then the connection fails when I try to save the page.  Refresh the page, and it saves perfectly.&lt;br /&gt;
&lt;br /&gt;
Something somewhere keeps MySQL from answering the FIRST request for a connection in the time frame that Mediawiki expects.  After that, everything is normal enough until MySQL decides to fall asleep again.&lt;br /&gt;
&lt;br /&gt;
== Round up the usual suspects ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s some interaction between Windows, Apache, MySQL, and the Wikimedia routines that has got me down.&lt;br /&gt;
&lt;br /&gt;
Why can&#039;t we all just get along?&lt;br /&gt;
&lt;br /&gt;
The articles in the [[#Links|links below]] have got excellent information and links in them.  They cover pretty much everything I&#039;ve tried, and then some.  I&#039;m just going to list the failed fixes that float into mind:&lt;br /&gt;
&lt;br /&gt;
* turn off IPv6 on my machine&lt;br /&gt;
* have Apache listen only to 127.0.0.1:80&lt;br /&gt;
* bind MySQL to 127.0.0.1 &lt;br /&gt;
* turn off name resolution in MySQL&lt;br /&gt;
* change localhost to 127.0.0.1 everywhere I can to avoid DNS calls&lt;br /&gt;
* edit Hosts file to make sure localhost is defined&lt;br /&gt;
* enable opcache and install APCu&lt;br /&gt;
* turn off Zend debugger&lt;br /&gt;
* moved from WAMPserver 2.5 to 3&lt;br /&gt;
&lt;br /&gt;
Total failure, but intriguing: get MySQL to use a socket.  There are paths for it in the configuration files, but I&#039;ve never gotten it going.  I must do more googling!  It seems as though it SHOULD work.&lt;br /&gt;
&lt;br /&gt;
== Sysinfo ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
: BIOS Manufacturer: American Megatrends Inc.&lt;br /&gt;
: Release Date: 10/23/2012&lt;br /&gt;
: BIOS Version: ALASKA - 1072009&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: Board Product ID: Gigabyte 990FXA-UD3&lt;br /&gt;
&lt;br /&gt;
: AMD FX-8350 Eight-Core Processor, 4 Ghz&lt;br /&gt;
: 16 GB RAM&lt;br /&gt;
: 480 Gb SSHD&lt;br /&gt;
: 1 Tb HD&lt;br /&gt;
: 650 W power supply&lt;br /&gt;
: AMD Radeon HD 7700 with 2 Gb RAM&lt;br /&gt;
&lt;br /&gt;
Report Generated at: 1/8/2013 1:02:45 AM&lt;br /&gt;
&lt;br /&gt;
OK, so the machine is sneaking up on its third year in service.  It still gets a decent rating from me and Windows:&lt;br /&gt;
&lt;br /&gt;
[[File:Homebrew 5 performance.jpg]]&lt;br /&gt;
&lt;br /&gt;
And, as with everything else except for Wikimedia version and the WAMPserver versions, I haven&#039;t changed anything from last week, when all was well in wikiland.&lt;br /&gt;
&lt;br /&gt;
=== OS ===&lt;br /&gt;
&lt;br /&gt;
: Windows 7 Professional, 64-bit&lt;br /&gt;
: Service Pack 1&lt;br /&gt;
&lt;br /&gt;
=== Browser ===&lt;br /&gt;
&lt;br /&gt;
: Chrome 46.0.2490.86 m&lt;br /&gt;
&lt;br /&gt;
=== Software Guardians ===&lt;br /&gt;
&lt;br /&gt;
: Malware Bytes&lt;br /&gt;
::: Set to exclude 127.0.0.1, httpd.exe, and mysql.exe from inspection.&lt;br /&gt;
&lt;br /&gt;
: CylanceProtect&lt;br /&gt;
::: I&#039;ve got no control over this.  All I can say is that with MediaWiki 1.20, I had no connection problems.&lt;br /&gt;
&lt;br /&gt;
: Firewall&lt;br /&gt;
::: Made sure port 3306 is open.&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #1 ==&lt;br /&gt;
&lt;br /&gt;
Because the connection ALWAYS worked on the very next try after a failure, I thought that perhaps I could arrange a sacrificial connection to feed the ravenous Connection Monster; while it was chomping on the carcass, the real Mediawiki connection might sneak by unnoticed.&lt;br /&gt;
&lt;br /&gt;
So I put this in my LocalSettings.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$servername = &amp;quot;127.0.0.1&amp;quot;;&lt;br /&gt;
$username = &amp;quot;dbuser&amp;quot;;&lt;br /&gt;
$password = &amp;quot;dbuserpassword&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Create connection&lt;br /&gt;
$conn = new mysqli($servername, $username, $password);&lt;br /&gt;
&lt;br /&gt;
// Check connection&lt;br /&gt;
if ($conn-&amp;gt;connect_error) {&lt;br /&gt;
    die(&amp;quot;Connection failed: &amp;quot; . $conn-&amp;gt;connect_error);&lt;br /&gt;
} &lt;br /&gt;
#echo &amp;quot;Connected successfully&amp;quot;;&lt;br /&gt;
mysqli_close($conn);&lt;br /&gt;
#die(&amp;quot;test finished&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This idiotic connection hasn&#039;t ever failed yet.&lt;br /&gt;
&lt;br /&gt;
And the wiki page hasn&#039;t yet failed to connect afterward, either.&lt;br /&gt;
&lt;br /&gt;
Pasta faggiole!&lt;br /&gt;
&lt;br /&gt;
I hate it.&lt;br /&gt;
&lt;br /&gt;
But not as much as I hate seeing the &amp;quot;connection failed&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Not yet, anyway.&lt;br /&gt;
&lt;br /&gt;
Using the [http://php.net/manual/en/book.hrtime.php &#039;&#039;hrtime&#039;&#039; extension,] I can see that this little connection check only takes a couple of milliseconds, so it&#039;s not costing me huge time in loading pages.  &lt;br /&gt;
&lt;br /&gt;
But I hate it.&lt;br /&gt;
&lt;br /&gt;
== It&#039;s a feature, not a bug ==&lt;br /&gt;
&lt;br /&gt;
The MediaWiki wizards know about this.&lt;br /&gt;
&lt;br /&gt;
There is something awkward in &#039;&#039;&#039;LoadBalancer.php&#039;&#039;&#039;: [https://phabricator.wikimedia.org/T72223#1673869 &amp;quot;&#039;Unknown error&#039; in LoadBalancer-&amp;gt;reportConnectionError() hides a real database problem&amp;quot; (Sep 25 2015, 9:15 AM):]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Change 157488 abandoned by Hashar:&lt;br /&gt;
Do not hide real DB error on first connect&lt;br /&gt;
&lt;br /&gt;
Reason:&lt;br /&gt;
That would cause T31233 Broken failover for DB slave connection errors.&lt;br /&gt;
&lt;br /&gt;
The try/catch was done on purpose, see Tim comment on https://www.mediawiki.org/wiki/Special:Code/MediaWiki/90266#c20239 &lt;br /&gt;
&lt;br /&gt;
We have a task for a better fix T35036&lt;br /&gt;
&lt;br /&gt;
[https://gerrit.wikimedia.org/r/157488 Do not hide real DB error on first connect]&lt;br /&gt;
:: LoadBalancer should not silence database exception. Bug: 70223&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #2 ==&lt;br /&gt;
&lt;br /&gt;
I&#039;ve commented out the &amp;quot;try ... catch&amp;quot; code and replaced with with the rejected simplification suggested by Saper.  I don&#039;t care that this simplification &amp;quot;would cause T31233 Broken failover for DB slave connection errors.&amp;quot; Not my circus, not my monkeys.  I&#039;m running this code on &#039;&#039;localhost.&#039;&#039;  There are no slave connections.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# MXM Cutting out &amp;quot;ugliest thing&amp;quot; and substituting another&#039;s guy&#039;s remedy&lt;br /&gt;
#		try {&lt;br /&gt;
#			$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
#		} catch ( DBConnectionError $e ) {&lt;br /&gt;
#			// FIXME: This is probably the ugliest thing I have ever done to&lt;br /&gt;
#			// PHP. I&#039;m half-expecting it to segfault, just out of disgust. -- TS&lt;br /&gt;
#			$db = $e-&amp;gt;db;&lt;br /&gt;
#		}&lt;br /&gt;
# MXM&lt;br /&gt;
$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
# MXM&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.mail-archive.com/mediawiki-commits@lists.wikimedia.org/msg283522.html &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;MediaWiki-commits&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;Gerrit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; Add support for connect_timeout -	change (mediawiki...PoolCounter)]&lt;br /&gt;
:: The intriguing line: &#039;&#039;we implement here what we already do for mysql connections: if we set a connection timeout to a very small value (in the order of magnitude of twice the RTT to the poolcounter server) and retry twice, we can have very fast failures in case one server goes down, and the failover to the other active servers would happen almost harmlessly.&#039;&#039;  &lt;br /&gt;
:: I&#039;m convinced this is a clue, but I haven&#039;t waded into the code to see what I might be able to play with.  &lt;br /&gt;
* [http://serverfault.com/questions/408550/connecting-to-mysql-from-php-is-extremely-slow &amp;quot;Connecting to MySQL from PHP is extremely slow&amp;quot;]&lt;br /&gt;
:: David Random&#039;s essay on this page is superb.  It didn&#039;t fix what ailed me, but it made me feel that I was understanding the problem better.&lt;br /&gt;
* [https://ineed.coffee/1441/apache-php-mysql-slow-under-windows-8-how-to-fix/ &amp;quot;Apache, PHP, MySQL slow under Windows 8. How to fix.&amp;quot;]&lt;br /&gt;
:: Contains an excellent set of links to various tips and tricks, as well as making some fresh suggestions.&lt;br /&gt;
&lt;br /&gt;
[[Category:Computers]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16395</id>
		<title>WAMP, localhost, Mediawiki: Cannot access the database</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16395"/>
		<updated>2015-12-03T01:23:50Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* It&amp;#039;s a feature, not a bug */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;or &#039;&#039;&#039;&#039;&#039;The Bug that Ate a Week of My Life!&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mediawiki on localhost ==&lt;br /&gt;
&lt;br /&gt;
Since 2:42 PM on 14 March 2009, I have run a private wiki for myself on a WAMP stack--6.5 years and counting.&lt;br /&gt;
&lt;br /&gt;
I have migrated the wiki from one desktop to another and installed it on two different laptops.&lt;br /&gt;
&lt;br /&gt;
I have never had everything work perfectly right out of the box, but I have never been frustrated for too long.  People have solved all of the basic problems more than once, and it has been just a matter of googling around long enough to debug the setup.&lt;br /&gt;
&lt;br /&gt;
All that has changed.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve found a bug that has defeated me.&lt;br /&gt;
&lt;br /&gt;
== Mediawiki 1.26, WAMPserver 2.5, and WAMPserver 3 ==&lt;br /&gt;
&lt;br /&gt;
== Error Messages ==&lt;br /&gt;
&lt;br /&gt;
=== Shorter version ===&lt;br /&gt;
&lt;br /&gt;
Sorry! This site is experiencing technical difficulties.&lt;br /&gt;
&lt;br /&gt;
Try waiting a few minutes and reloading.&lt;br /&gt;
&lt;br /&gt;
(Cannot access the database)&lt;br /&gt;
&lt;br /&gt;
=== With debugging and backtracking enabled ===&lt;br /&gt;
&lt;br /&gt;
Cannot access the database: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ())&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Backtrace:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
:  #0 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(842): &#039;&#039;&#039;DatabaseBase&#039;&#039;&#039;-&amp;gt;reportConnectionError(&#039;Unknown error (...&#039;)&lt;br /&gt;
:  #1 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(537): &#039;&#039;&#039;LoadBalancer&#039;&#039;&#039;-&amp;gt;reportConnectionError()&lt;br /&gt;
:  #2 C:\wamp\www\mediawiki\includes\GlobalFunctions.php(3631): LoadBalancer-&amp;gt;getConnection(-1, Array, false)&lt;br /&gt;
:  #3 C:\wamp\www\mediawiki\includes\User.php(1208): wfGetDB(-1)&lt;br /&gt;
:  #4 C:\wamp\www\mediawiki\includes\User.php(397): User-&amp;gt;loadFromDatabase(0)&lt;br /&gt;
:  #5 C:\wamp\www\mediawiki\includes\User.php(362): User-&amp;gt;loadFromId(0)&lt;br /&gt;
:  #6 C:\wamp\www\mediawiki\includes\User.php(2459): User-&amp;gt;load()&lt;br /&gt;
:  #7 C:\wamp\www\mediawiki\includes\User.php(1167): User-&amp;gt;getToken(false)&lt;br /&gt;
:  #8 C:\wamp\www\mediawiki\includes\User.php(365): User-&amp;gt;loadFromSession()&lt;br /&gt;
:  #9 C:\wamp\www\mediawiki\includes\User.php(2029): User-&amp;gt;load()&lt;br /&gt;
:  #10 C:\wamp\www\mediawiki\includes\User.php(3204): User-&amp;gt;getId()&lt;br /&gt;
:  #11 C:\wamp\www\mediawiki\includes\MediaWiki.php(627): User-&amp;gt;isLoggedIn()&lt;br /&gt;
:  #12 C:\wamp\www\mediawiki\includes\MediaWiki.php(476): MediaWiki-&amp;gt;main()&lt;br /&gt;
:  #13 C:\wamp\www\mediawiki\index.php(51): MediaWiki-&amp;gt;run()&lt;br /&gt;
:  #14 {main}&lt;br /&gt;
&lt;br /&gt;
:  reportConnectionError &amp;quot;Unknown error&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Failure message when MySQL is totally disabled ===&lt;br /&gt;
&lt;br /&gt;
Warning: mysqli::mysqli(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp\www\mediawiki\LocalSettings.php on line 152&lt;br /&gt;
&lt;br /&gt;
Connection failed: No connection could be made because the target machine actively refused it.&lt;br /&gt;
&lt;br /&gt;
== Not a code or configuration problem ==&lt;br /&gt;
&lt;br /&gt;
Except for a few times when I shot myself in the foot while debugging, the proof that the PHP code base and my configuration are correct is that I can immediately obtain the page I want by reloading the page.  &lt;br /&gt;
&lt;br /&gt;
It is only on the first call after a long time (five minutes? ten?) of not accessing the wiki that the problem occurs.&lt;br /&gt;
&lt;br /&gt;
== Timing is everything ==&lt;br /&gt;
&lt;br /&gt;
The most common time for the bug to bite is when I open my browser.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve got two tabs to pages on the local wiki in my collection of home pages.&lt;br /&gt;
&lt;br /&gt;
The first one usually fails if I&#039;ve had the browser closed for a while; the second never does.&lt;br /&gt;
&lt;br /&gt;
I dropped the second page from the set to see if that would help the first. &lt;br /&gt;
&lt;br /&gt;
It didn&#039;t.&lt;br /&gt;
&lt;br /&gt;
Once MySQL is awakened from its slumbers, all the links in the wiki work reasonably well--no worse than ever before--unless I spend a long time composing a page, and then the connection fails when I try to save the page.  Refresh the page, and it saves perfectly.&lt;br /&gt;
&lt;br /&gt;
Something somewhere keeps MySQL from answering the FIRST request for a connection in the time frame that Mediawiki expects.  After that, everything is normal enough until MySQL decides to fall asleep again.&lt;br /&gt;
&lt;br /&gt;
== Round up the usual suspects ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s some interaction between Windows, Apache, MySQL, and the Wikimedia routines that has got me down.&lt;br /&gt;
&lt;br /&gt;
Why can&#039;t we all just get along?&lt;br /&gt;
&lt;br /&gt;
The articles in the [[#Links|links below]] have got excellent information and links in them.  They cover pretty much everything I&#039;ve tried, and then some.  I&#039;m just going to list the failed fixes that float into mind:&lt;br /&gt;
&lt;br /&gt;
* turn off IPv6 on my machine&lt;br /&gt;
* have Apache listen only to 127.0.0.1:80&lt;br /&gt;
* bind MySQL to 127.0.0.1 &lt;br /&gt;
* turn off name resolution in MySQL&lt;br /&gt;
* change localhost to 127.0.0.1 everywhere I can to avoid DNS calls&lt;br /&gt;
* edit Hosts file to make sure localhost is defined&lt;br /&gt;
* enable opcache and install APCu&lt;br /&gt;
* turn off Zend debugger&lt;br /&gt;
* moved from WAMPserver 2.5 to 3&lt;br /&gt;
&lt;br /&gt;
Total failure, but intriguing: get MySQL to use a socket.  There are paths for it in the configuration files, but I&#039;ve never gotten it going.  I must do more googling!  It seems as though it SHOULD work.&lt;br /&gt;
&lt;br /&gt;
== Sysinfo ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
: BIOS Manufacturer: American Megatrends Inc.&lt;br /&gt;
: Release Date: 10/23/2012&lt;br /&gt;
: BIOS Version: ALASKA - 1072009&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: Board Product ID: Gigabyte 990FXA-UD3&lt;br /&gt;
&lt;br /&gt;
: AMD FX-8350 Eight-Core Processor, 4 Ghz&lt;br /&gt;
: 16 GB RAM&lt;br /&gt;
: 480 Gb SSHD&lt;br /&gt;
: 1 Tb HD&lt;br /&gt;
: 650 W power supply&lt;br /&gt;
: AMD Radeon HD 7700 with 2 Gb RAM&lt;br /&gt;
&lt;br /&gt;
Report Generated at: 1/8/2013 1:02:45 AM&lt;br /&gt;
&lt;br /&gt;
OK, so the machine is sneaking up on its third year in service.  It still gets a decent rating from me and Windows:&lt;br /&gt;
&lt;br /&gt;
[[File:Homebrew 5 performance.jpg]]&lt;br /&gt;
&lt;br /&gt;
And, as with everything else except for Wikimedia version and the WAMPserver versions, I haven&#039;t changed anything from last week, when all was well in wikiland.&lt;br /&gt;
&lt;br /&gt;
=== OS ===&lt;br /&gt;
&lt;br /&gt;
: Windows 7 Professional, 64-bit&lt;br /&gt;
: Service Pack 1&lt;br /&gt;
&lt;br /&gt;
=== Browser ===&lt;br /&gt;
&lt;br /&gt;
: Chrome 46.0.2490.86 m&lt;br /&gt;
&lt;br /&gt;
=== Software Guardians ===&lt;br /&gt;
&lt;br /&gt;
: Malware Bytes&lt;br /&gt;
::: Set to exclude 127.0.0.1, httpd.exe, and mysql.exe from inspection.&lt;br /&gt;
&lt;br /&gt;
: CylanceProtect&lt;br /&gt;
::: I&#039;ve got no control over this.  All I can say is that with MediaWiki 1.20, I had no connection problems.&lt;br /&gt;
&lt;br /&gt;
: Firewall&lt;br /&gt;
::: Made sure port 3306 is open.&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #1 ==&lt;br /&gt;
&lt;br /&gt;
Because the connection ALWAYS worked on the very next try after a failure, I thought that perhaps I could arrange a sacrificial connection to feed the ravenous Connection Monster; while it was chomping on the carcass, the real Mediawiki connection might sneak by unnoticed.&lt;br /&gt;
&lt;br /&gt;
So I put this in my LocalSettings.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$servername = &amp;quot;127.0.0.1&amp;quot;;&lt;br /&gt;
$username = &amp;quot;dbuser&amp;quot;;&lt;br /&gt;
$password = &amp;quot;dbuserpassword&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Create connection&lt;br /&gt;
$conn = new mysqli($servername, $username, $password);&lt;br /&gt;
&lt;br /&gt;
// Check connection&lt;br /&gt;
if ($conn-&amp;gt;connect_error) {&lt;br /&gt;
    die(&amp;quot;Connection failed: &amp;quot; . $conn-&amp;gt;connect_error);&lt;br /&gt;
} &lt;br /&gt;
#echo &amp;quot;Connected successfully&amp;quot;;&lt;br /&gt;
mysqli_close($conn);&lt;br /&gt;
#die(&amp;quot;test finished&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This idiotic connection hasn&#039;t ever failed yet.&lt;br /&gt;
&lt;br /&gt;
And the wiki page hasn&#039;t yet failed to connect afterward, either.&lt;br /&gt;
&lt;br /&gt;
Pasta faggiole!&lt;br /&gt;
&lt;br /&gt;
I hate it.&lt;br /&gt;
&lt;br /&gt;
But not as much as I hate seeing the &amp;quot;connection failed&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Not yet, anyway.&lt;br /&gt;
&lt;br /&gt;
Using the [http://php.net/manual/en/book.hrtime.php &#039;&#039;hrtime&#039;&#039; extension,] I can see that this little connection check only takes a couple of milliseconds, so it&#039;s not costing me huge time in loading pages.  &lt;br /&gt;
&lt;br /&gt;
But I hate it.&lt;br /&gt;
&lt;br /&gt;
== It&#039;s a feature, not a bug ==&lt;br /&gt;
&lt;br /&gt;
The MediaWiki wizards know about this.&lt;br /&gt;
&lt;br /&gt;
There is something awkward in &#039;&#039;&#039;LoadBalancer.php&#039;&#039;&#039;: [https://phabricator.wikimedia.org/T72223#1673869 &amp;quot;&#039;Unknown error&#039; in LoadBalancer-&amp;gt;reportConnectionError() hides a real database problem&amp;quot;:]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Change 157488 abandoned by Hashar:&lt;br /&gt;
Do not hide real DB error on first connect&lt;br /&gt;
&lt;br /&gt;
Reason:&lt;br /&gt;
That would cause T31233 Broken failover for DB slave connection errors.&lt;br /&gt;
&lt;br /&gt;
The try/catch was done on purpose, see Tim comment on https://www.mediawiki.org/wiki/Special:Code/MediaWiki/90266#c20239 &lt;br /&gt;
&lt;br /&gt;
We have a task for a better fix T35036&lt;br /&gt;
&lt;br /&gt;
[https://gerrit.wikimedia.org/r/157488 Do not hide real DB error on first connect]&lt;br /&gt;
:: LoadBalancer should not silence database exception. Bug: 70223&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #2 ==&lt;br /&gt;
&lt;br /&gt;
I&#039;ve commented out the &amp;quot;try ... catch&amp;quot; code and replaced with with the rejected simplification suggested by Saper.  I don&#039;t care that this simplification &amp;quot;would cause T31233 Broken failover for DB slave connection errors.&amp;quot; Not my circus, not my monkeys.  I&#039;m running this code on &#039;&#039;localhost.&#039;&#039;  There are no slave connections.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# MXM Cutting out &amp;quot;ugliest thing&amp;quot; and substituting another&#039;s guy&#039;s remedy&lt;br /&gt;
#		try {&lt;br /&gt;
#			$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
#		} catch ( DBConnectionError $e ) {&lt;br /&gt;
#			// FIXME: This is probably the ugliest thing I have ever done to&lt;br /&gt;
#			// PHP. I&#039;m half-expecting it to segfault, just out of disgust. -- TS&lt;br /&gt;
#			$db = $e-&amp;gt;db;&lt;br /&gt;
#		}&lt;br /&gt;
# MXM&lt;br /&gt;
$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
# MXM&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.mail-archive.com/mediawiki-commits@lists.wikimedia.org/msg283522.html &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;MediaWiki-commits&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;Gerrit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; Add support for connect_timeout -	change (mediawiki...PoolCounter)]&lt;br /&gt;
:: The intriguing line: &#039;&#039;we implement here what we already do for mysql connections: if we set a connection timeout to a very small value (in the order of magnitude of twice the RTT to the poolcounter server) and retry twice, we can have very fast failures in case one server goes down, and the failover to the other active servers would happen almost harmlessly.&#039;&#039;  &lt;br /&gt;
:: I&#039;m convinced this is a clue, but I haven&#039;t waded into the code to see what I might be able to play with.  &lt;br /&gt;
* [http://serverfault.com/questions/408550/connecting-to-mysql-from-php-is-extremely-slow &amp;quot;Connecting to MySQL from PHP is extremely slow&amp;quot;]&lt;br /&gt;
:: David Random&#039;s essay on this page is superb.  It didn&#039;t fix what ailed me, but it made me feel that I was understanding the problem better.&lt;br /&gt;
* [https://ineed.coffee/1441/apache-php-mysql-slow-under-windows-8-how-to-fix/ &amp;quot;Apache, PHP, MySQL slow under Windows 8. How to fix.&amp;quot;]&lt;br /&gt;
:: Contains an excellent set of links to various tips and tricks, as well as making some fresh suggestions.&lt;br /&gt;
&lt;br /&gt;
[[Category:Computers]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16394</id>
		<title>WAMP, localhost, Mediawiki: Cannot access the database</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16394"/>
		<updated>2015-12-03T01:13:36Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* Ugly Workaround #2 */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;or &#039;&#039;&#039;&#039;&#039;The Bug that Ate a Week of My Life!&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mediawiki on localhost ==&lt;br /&gt;
&lt;br /&gt;
Since 2:42 PM on 14 March 2009, I have run a private wiki for myself on a WAMP stack--6.5 years and counting.&lt;br /&gt;
&lt;br /&gt;
I have migrated the wiki from one desktop to another and installed it on two different laptops.&lt;br /&gt;
&lt;br /&gt;
I have never had everything work perfectly right out of the box, but I have never been frustrated for too long.  People have solved all of the basic problems more than once, and it has been just a matter of googling around long enough to debug the setup.&lt;br /&gt;
&lt;br /&gt;
All that has changed.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve found a bug that has defeated me.&lt;br /&gt;
&lt;br /&gt;
== Mediawiki 1.26, WAMPserver 2.5, and WAMPserver 3 ==&lt;br /&gt;
&lt;br /&gt;
== Error Messages ==&lt;br /&gt;
&lt;br /&gt;
=== Shorter version ===&lt;br /&gt;
&lt;br /&gt;
Sorry! This site is experiencing technical difficulties.&lt;br /&gt;
&lt;br /&gt;
Try waiting a few minutes and reloading.&lt;br /&gt;
&lt;br /&gt;
(Cannot access the database)&lt;br /&gt;
&lt;br /&gt;
=== With debugging and backtracking enabled ===&lt;br /&gt;
&lt;br /&gt;
Cannot access the database: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ())&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Backtrace:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
:  #0 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(842): &#039;&#039;&#039;DatabaseBase&#039;&#039;&#039;-&amp;gt;reportConnectionError(&#039;Unknown error (...&#039;)&lt;br /&gt;
:  #1 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(537): &#039;&#039;&#039;LoadBalancer&#039;&#039;&#039;-&amp;gt;reportConnectionError()&lt;br /&gt;
:  #2 C:\wamp\www\mediawiki\includes\GlobalFunctions.php(3631): LoadBalancer-&amp;gt;getConnection(-1, Array, false)&lt;br /&gt;
:  #3 C:\wamp\www\mediawiki\includes\User.php(1208): wfGetDB(-1)&lt;br /&gt;
:  #4 C:\wamp\www\mediawiki\includes\User.php(397): User-&amp;gt;loadFromDatabase(0)&lt;br /&gt;
:  #5 C:\wamp\www\mediawiki\includes\User.php(362): User-&amp;gt;loadFromId(0)&lt;br /&gt;
:  #6 C:\wamp\www\mediawiki\includes\User.php(2459): User-&amp;gt;load()&lt;br /&gt;
:  #7 C:\wamp\www\mediawiki\includes\User.php(1167): User-&amp;gt;getToken(false)&lt;br /&gt;
:  #8 C:\wamp\www\mediawiki\includes\User.php(365): User-&amp;gt;loadFromSession()&lt;br /&gt;
:  #9 C:\wamp\www\mediawiki\includes\User.php(2029): User-&amp;gt;load()&lt;br /&gt;
:  #10 C:\wamp\www\mediawiki\includes\User.php(3204): User-&amp;gt;getId()&lt;br /&gt;
:  #11 C:\wamp\www\mediawiki\includes\MediaWiki.php(627): User-&amp;gt;isLoggedIn()&lt;br /&gt;
:  #12 C:\wamp\www\mediawiki\includes\MediaWiki.php(476): MediaWiki-&amp;gt;main()&lt;br /&gt;
:  #13 C:\wamp\www\mediawiki\index.php(51): MediaWiki-&amp;gt;run()&lt;br /&gt;
:  #14 {main}&lt;br /&gt;
&lt;br /&gt;
:  reportConnectionError &amp;quot;Unknown error&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Failure message when MySQL is totally disabled ===&lt;br /&gt;
&lt;br /&gt;
Warning: mysqli::mysqli(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp\www\mediawiki\LocalSettings.php on line 152&lt;br /&gt;
&lt;br /&gt;
Connection failed: No connection could be made because the target machine actively refused it.&lt;br /&gt;
&lt;br /&gt;
== Not a code or configuration problem ==&lt;br /&gt;
&lt;br /&gt;
Except for a few times when I shot myself in the foot while debugging, the proof that the PHP code base and my configuration are correct is that I can immediately obtain the page I want by reloading the page.  &lt;br /&gt;
&lt;br /&gt;
It is only on the first call after a long time (five minutes? ten?) of not accessing the wiki that the problem occurs.&lt;br /&gt;
&lt;br /&gt;
== Timing is everything ==&lt;br /&gt;
&lt;br /&gt;
The most common time for the bug to bite is when I open my browser.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve got two tabs to pages on the local wiki in my collection of home pages.&lt;br /&gt;
&lt;br /&gt;
The first one usually fails if I&#039;ve had the browser closed for a while; the second never does.&lt;br /&gt;
&lt;br /&gt;
I dropped the second page from the set to see if that would help the first. &lt;br /&gt;
&lt;br /&gt;
It didn&#039;t.&lt;br /&gt;
&lt;br /&gt;
Once MySQL is awakened from its slumbers, all the links in the wiki work reasonably well--no worse than ever before--unless I spend a long time composing a page, and then the connection fails when I try to save the page.  Refresh the page, and it saves perfectly.&lt;br /&gt;
&lt;br /&gt;
Something somewhere keeps MySQL from answering the FIRST request for a connection in the time frame that Mediawiki expects.  After that, everything is normal enough until MySQL decides to fall asleep again.&lt;br /&gt;
&lt;br /&gt;
== Round up the usual suspects ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s some interaction between Windows, Apache, MySQL, and the Wikimedia routines that has got me down.&lt;br /&gt;
&lt;br /&gt;
Why can&#039;t we all just get along?&lt;br /&gt;
&lt;br /&gt;
The articles in the [[#Links|links below]] have got excellent information and links in them.  They cover pretty much everything I&#039;ve tried, and then some.  I&#039;m just going to list the failed fixes that float into mind:&lt;br /&gt;
&lt;br /&gt;
* turn off IPv6 on my machine&lt;br /&gt;
* have Apache listen only to 127.0.0.1:80&lt;br /&gt;
* bind MySQL to 127.0.0.1 &lt;br /&gt;
* turn off name resolution in MySQL&lt;br /&gt;
* change localhost to 127.0.0.1 everywhere I can to avoid DNS calls&lt;br /&gt;
* edit Hosts file to make sure localhost is defined&lt;br /&gt;
* enable opcache and install APCu&lt;br /&gt;
* turn off Zend debugger&lt;br /&gt;
* moved from WAMPserver 2.5 to 3&lt;br /&gt;
&lt;br /&gt;
Total failure, but intriguing: get MySQL to use a socket.  There are paths for it in the configuration files, but I&#039;ve never gotten it going.  I must do more googling!  It seems as though it SHOULD work.&lt;br /&gt;
&lt;br /&gt;
== Sysinfo ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
: BIOS Manufacturer: American Megatrends Inc.&lt;br /&gt;
: Release Date: 10/23/2012&lt;br /&gt;
: BIOS Version: ALASKA - 1072009&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: Board Product ID: Gigabyte 990FXA-UD3&lt;br /&gt;
&lt;br /&gt;
: AMD FX-8350 Eight-Core Processor, 4 Ghz&lt;br /&gt;
: 16 GB RAM&lt;br /&gt;
: 480 Gb SSHD&lt;br /&gt;
: 1 Tb HD&lt;br /&gt;
: 650 W power supply&lt;br /&gt;
: AMD Radeon HD 7700 with 2 Gb RAM&lt;br /&gt;
&lt;br /&gt;
Report Generated at: 1/8/2013 1:02:45 AM&lt;br /&gt;
&lt;br /&gt;
OK, so the machine is sneaking up on its third year in service.  It still gets a decent rating from me and Windows:&lt;br /&gt;
&lt;br /&gt;
[[File:Homebrew 5 performance.jpg]]&lt;br /&gt;
&lt;br /&gt;
And, as with everything else except for Wikimedia version and the WAMPserver versions, I haven&#039;t changed anything from last week, when all was well in wikiland.&lt;br /&gt;
&lt;br /&gt;
=== OS ===&lt;br /&gt;
&lt;br /&gt;
: Windows 7 Professional, 64-bit&lt;br /&gt;
: Service Pack 1&lt;br /&gt;
&lt;br /&gt;
=== Browser ===&lt;br /&gt;
&lt;br /&gt;
: Chrome 46.0.2490.86 m&lt;br /&gt;
&lt;br /&gt;
=== Software Guardians ===&lt;br /&gt;
&lt;br /&gt;
: Malware Bytes&lt;br /&gt;
::: Set to exclude 127.0.0.1, httpd.exe, and mysql.exe from inspection.&lt;br /&gt;
&lt;br /&gt;
: CylanceProtect&lt;br /&gt;
::: I&#039;ve got no control over this.  All I can say is that with MediaWiki 1.20, I had no connection problems.&lt;br /&gt;
&lt;br /&gt;
: Firewall&lt;br /&gt;
::: Made sure port 3306 is open.&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #1 ==&lt;br /&gt;
&lt;br /&gt;
Because the connection ALWAYS worked on the very next try after a failure, I thought that perhaps I could arrange a sacrificial connection to feed the ravenous Connection Monster; while it was chomping on the carcass, the real Mediawiki connection might sneak by unnoticed.&lt;br /&gt;
&lt;br /&gt;
So I put this in my LocalSettings.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$servername = &amp;quot;127.0.0.1&amp;quot;;&lt;br /&gt;
$username = &amp;quot;dbuser&amp;quot;;&lt;br /&gt;
$password = &amp;quot;dbuserpassword&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Create connection&lt;br /&gt;
$conn = new mysqli($servername, $username, $password);&lt;br /&gt;
&lt;br /&gt;
// Check connection&lt;br /&gt;
if ($conn-&amp;gt;connect_error) {&lt;br /&gt;
    die(&amp;quot;Connection failed: &amp;quot; . $conn-&amp;gt;connect_error);&lt;br /&gt;
} &lt;br /&gt;
#echo &amp;quot;Connected successfully&amp;quot;;&lt;br /&gt;
mysqli_close($conn);&lt;br /&gt;
#die(&amp;quot;test finished&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This idiotic connection hasn&#039;t ever failed yet.&lt;br /&gt;
&lt;br /&gt;
And the wiki page hasn&#039;t yet failed to connect afterward, either.&lt;br /&gt;
&lt;br /&gt;
Pasta faggiole!&lt;br /&gt;
&lt;br /&gt;
I hate it.&lt;br /&gt;
&lt;br /&gt;
But not as much as I hate seeing the &amp;quot;connection failed&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Not yet, anyway.&lt;br /&gt;
&lt;br /&gt;
Using the [http://php.net/manual/en/book.hrtime.php &#039;&#039;hrtime&#039;&#039; extension,] I can see that this little connection check only takes a couple of milliseconds, so it&#039;s not costing me huge time in loading pages.  &lt;br /&gt;
&lt;br /&gt;
But I hate it.&lt;br /&gt;
&lt;br /&gt;
== It&#039;s a feature, not a bug ==&lt;br /&gt;
&lt;br /&gt;
The MediaWiki wizards know about this.&lt;br /&gt;
&lt;br /&gt;
There is something awkward in &#039;&#039;&#039;LoadBalancer.php&#039;&#039;&#039;: [https://phabricator.wikimedia.org/T72223 &amp;quot;&#039;Unknown error&#039; in LoadBalancer-&amp;gt;reportConnectionError() hides a real database problem.&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Change 157488 abandoned by Hashar:&lt;br /&gt;
Do not hide real DB error on first connect&lt;br /&gt;
&lt;br /&gt;
Reason:&lt;br /&gt;
That would cause T31233 Broken failover for DB slave connection errors.&lt;br /&gt;
&lt;br /&gt;
The try/catch was done on purpose, see Tim comment on https://www.mediawiki.org/wiki/Special:Code/MediaWiki/90266#c20239 &lt;br /&gt;
&lt;br /&gt;
We have a task for a better fix T35036&lt;br /&gt;
&lt;br /&gt;
[https://gerrit.wikimedia.org/r/157488 Do not hide real DB error on first connect]&lt;br /&gt;
:: LoadBalancer should not silence database exception. Bug: 70223&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #2 ==&lt;br /&gt;
&lt;br /&gt;
I&#039;ve commented out the &amp;quot;try ... catch&amp;quot; code and replaced with with the rejected simplification suggested by Saper.  I don&#039;t care that this simplification &amp;quot;would cause T31233 Broken failover for DB slave connection errors.&amp;quot; Not my circus, not my monkeys.  I&#039;m running this code on &#039;&#039;localhost.&#039;&#039;  There are no slave connections.  &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# MXM Cutting out &amp;quot;ugliest thing&amp;quot; and substituting another&#039;s guy&#039;s remedy&lt;br /&gt;
#		try {&lt;br /&gt;
#			$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
#		} catch ( DBConnectionError $e ) {&lt;br /&gt;
#			// FIXME: This is probably the ugliest thing I have ever done to&lt;br /&gt;
#			// PHP. I&#039;m half-expecting it to segfault, just out of disgust. -- TS&lt;br /&gt;
#			$db = $e-&amp;gt;db;&lt;br /&gt;
#		}&lt;br /&gt;
# MXM&lt;br /&gt;
$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
# MXM&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.mail-archive.com/mediawiki-commits@lists.wikimedia.org/msg283522.html &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;MediaWiki-commits&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;Gerrit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; Add support for connect_timeout -	change (mediawiki...PoolCounter)]&lt;br /&gt;
:: The intriguing line: &#039;&#039;we implement here what we already do for mysql connections: if we set a connection timeout to a very small value (in the order of magnitude of twice the RTT to the poolcounter server) and retry twice, we can have very fast failures in case one server goes down, and the failover to the other active servers would happen almost harmlessly.&#039;&#039;  &lt;br /&gt;
:: I&#039;m convinced this is a clue, but I haven&#039;t waded into the code to see what I might be able to play with.  &lt;br /&gt;
* [http://serverfault.com/questions/408550/connecting-to-mysql-from-php-is-extremely-slow &amp;quot;Connecting to MySQL from PHP is extremely slow&amp;quot;]&lt;br /&gt;
:: David Random&#039;s essay on this page is superb.  It didn&#039;t fix what ailed me, but it made me feel that I was understanding the problem better.&lt;br /&gt;
* [https://ineed.coffee/1441/apache-php-mysql-slow-under-windows-8-how-to-fix/ &amp;quot;Apache, PHP, MySQL slow under Windows 8. How to fix.&amp;quot;]&lt;br /&gt;
:: Contains an excellent set of links to various tips and tricks, as well as making some fresh suggestions.&lt;br /&gt;
&lt;br /&gt;
[[Category:Computers]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16393</id>
		<title>WAMP, localhost, Mediawiki: Cannot access the database</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16393"/>
		<updated>2015-12-03T01:08:16Z</updated>

		<summary type="html">&lt;p&gt;Laura: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;or &#039;&#039;&#039;&#039;&#039;The Bug that Ate a Week of My Life!&#039;&#039;&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mediawiki on localhost ==&lt;br /&gt;
&lt;br /&gt;
Since 2:42 PM on 14 March 2009, I have run a private wiki for myself on a WAMP stack--6.5 years and counting.&lt;br /&gt;
&lt;br /&gt;
I have migrated the wiki from one desktop to another and installed it on two different laptops.&lt;br /&gt;
&lt;br /&gt;
I have never had everything work perfectly right out of the box, but I have never been frustrated for too long.  People have solved all of the basic problems more than once, and it has been just a matter of googling around long enough to debug the setup.&lt;br /&gt;
&lt;br /&gt;
All that has changed.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve found a bug that has defeated me.&lt;br /&gt;
&lt;br /&gt;
== Mediawiki 1.26, WAMPserver 2.5, and WAMPserver 3 ==&lt;br /&gt;
&lt;br /&gt;
== Error Messages ==&lt;br /&gt;
&lt;br /&gt;
=== Shorter version ===&lt;br /&gt;
&lt;br /&gt;
Sorry! This site is experiencing technical difficulties.&lt;br /&gt;
&lt;br /&gt;
Try waiting a few minutes and reloading.&lt;br /&gt;
&lt;br /&gt;
(Cannot access the database)&lt;br /&gt;
&lt;br /&gt;
=== With debugging and backtracking enabled ===&lt;br /&gt;
&lt;br /&gt;
Cannot access the database: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ())&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Backtrace:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
:  #0 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(842): &#039;&#039;&#039;DatabaseBase&#039;&#039;&#039;-&amp;gt;reportConnectionError(&#039;Unknown error (...&#039;)&lt;br /&gt;
:  #1 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(537): &#039;&#039;&#039;LoadBalancer&#039;&#039;&#039;-&amp;gt;reportConnectionError()&lt;br /&gt;
:  #2 C:\wamp\www\mediawiki\includes\GlobalFunctions.php(3631): LoadBalancer-&amp;gt;getConnection(-1, Array, false)&lt;br /&gt;
:  #3 C:\wamp\www\mediawiki\includes\User.php(1208): wfGetDB(-1)&lt;br /&gt;
:  #4 C:\wamp\www\mediawiki\includes\User.php(397): User-&amp;gt;loadFromDatabase(0)&lt;br /&gt;
:  #5 C:\wamp\www\mediawiki\includes\User.php(362): User-&amp;gt;loadFromId(0)&lt;br /&gt;
:  #6 C:\wamp\www\mediawiki\includes\User.php(2459): User-&amp;gt;load()&lt;br /&gt;
:  #7 C:\wamp\www\mediawiki\includes\User.php(1167): User-&amp;gt;getToken(false)&lt;br /&gt;
:  #8 C:\wamp\www\mediawiki\includes\User.php(365): User-&amp;gt;loadFromSession()&lt;br /&gt;
:  #9 C:\wamp\www\mediawiki\includes\User.php(2029): User-&amp;gt;load()&lt;br /&gt;
:  #10 C:\wamp\www\mediawiki\includes\User.php(3204): User-&amp;gt;getId()&lt;br /&gt;
:  #11 C:\wamp\www\mediawiki\includes\MediaWiki.php(627): User-&amp;gt;isLoggedIn()&lt;br /&gt;
:  #12 C:\wamp\www\mediawiki\includes\MediaWiki.php(476): MediaWiki-&amp;gt;main()&lt;br /&gt;
:  #13 C:\wamp\www\mediawiki\index.php(51): MediaWiki-&amp;gt;run()&lt;br /&gt;
:  #14 {main}&lt;br /&gt;
&lt;br /&gt;
:  reportConnectionError &amp;quot;Unknown error&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Failure message when MySQL is totally disabled ===&lt;br /&gt;
&lt;br /&gt;
Warning: mysqli::mysqli(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp\www\mediawiki\LocalSettings.php on line 152&lt;br /&gt;
&lt;br /&gt;
Connection failed: No connection could be made because the target machine actively refused it.&lt;br /&gt;
&lt;br /&gt;
== Not a code or configuration problem ==&lt;br /&gt;
&lt;br /&gt;
Except for a few times when I shot myself in the foot while debugging, the proof that the PHP code base and my configuration are correct is that I can immediately obtain the page I want by reloading the page.  &lt;br /&gt;
&lt;br /&gt;
It is only on the first call after a long time (five minutes? ten?) of not accessing the wiki that the problem occurs.&lt;br /&gt;
&lt;br /&gt;
== Timing is everything ==&lt;br /&gt;
&lt;br /&gt;
The most common time for the bug to bite is when I open my browser.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve got two tabs to pages on the local wiki in my collection of home pages.&lt;br /&gt;
&lt;br /&gt;
The first one usually fails if I&#039;ve had the browser closed for a while; the second never does.&lt;br /&gt;
&lt;br /&gt;
I dropped the second page from the set to see if that would help the first. &lt;br /&gt;
&lt;br /&gt;
It didn&#039;t.&lt;br /&gt;
&lt;br /&gt;
Once MySQL is awakened from its slumbers, all the links in the wiki work reasonably well--no worse than ever before--unless I spend a long time composing a page, and then the connection fails when I try to save the page.  Refresh the page, and it saves perfectly.&lt;br /&gt;
&lt;br /&gt;
Something somewhere keeps MySQL from answering the FIRST request for a connection in the time frame that Mediawiki expects.  After that, everything is normal enough until MySQL decides to fall asleep again.&lt;br /&gt;
&lt;br /&gt;
== Round up the usual suspects ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s some interaction between Windows, Apache, MySQL, and the Wikimedia routines that has got me down.&lt;br /&gt;
&lt;br /&gt;
Why can&#039;t we all just get along?&lt;br /&gt;
&lt;br /&gt;
The articles in the [[#Links|links below]] have got excellent information and links in them.  They cover pretty much everything I&#039;ve tried, and then some.  I&#039;m just going to list the failed fixes that float into mind:&lt;br /&gt;
&lt;br /&gt;
* turn off IPv6 on my machine&lt;br /&gt;
* have Apache listen only to 127.0.0.1:80&lt;br /&gt;
* bind MySQL to 127.0.0.1 &lt;br /&gt;
* turn off name resolution in MySQL&lt;br /&gt;
* change localhost to 127.0.0.1 everywhere I can to avoid DNS calls&lt;br /&gt;
* edit Hosts file to make sure localhost is defined&lt;br /&gt;
* enable opcache and install APCu&lt;br /&gt;
* turn off Zend debugger&lt;br /&gt;
* moved from WAMPserver 2.5 to 3&lt;br /&gt;
&lt;br /&gt;
Total failure, but intriguing: get MySQL to use a socket.  There are paths for it in the configuration files, but I&#039;ve never gotten it going.  I must do more googling!  It seems as though it SHOULD work.&lt;br /&gt;
&lt;br /&gt;
== Sysinfo ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
: BIOS Manufacturer: American Megatrends Inc.&lt;br /&gt;
: Release Date: 10/23/2012&lt;br /&gt;
: BIOS Version: ALASKA - 1072009&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: Board Product ID: Gigabyte 990FXA-UD3&lt;br /&gt;
&lt;br /&gt;
: AMD FX-8350 Eight-Core Processor, 4 Ghz&lt;br /&gt;
: 16 GB RAM&lt;br /&gt;
: 480 Gb SSHD&lt;br /&gt;
: 1 Tb HD&lt;br /&gt;
: 650 W power supply&lt;br /&gt;
: AMD Radeon HD 7700 with 2 Gb RAM&lt;br /&gt;
&lt;br /&gt;
Report Generated at: 1/8/2013 1:02:45 AM&lt;br /&gt;
&lt;br /&gt;
OK, so the machine is sneaking up on its third year in service.  It still gets a decent rating from me and Windows:&lt;br /&gt;
&lt;br /&gt;
[[File:Homebrew 5 performance.jpg]]&lt;br /&gt;
&lt;br /&gt;
And, as with everything else except for Wikimedia version and the WAMPserver versions, I haven&#039;t changed anything from last week, when all was well in wikiland.&lt;br /&gt;
&lt;br /&gt;
=== OS ===&lt;br /&gt;
&lt;br /&gt;
: Windows 7 Professional, 64-bit&lt;br /&gt;
: Service Pack 1&lt;br /&gt;
&lt;br /&gt;
=== Browser ===&lt;br /&gt;
&lt;br /&gt;
: Chrome 46.0.2490.86 m&lt;br /&gt;
&lt;br /&gt;
=== Software Guardians ===&lt;br /&gt;
&lt;br /&gt;
: Malware Bytes&lt;br /&gt;
::: Set to exclude 127.0.0.1, httpd.exe, and mysql.exe from inspection.&lt;br /&gt;
&lt;br /&gt;
: CylanceProtect&lt;br /&gt;
::: I&#039;ve got no control over this.  All I can say is that with MediaWiki 1.20, I had no connection problems.&lt;br /&gt;
&lt;br /&gt;
: Firewall&lt;br /&gt;
::: Made sure port 3306 is open.&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #1 ==&lt;br /&gt;
&lt;br /&gt;
Because the connection ALWAYS worked on the very next try after a failure, I thought that perhaps I could arrange a sacrificial connection to feed the ravenous Connection Monster; while it was chomping on the carcass, the real Mediawiki connection might sneak by unnoticed.&lt;br /&gt;
&lt;br /&gt;
So I put this in my LocalSettings.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$servername = &amp;quot;127.0.0.1&amp;quot;;&lt;br /&gt;
$username = &amp;quot;dbuser&amp;quot;;&lt;br /&gt;
$password = &amp;quot;dbuserpassword&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Create connection&lt;br /&gt;
$conn = new mysqli($servername, $username, $password);&lt;br /&gt;
&lt;br /&gt;
// Check connection&lt;br /&gt;
if ($conn-&amp;gt;connect_error) {&lt;br /&gt;
    die(&amp;quot;Connection failed: &amp;quot; . $conn-&amp;gt;connect_error);&lt;br /&gt;
} &lt;br /&gt;
#echo &amp;quot;Connected successfully&amp;quot;;&lt;br /&gt;
mysqli_close($conn);&lt;br /&gt;
#die(&amp;quot;test finished&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This idiotic connection hasn&#039;t ever failed yet.&lt;br /&gt;
&lt;br /&gt;
And the wiki page hasn&#039;t yet failed to connect afterward, either.&lt;br /&gt;
&lt;br /&gt;
Pasta faggiole!&lt;br /&gt;
&lt;br /&gt;
I hate it.&lt;br /&gt;
&lt;br /&gt;
But not as much as I hate seeing the &amp;quot;connection failed&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Not yet, anyway.&lt;br /&gt;
&lt;br /&gt;
Using the [http://php.net/manual/en/book.hrtime.php &#039;&#039;hrtime&#039;&#039; extension,] I can see that this little connection check only takes a couple of milliseconds, so it&#039;s not costing me huge time in loading pages.  &lt;br /&gt;
&lt;br /&gt;
But I hate it.&lt;br /&gt;
&lt;br /&gt;
== It&#039;s a feature, not a bug ==&lt;br /&gt;
&lt;br /&gt;
The MediaWiki wizards know about this.&lt;br /&gt;
&lt;br /&gt;
There is something awkward in &#039;&#039;&#039;LoadBalancer.php&#039;&#039;&#039;: [https://phabricator.wikimedia.org/T72223 &amp;quot;&#039;Unknown error&#039; in LoadBalancer-&amp;gt;reportConnectionError() hides a real database problem.&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Change 157488 abandoned by Hashar:&lt;br /&gt;
Do not hide real DB error on first connect&lt;br /&gt;
&lt;br /&gt;
Reason:&lt;br /&gt;
That would cause T31233 Broken failover for DB slave connection errors.&lt;br /&gt;
&lt;br /&gt;
The try/catch was done on purpose, see Tim comment on https://www.mediawiki.org/wiki/Special:Code/MediaWiki/90266#c20239 &lt;br /&gt;
&lt;br /&gt;
We have a task for a better fix T35036&lt;br /&gt;
&lt;br /&gt;
[https://gerrit.wikimedia.org/r/157488 Do not hide real DB error on first connect]&lt;br /&gt;
:: LoadBalancer should not silence database exception. Bug: 70223&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround #2 ==&lt;br /&gt;
&lt;br /&gt;
I&#039;ve commented out the &amp;quot;try ... catch&amp;quot; code and replaced with with the rejected simplification suggested by Saper:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# MXM Cutting out &amp;quot;ugliest thing&amp;quot; and substituting another&#039;s guy&#039;s remedy&lt;br /&gt;
#		try {&lt;br /&gt;
#			$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
#		} catch ( DBConnectionError $e ) {&lt;br /&gt;
#			// FIXME: This is probably the ugliest thing I have ever done to&lt;br /&gt;
#			// PHP. I&#039;m half-expecting it to segfault, just out of disgust. -- TS&lt;br /&gt;
#			$db = $e-&amp;gt;db;&lt;br /&gt;
#		}&lt;br /&gt;
# MXM&lt;br /&gt;
$db = DatabaseBase::factory( $server[&#039;type&#039;], $server );&lt;br /&gt;
# MXM&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.mail-archive.com/mediawiki-commits@lists.wikimedia.org/msg283522.html &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;MediaWiki-commits&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;Gerrit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; Add support for connect_timeout -	change (mediawiki...PoolCounter)]&lt;br /&gt;
:: The intriguing line: &#039;&#039;we implement here what we already do for mysql connections: if we set a connection timeout to a very small value (in the order of magnitude of twice the RTT to the poolcounter server) and retry twice, we can have very fast failures in case one server goes down, and the failover to the other active servers would happen almost harmlessly.&#039;&#039;  &lt;br /&gt;
:: I&#039;m convinced this is a clue, but I haven&#039;t waded into the code to see what I might be able to play with.  &lt;br /&gt;
* [http://serverfault.com/questions/408550/connecting-to-mysql-from-php-is-extremely-slow &amp;quot;Connecting to MySQL from PHP is extremely slow&amp;quot;]&lt;br /&gt;
:: David Random&#039;s essay on this page is superb.  It didn&#039;t fix what ailed me, but it made me feel that I was understanding the problem better.&lt;br /&gt;
* [https://ineed.coffee/1441/apache-php-mysql-slow-under-windows-8-how-to-fix/ &amp;quot;Apache, PHP, MySQL slow under Windows 8. How to fix.&amp;quot;]&lt;br /&gt;
:: Contains an excellent set of links to various tips and tricks, as well as making some fresh suggestions.&lt;br /&gt;
&lt;br /&gt;
[[Category:Computers]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16392</id>
		<title>WAMP, localhost, Mediawiki: Cannot access the database</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16392"/>
		<updated>2015-12-03T00:58:58Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;This is just a draft.  There is more to the story than this.  I&#039;m still googling and tweaking.  Stay tuned for more morbid details on The Bug that Ate a Week of My Life!&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mediawiki on localhost ==&lt;br /&gt;
&lt;br /&gt;
Since 2:42 PM on 14 March 2009, I have run a private wiki for myself on a WAMP stack--6.5 years and counting.&lt;br /&gt;
&lt;br /&gt;
I have migrated the wiki from one desktop to another and installed it on two different laptops.&lt;br /&gt;
&lt;br /&gt;
I have never had everything work perfectly right out of the box, but I have never been frustrated for too long.  People have solved all of the basic problems more than once, and it has been just a matter of googling around long enough to debug the setup.&lt;br /&gt;
&lt;br /&gt;
All that has changed.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve found a bug that has defeated me.&lt;br /&gt;
&lt;br /&gt;
== Mediawiki 1.26, WAMPserver 2.5, and WAMPserver 3 ==&lt;br /&gt;
&lt;br /&gt;
== Error Messages ==&lt;br /&gt;
&lt;br /&gt;
=== Shorter version ===&lt;br /&gt;
&lt;br /&gt;
Sorry! This site is experiencing technical difficulties.&lt;br /&gt;
&lt;br /&gt;
Try waiting a few minutes and reloading.&lt;br /&gt;
&lt;br /&gt;
(Cannot access the database)&lt;br /&gt;
&lt;br /&gt;
=== With debugging and backtracking enabled ===&lt;br /&gt;
&lt;br /&gt;
Cannot access the database: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ())&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Backtrace:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
:  #0 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(842): &#039;&#039;&#039;DatabaseBase&#039;&#039;&#039;-&amp;gt;reportConnectionError(&#039;Unknown error (...&#039;)&lt;br /&gt;
:  #1 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(537): &#039;&#039;&#039;LoadBalancer&#039;&#039;&#039;-&amp;gt;reportConnectionError()&lt;br /&gt;
:  #2 C:\wamp\www\mediawiki\includes\GlobalFunctions.php(3631): LoadBalancer-&amp;gt;getConnection(-1, Array, false)&lt;br /&gt;
:  #3 C:\wamp\www\mediawiki\includes\User.php(1208): wfGetDB(-1)&lt;br /&gt;
:  #4 C:\wamp\www\mediawiki\includes\User.php(397): User-&amp;gt;loadFromDatabase(0)&lt;br /&gt;
:  #5 C:\wamp\www\mediawiki\includes\User.php(362): User-&amp;gt;loadFromId(0)&lt;br /&gt;
:  #6 C:\wamp\www\mediawiki\includes\User.php(2459): User-&amp;gt;load()&lt;br /&gt;
:  #7 C:\wamp\www\mediawiki\includes\User.php(1167): User-&amp;gt;getToken(false)&lt;br /&gt;
:  #8 C:\wamp\www\mediawiki\includes\User.php(365): User-&amp;gt;loadFromSession()&lt;br /&gt;
:  #9 C:\wamp\www\mediawiki\includes\User.php(2029): User-&amp;gt;load()&lt;br /&gt;
:  #10 C:\wamp\www\mediawiki\includes\User.php(3204): User-&amp;gt;getId()&lt;br /&gt;
:  #11 C:\wamp\www\mediawiki\includes\MediaWiki.php(627): User-&amp;gt;isLoggedIn()&lt;br /&gt;
:  #12 C:\wamp\www\mediawiki\includes\MediaWiki.php(476): MediaWiki-&amp;gt;main()&lt;br /&gt;
:  #13 C:\wamp\www\mediawiki\index.php(51): MediaWiki-&amp;gt;run()&lt;br /&gt;
:  #14 {main}&lt;br /&gt;
&lt;br /&gt;
:  reportConnectionError &amp;quot;Unknown error&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Failure message when MySQL is totally disabled ===&lt;br /&gt;
&lt;br /&gt;
Warning: mysqli::mysqli(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp\www\mediawiki\LocalSettings.php on line 152&lt;br /&gt;
&lt;br /&gt;
Connection failed: No connection could be made because the target machine actively refused it.&lt;br /&gt;
&lt;br /&gt;
== Not a code or configuration problem ==&lt;br /&gt;
&lt;br /&gt;
Except for a few times when I shot myself in the foot while debugging, the proof that the PHP code base and my configuration are correct is that I can immediately obtain the page I want by reloading the page.  &lt;br /&gt;
&lt;br /&gt;
It is only on the first call after a long time (five minutes? ten?) of not accessing the wiki that the problem occurs.&lt;br /&gt;
&lt;br /&gt;
== Timing is everything ==&lt;br /&gt;
&lt;br /&gt;
The most common time for the bug to bite is when I open my browser.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve got two tabs to pages on the local wiki in my collection of home pages.&lt;br /&gt;
&lt;br /&gt;
The first one usually fails if I&#039;ve had the browser closed for a while; the second never does.&lt;br /&gt;
&lt;br /&gt;
I dropped the second page from the set to see if that would help the first. &lt;br /&gt;
&lt;br /&gt;
It didn&#039;t.&lt;br /&gt;
&lt;br /&gt;
Once MySQL is awakened from its slumbers, all the links in the wiki work reasonably well--no worse than ever before--unless I spend a long time composing a page, and then the connection fails when I try to save the page.  Refresh the page, and it saves perfectly.&lt;br /&gt;
&lt;br /&gt;
Something somewhere keeps MySQL from answering the FIRST request for a connection in the time frame that Mediawiki expects.  After that, everything is normal enough until MySQL decides to fall asleep again.&lt;br /&gt;
&lt;br /&gt;
== Round up the usual suspects ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s some interaction between Windows, Apache, MySQL, and the Wikimedia routines that has got me down.&lt;br /&gt;
&lt;br /&gt;
Why can&#039;t we all just get along?&lt;br /&gt;
&lt;br /&gt;
The articles in the [[#Links|links below]] have got excellent information and links in them.  They cover pretty much everything I&#039;ve tried, and then some.  I&#039;m just going to list the failed fixes that float into mind:&lt;br /&gt;
&lt;br /&gt;
* turn off IPv6 on my machine&lt;br /&gt;
* have Apache listen only to 127.0.0.1:80&lt;br /&gt;
* bind MySQL to 127.0.0.1 &lt;br /&gt;
* turn off name resolution in MySQL&lt;br /&gt;
* change localhost to 127.0.0.1 everywhere I can to avoid DNS calls&lt;br /&gt;
* edit Hosts file to make sure localhost is defined&lt;br /&gt;
* enable opcache and install APCu&lt;br /&gt;
* turn off Zend debugger&lt;br /&gt;
* moved from WAMPserver 2.5 to 3&lt;br /&gt;
&lt;br /&gt;
Total failure, but intriguing: get MySQL to use a socket.  There are paths for it in the configuration files, but I&#039;ve never gotten it going.  I must do more googling!  It seems as though it SHOULD work.&lt;br /&gt;
&lt;br /&gt;
== Sysinfo ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
: BIOS Manufacturer: American Megatrends Inc.&lt;br /&gt;
: Release Date: 10/23/2012&lt;br /&gt;
: BIOS Version: ALASKA - 1072009&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: Board Product ID: Gigabyte 990FXA-UD3&lt;br /&gt;
&lt;br /&gt;
: AMD FX-8350 Eight-Core Processor, 4 Ghz&lt;br /&gt;
: 16 GB RAM&lt;br /&gt;
: 480 Gb SSHD&lt;br /&gt;
: 1 Tb HD&lt;br /&gt;
: 650 W power supply&lt;br /&gt;
: AMD Radeon HD 7700 with 2 Gb RAM&lt;br /&gt;
&lt;br /&gt;
Report Generated at: 1/8/2013 1:02:45 AM&lt;br /&gt;
&lt;br /&gt;
OK, so the machine is sneaking up on its third year in service.  It still gets a decent rating from me and Windows:&lt;br /&gt;
&lt;br /&gt;
[[File:Homebrew 5 performance.jpg]]&lt;br /&gt;
&lt;br /&gt;
And, as with everything else except for Wikimedia version and the WAMPserver versions, I haven&#039;t changed anything from last week, when all was well in wikiland.&lt;br /&gt;
&lt;br /&gt;
=== OS ===&lt;br /&gt;
&lt;br /&gt;
: Windows 7 Professional, 64-bit&lt;br /&gt;
: Service Pack 1&lt;br /&gt;
&lt;br /&gt;
=== Browser ===&lt;br /&gt;
&lt;br /&gt;
: Chrome 46.0.2490.86 m&lt;br /&gt;
&lt;br /&gt;
=== Software Guardians ===&lt;br /&gt;
&lt;br /&gt;
: Malware Bytes&lt;br /&gt;
::: Set to exclude 127.0.0.1, httpd.exe, and mysql.exe from inspection.&lt;br /&gt;
&lt;br /&gt;
: CylanceProtect&lt;br /&gt;
::: I&#039;ve got no control over this.  All I can say is that with MediaWiki 1.20, I had no connection problems.&lt;br /&gt;
&lt;br /&gt;
: Firewall&lt;br /&gt;
::: Made sure port 3306 is open.&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround ==&lt;br /&gt;
&lt;br /&gt;
Because the connection ALWAYS worked on the very next try after a failure, I thought that perhaps I could arrange a sacrificial connection to feed the ravenous Connection Monster; while it was chomping on the carcass, the real Mediawiki connection might sneak by unnoticed.&lt;br /&gt;
&lt;br /&gt;
So I put this in my LocalSettings.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$servername = &amp;quot;127.0.0.1&amp;quot;;&lt;br /&gt;
$username = &amp;quot;dbuser&amp;quot;;&lt;br /&gt;
$password = &amp;quot;dbuserpassword&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Create connection&lt;br /&gt;
$conn = new mysqli($servername, $username, $password);&lt;br /&gt;
&lt;br /&gt;
// Check connection&lt;br /&gt;
if ($conn-&amp;gt;connect_error) {&lt;br /&gt;
    die(&amp;quot;Connection failed: &amp;quot; . $conn-&amp;gt;connect_error);&lt;br /&gt;
} &lt;br /&gt;
#echo &amp;quot;Connected successfully&amp;quot;;&lt;br /&gt;
mysqli_close($conn);&lt;br /&gt;
#die(&amp;quot;test finished&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This idiotic connection hasn&#039;t ever failed yet.&lt;br /&gt;
&lt;br /&gt;
And the wiki page hasn&#039;t yet failed to connect afterward, either.&lt;br /&gt;
&lt;br /&gt;
Pasta faggiole!&lt;br /&gt;
&lt;br /&gt;
I hate it.&lt;br /&gt;
&lt;br /&gt;
But not as much as I hate seeing the &amp;quot;connection failed&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Not yet, anyway.&lt;br /&gt;
&lt;br /&gt;
Using the [http://php.net/manual/en/book.hrtime.php &#039;&#039;hrtime&#039;&#039; extension,] I can see that this little connection check only takes a couple of milliseconds, so it&#039;s not costing me huge time in loading pages.  &lt;br /&gt;
&lt;br /&gt;
I&#039;m going to let it ride for a while, FWIW.&lt;br /&gt;
&lt;br /&gt;
== It&#039;s a feature, not a bug ==&lt;br /&gt;
&lt;br /&gt;
The MediaWiki wizards know about this.&lt;br /&gt;
&lt;br /&gt;
There is something awkward in &#039;&#039;&#039;LoadBalancer.php&#039;&#039;&#039;: [https://phabricator.wikimedia.org/T72223 &amp;quot;&#039;Unknown error&#039; in LoadBalancer-&amp;gt;reportConnectionError() hides a real database problem.&amp;quot;]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;blockquote&amp;gt;&lt;br /&gt;
Change 157488 abandoned by Hashar:&lt;br /&gt;
Do not hide real DB error on first connect&lt;br /&gt;
&lt;br /&gt;
Reason:&lt;br /&gt;
That would cause T31233 Broken failover for DB slave connection errors.&lt;br /&gt;
&lt;br /&gt;
The try/catch was done on purpose, see Tim comment on https://www.mediawiki.org/wiki/Special:Code/MediaWiki/90266#c20239 &lt;br /&gt;
&lt;br /&gt;
We have a task for a better fix T35036&lt;br /&gt;
&lt;br /&gt;
[https://gerrit.wikimedia.org/r/157488 Do not hide real DB error on first connect]&lt;br /&gt;
:: LoadBalancer should not silence database exception. Bug: 70223&lt;br /&gt;
&amp;lt;/blockquote&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.mail-archive.com/mediawiki-commits@lists.wikimedia.org/msg283522.html &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;MediaWiki-commits&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;Gerrit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; Add support for connect_timeout -	change (mediawiki...PoolCounter)]&lt;br /&gt;
:: The intriguing line: &#039;&#039;we implement here what we already do for mysql connections: if we set a connection timeout to a very small value (in the order of magnitude of twice the RTT to the poolcounter server) and retry twice, we can have very fast failures in case one server goes down, and the failover to the other active servers would happen almost harmlessly.&#039;&#039;  &lt;br /&gt;
:: I&#039;m convinced this is a clue, but I haven&#039;t waded into the code to see what I might be able to play with.  &lt;br /&gt;
* [http://serverfault.com/questions/408550/connecting-to-mysql-from-php-is-extremely-slow &amp;quot;Connecting to MySQL from PHP is extremely slow&amp;quot;]&lt;br /&gt;
:: David Random&#039;s essay on this page is superb.  It didn&#039;t fix what ailed me, but it made me feel that I was understanding the problem better.&lt;br /&gt;
* [https://ineed.coffee/1441/apache-php-mysql-slow-under-windows-8-how-to-fix/ &amp;quot;Apache, PHP, MySQL slow under Windows 8. How to fix.&amp;quot;]&lt;br /&gt;
:: Contains an excellent set of links to various tips and tricks, as well as making some fresh suggestions.&lt;br /&gt;
&lt;br /&gt;
[[Category:Computers]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16391</id>
		<title>WAMP, localhost, Mediawiki: Cannot access the database</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16391"/>
		<updated>2015-12-03T00:39:08Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;This is just a draft.  There is more to the story than this.  I&#039;m still googling and tweaking.  Stay tuned for more morbid details on The Bug that Ate a Week of My Life!&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mediawiki on localhost ==&lt;br /&gt;
&lt;br /&gt;
Since 2:42 PM on 14 March 2009, I have run a private wiki for myself on a WAMP stack--6.5 years and counting.&lt;br /&gt;
&lt;br /&gt;
I have migrated the wiki from one desktop to another and installed it on two different laptops.&lt;br /&gt;
&lt;br /&gt;
I have never had everything work perfectly right out of the box, but I have never been frustrated for too long.  People have solved all of the basic problems more than once, and it has been just a matter of googling around long enough to debug the setup.&lt;br /&gt;
&lt;br /&gt;
All that has changed.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve found a bug that has defeated me.&lt;br /&gt;
&lt;br /&gt;
== Mediawiki 1.26, WAMPserver 2.5, and WAMPserver 3 ==&lt;br /&gt;
&lt;br /&gt;
== Error Messages ==&lt;br /&gt;
&lt;br /&gt;
=== Shorter version ===&lt;br /&gt;
&lt;br /&gt;
Sorry! This site is experiencing technical difficulties.&lt;br /&gt;
&lt;br /&gt;
Try waiting a few minutes and reloading.&lt;br /&gt;
&lt;br /&gt;
(Cannot access the database)&lt;br /&gt;
&lt;br /&gt;
=== With debugging and backtracking enabled ===&lt;br /&gt;
&lt;br /&gt;
Cannot access the database: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ())&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Backtrace:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
:  #0 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(842): &#039;&#039;&#039;DatabaseBase&#039;&#039;&#039;-&amp;gt;reportConnectionError(&#039;Unknown error (...&#039;)&lt;br /&gt;
:  #1 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(537): &#039;&#039;&#039;LoadBalancer&#039;&#039;&#039;-&amp;gt;reportConnectionError()&lt;br /&gt;
:  #2 C:\wamp\www\mediawiki\includes\GlobalFunctions.php(3631): LoadBalancer-&amp;gt;getConnection(-1, Array, false)&lt;br /&gt;
:  #3 C:\wamp\www\mediawiki\includes\User.php(1208): wfGetDB(-1)&lt;br /&gt;
:  #4 C:\wamp\www\mediawiki\includes\User.php(397): User-&amp;gt;loadFromDatabase(0)&lt;br /&gt;
:  #5 C:\wamp\www\mediawiki\includes\User.php(362): User-&amp;gt;loadFromId(0)&lt;br /&gt;
:  #6 C:\wamp\www\mediawiki\includes\User.php(2459): User-&amp;gt;load()&lt;br /&gt;
:  #7 C:\wamp\www\mediawiki\includes\User.php(1167): User-&amp;gt;getToken(false)&lt;br /&gt;
:  #8 C:\wamp\www\mediawiki\includes\User.php(365): User-&amp;gt;loadFromSession()&lt;br /&gt;
:  #9 C:\wamp\www\mediawiki\includes\User.php(2029): User-&amp;gt;load()&lt;br /&gt;
:  #10 C:\wamp\www\mediawiki\includes\User.php(3204): User-&amp;gt;getId()&lt;br /&gt;
:  #11 C:\wamp\www\mediawiki\includes\MediaWiki.php(627): User-&amp;gt;isLoggedIn()&lt;br /&gt;
:  #12 C:\wamp\www\mediawiki\includes\MediaWiki.php(476): MediaWiki-&amp;gt;main()&lt;br /&gt;
:  #13 C:\wamp\www\mediawiki\index.php(51): MediaWiki-&amp;gt;run()&lt;br /&gt;
:  #14 {main}&lt;br /&gt;
&lt;br /&gt;
:  reportConnectionError &amp;quot;Unknown error&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Failure message when MySQL is totally disabled ===&lt;br /&gt;
&lt;br /&gt;
Warning: mysqli::mysqli(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp\www\mediawiki\LocalSettings.php on line 152&lt;br /&gt;
&lt;br /&gt;
Connection failed: No connection could be made because the target machine actively refused it.&lt;br /&gt;
&lt;br /&gt;
== Not a code or configuration problem ==&lt;br /&gt;
&lt;br /&gt;
Except for a few times when I shot myself in the foot while debugging, the proof that the PHP code base and my configuration are correct is that I can immediately obtain the page I want by reloading the page.  &lt;br /&gt;
&lt;br /&gt;
It is only on the first call after a long time (five minutes? ten?) of not accessing the wiki that the problem occurs.&lt;br /&gt;
&lt;br /&gt;
== Timing is everything ==&lt;br /&gt;
&lt;br /&gt;
The most common time for the bug to bite is when I open my browser.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve got two tabs to pages on the local wiki in my collection of home pages.&lt;br /&gt;
&lt;br /&gt;
The first one usually fails if I&#039;ve had the browser closed for a while; the second never does.&lt;br /&gt;
&lt;br /&gt;
I dropped the second page from the set to see if that would help the first. &lt;br /&gt;
&lt;br /&gt;
It didn&#039;t.&lt;br /&gt;
&lt;br /&gt;
Once MySQL is awakened from its slumbers, all the links in the wiki work reasonably well--no worse than ever before--unless I spend a long time composing a page, and then the connection fails when I try to save the page.  Refresh the page, and it saves perfectly.&lt;br /&gt;
&lt;br /&gt;
Something somewhere keeps MySQL from answering the FIRST request for a connection in the time frame that Mediawiki expects.  After that, everything is normal enough until MySQL decides to fall asleep again.&lt;br /&gt;
&lt;br /&gt;
== Round up the usual suspects ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s some interaction between Windows, Apache, MySQL, and the Wikimedia routines that has got me down.&lt;br /&gt;
&lt;br /&gt;
Why can&#039;t we all just get along?&lt;br /&gt;
&lt;br /&gt;
The articles in the [[#Links|links below]] have got excellent information and links in them.  They cover pretty much everything I&#039;ve tried, and then some.  I&#039;m just going to list the failed fixes that float into mind:&lt;br /&gt;
&lt;br /&gt;
* turn off IPv6 on my machine&lt;br /&gt;
* have Apache listen only to 127.0.0.1:80&lt;br /&gt;
* bind MySQL to 127.0.0.1 &lt;br /&gt;
* turn off name resolution in MySQL&lt;br /&gt;
* change localhost to 127.0.0.1 everywhere I can to avoid DNS calls&lt;br /&gt;
* edit Hosts file to make sure localhost is defined&lt;br /&gt;
* enable opcache and install APCu&lt;br /&gt;
* turn off Zend debugger&lt;br /&gt;
* moved from WAMPserver 2.5 to 3&lt;br /&gt;
&lt;br /&gt;
Total failure, but intriguing: get MySQL to use a socket.  There are paths for it in the configuration files, but I&#039;ve never gotten it going.  I must do more googling!  It seems as though it SHOULD work.&lt;br /&gt;
&lt;br /&gt;
== Sysinfo ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
: BIOS Manufacturer: American Megatrends Inc.&lt;br /&gt;
: Release Date: 10/23/2012&lt;br /&gt;
: BIOS Version: ALASKA - 1072009&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: Board Product ID: Gigabyte 990FXA-UD3&lt;br /&gt;
&lt;br /&gt;
: AMD FX-8350 Eight-Core Processor, 4 Ghz&lt;br /&gt;
: 16 GB RAM&lt;br /&gt;
: 480 Gb SSHD&lt;br /&gt;
: 1 Tb HD&lt;br /&gt;
: 650 W power supply&lt;br /&gt;
: AMD Radeon HD 7700 with 2 Gb RAM&lt;br /&gt;
&lt;br /&gt;
Report Generated at: 1/8/2013 1:02:45 AM&lt;br /&gt;
&lt;br /&gt;
OK, so the machine is sneaking up on its third year in service.  It still gets a decent rating from me and Windows:&lt;br /&gt;
&lt;br /&gt;
[[File:Homebrew 5 performance.jpg]]&lt;br /&gt;
&lt;br /&gt;
And, as with everything else except for Wikimedia version and the WAMPserver versions, I haven&#039;t changed anything from last week, when all was well in wikiland.&lt;br /&gt;
&lt;br /&gt;
=== OS ===&lt;br /&gt;
&lt;br /&gt;
: Windows 7 Professional, 64-bit&lt;br /&gt;
: Service Pack 1&lt;br /&gt;
&lt;br /&gt;
=== Browser ===&lt;br /&gt;
&lt;br /&gt;
: Chrome 46.0.2490.86 m&lt;br /&gt;
&lt;br /&gt;
=== Software Guardians ===&lt;br /&gt;
&lt;br /&gt;
: Malware Bytes&lt;br /&gt;
::: Set to exclude 127.0.0.1, httpd.exe, and mysql.exe from inspection.&lt;br /&gt;
&lt;br /&gt;
: CylanceProtect&lt;br /&gt;
::: I&#039;ve got no control over this.  All I can say is that with MediaWiki 1.20, I had no connection problems.&lt;br /&gt;
&lt;br /&gt;
: Firewall&lt;br /&gt;
::: Made sure port 3306 is open.&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround ==&lt;br /&gt;
&lt;br /&gt;
Because the connection ALWAYS worked on the very next try after a failure, I thought that perhaps I could arrange a sacrificial connection to feed the ravenous Connection Monster; while it was chomping on the carcass, the real Mediawiki connection might sneak by unnoticed.&lt;br /&gt;
&lt;br /&gt;
So I put this in my LocalSettings.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$servername = &amp;quot;127.0.0.1&amp;quot;;&lt;br /&gt;
$username = &amp;quot;dbuser&amp;quot;;&lt;br /&gt;
$password = &amp;quot;dbuserpassword&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Create connection&lt;br /&gt;
$conn = new mysqli($servername, $username, $password);&lt;br /&gt;
&lt;br /&gt;
// Check connection&lt;br /&gt;
if ($conn-&amp;gt;connect_error) {&lt;br /&gt;
    die(&amp;quot;Connection failed: &amp;quot; . $conn-&amp;gt;connect_error);&lt;br /&gt;
} &lt;br /&gt;
#echo &amp;quot;Connected successfully&amp;quot;;&lt;br /&gt;
mysqli_close($conn);&lt;br /&gt;
#die(&amp;quot;test finished&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This idiotic connection hasn&#039;t ever failed yet.&lt;br /&gt;
&lt;br /&gt;
And the wiki page hasn&#039;t yet failed to connect afterward, either.&lt;br /&gt;
&lt;br /&gt;
Pasta faggiole!&lt;br /&gt;
&lt;br /&gt;
I hate it.&lt;br /&gt;
&lt;br /&gt;
But not as much as I hate seeing the &amp;quot;connection failed&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Not yet, anyway.&lt;br /&gt;
&lt;br /&gt;
Using the [http://php.net/manual/en/book.hrtime.php &#039;&#039;hrtime&#039;&#039; extension,] I can see that this little connection check only takes a couple of milliseconds, so it&#039;s not costing me huge time in loading pages.  &lt;br /&gt;
&lt;br /&gt;
I&#039;m going to let it ride for a while, FWIW.&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.mail-archive.com/mediawiki-commits@lists.wikimedia.org/msg283522.html &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;MediaWiki-commits&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; &amp;lt;nowiki&amp;gt;[&amp;lt;/nowiki&amp;gt;Gerrit&amp;lt;nowiki&amp;gt;]&amp;lt;/nowiki&amp;gt; Add support for connect_timeout -	change (mediawiki...PoolCounter)]&lt;br /&gt;
:: The intriguing line: &#039;&#039;we implement here what we already do for mysql connections: if we set a connection timeout to a very small value (in the order of magnitude of twice the RTT to the poolcounter server) and retry twice, we can have very fast failures in case one server goes down, and the failover to the other active servers would happen almost harmlessly.&#039;&#039;  &lt;br /&gt;
:: I&#039;m convinced this is a clue, but I haven&#039;t waded into the code to see what I might be able to play with.  &lt;br /&gt;
* [http://serverfault.com/questions/408550/connecting-to-mysql-from-php-is-extremely-slow &amp;quot;Connecting to MySQL from PHP is extremely slow&amp;quot;]&lt;br /&gt;
:: David Random&#039;s essay on this page is superb.  It didn&#039;t fix what ailed me, but it made me feel that I was understanding the problem better.&lt;br /&gt;
* [https://ineed.coffee/1441/apache-php-mysql-slow-under-windows-8-how-to-fix/ &amp;quot;Apache, PHP, MySQL slow under Windows 8. How to fix.&amp;quot;]&lt;br /&gt;
:: Contains an excellent set of links to various tips and tricks, as well as making some fresh suggestions.&lt;br /&gt;
&lt;br /&gt;
[[Category:Computers]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16390</id>
		<title>WAMP, localhost, Mediawiki: Cannot access the database</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16390"/>
		<updated>2015-12-03T00:22:31Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* With debugging and backtracking enabled */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;This is just a draft.  There is more to the story than this.  I&#039;m still googling and tweaking.  Stay tuned for more morbid details on The Bug that Ate a Week of My Life!&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mediawiki on localhost ==&lt;br /&gt;
&lt;br /&gt;
Since 2:42 PM on 14 March 2009, I have run a private wiki for myself on a WAMP stack--6.5 years and counting.&lt;br /&gt;
&lt;br /&gt;
I have migrated the wiki from one desktop to another and installed it on two different laptops.&lt;br /&gt;
&lt;br /&gt;
I have never had everything work perfectly right out of the box, but I have never been frustrated for too long.  People have solved all of the basic problems more than once, and it has been just a matter of googling around long enough to debug the setup.&lt;br /&gt;
&lt;br /&gt;
All that has changed.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve found a bug that has defeated me.&lt;br /&gt;
&lt;br /&gt;
== Mediawiki 1.26, WAMPserver 2.5, and WAMPserver 3 ==&lt;br /&gt;
&lt;br /&gt;
== Error Messages ==&lt;br /&gt;
&lt;br /&gt;
=== Shorter version ===&lt;br /&gt;
&lt;br /&gt;
Sorry! This site is experiencing technical difficulties.&lt;br /&gt;
&lt;br /&gt;
Try waiting a few minutes and reloading.&lt;br /&gt;
&lt;br /&gt;
(Cannot access the database)&lt;br /&gt;
&lt;br /&gt;
=== With debugging and backtracking enabled ===&lt;br /&gt;
&lt;br /&gt;
Cannot access the database: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ())&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Backtrace:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
:  #0 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(842): &#039;&#039;&#039;DatabaseBase&#039;&#039;&#039;-&amp;gt;reportConnectionError(&#039;Unknown error (...&#039;)&lt;br /&gt;
:  #1 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(537): &#039;&#039;&#039;LoadBalancer&#039;&#039;&#039;-&amp;gt;reportConnectionError()&lt;br /&gt;
:  #2 C:\wamp\www\mediawiki\includes\GlobalFunctions.php(3631): LoadBalancer-&amp;gt;getConnection(-1, Array, false)&lt;br /&gt;
:  #3 C:\wamp\www\mediawiki\includes\User.php(1208): wfGetDB(-1)&lt;br /&gt;
:  #4 C:\wamp\www\mediawiki\includes\User.php(397): User-&amp;gt;loadFromDatabase(0)&lt;br /&gt;
:  #5 C:\wamp\www\mediawiki\includes\User.php(362): User-&amp;gt;loadFromId(0)&lt;br /&gt;
:  #6 C:\wamp\www\mediawiki\includes\User.php(2459): User-&amp;gt;load()&lt;br /&gt;
:  #7 C:\wamp\www\mediawiki\includes\User.php(1167): User-&amp;gt;getToken(false)&lt;br /&gt;
:  #8 C:\wamp\www\mediawiki\includes\User.php(365): User-&amp;gt;loadFromSession()&lt;br /&gt;
:  #9 C:\wamp\www\mediawiki\includes\User.php(2029): User-&amp;gt;load()&lt;br /&gt;
:  #10 C:\wamp\www\mediawiki\includes\User.php(3204): User-&amp;gt;getId()&lt;br /&gt;
:  #11 C:\wamp\www\mediawiki\includes\MediaWiki.php(627): User-&amp;gt;isLoggedIn()&lt;br /&gt;
:  #12 C:\wamp\www\mediawiki\includes\MediaWiki.php(476): MediaWiki-&amp;gt;main()&lt;br /&gt;
:  #13 C:\wamp\www\mediawiki\index.php(51): MediaWiki-&amp;gt;run()&lt;br /&gt;
:  #14 {main}&lt;br /&gt;
&lt;br /&gt;
:  reportConnectionError &amp;quot;Unknown error&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Failure message when MySQL is totally disabled ===&lt;br /&gt;
&lt;br /&gt;
Warning: mysqli::mysqli(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp\www\mediawiki\LocalSettings.php on line 152&lt;br /&gt;
&lt;br /&gt;
Connection failed: No connection could be made because the target machine actively refused it.&lt;br /&gt;
&lt;br /&gt;
== Not a code or configuration problem ==&lt;br /&gt;
&lt;br /&gt;
Except for a few times when I shot myself in the foot while debugging, the proof that the PHP code base and my configuration are correct is that I can immediately obtain the page I want by reloading the page.  &lt;br /&gt;
&lt;br /&gt;
It is only on the first call after a long time (five minutes? ten?) of not accessing the wiki that the problem occurs.&lt;br /&gt;
&lt;br /&gt;
== Timing is everything ==&lt;br /&gt;
&lt;br /&gt;
The most common time for the bug to bite is when I open my browser.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve got two tabs to pages on the local wiki in my collection of home pages.&lt;br /&gt;
&lt;br /&gt;
The first one usually fails if I&#039;ve had the browser closed for a while; the second never does.&lt;br /&gt;
&lt;br /&gt;
I dropped the second page from the set to see if that would help the first. &lt;br /&gt;
&lt;br /&gt;
It didn&#039;t.&lt;br /&gt;
&lt;br /&gt;
Once MySQL is awakened from its slumbers, all the links in the wiki work reasonably well--no worse than ever before--unless I spend a long time composing a page, and then the connection fails when I try to save the page.  Refresh the page, and it saves perfectly.&lt;br /&gt;
&lt;br /&gt;
Something somewhere keeps MySQL from answering the FIRST request for a connection in the time frame that Mediawiki expects.  After that, everything is normal enough until MySQL decides to fall asleep again.&lt;br /&gt;
&lt;br /&gt;
== Round up the usual suspects ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s some interaction between Windows, Apache, MySQL, and the Wikimedia routines that has got me down.&lt;br /&gt;
&lt;br /&gt;
Why can&#039;t we all just get along?&lt;br /&gt;
&lt;br /&gt;
The articles in the [[#Links|links below]] have got excellent information and links in them.  They cover pretty much everything I&#039;ve tried, and then some.  I&#039;m just going to list the failed fixes that float into mind:&lt;br /&gt;
&lt;br /&gt;
* turn off IPv6 on my machine&lt;br /&gt;
* have Apache listen only to 127.0.0.1:80&lt;br /&gt;
* bind MySQL to 127.0.0.1 &lt;br /&gt;
* turn off name resolution in MySQL&lt;br /&gt;
* change localhost to 127.0.0.1 everywhere I can to avoid DNS calls&lt;br /&gt;
* edit Hosts file to make sure localhost is defined&lt;br /&gt;
* enable opcache and install APCu&lt;br /&gt;
* turn off Zend debugger&lt;br /&gt;
* moved from WAMPserver 2.5 to 3&lt;br /&gt;
&lt;br /&gt;
Total failure, but intriguing: get MySQL to use a socket.  There are paths for it in the configuration files, but I&#039;ve never gotten it going.  I must do more googling!  It seems as though it SHOULD work.&lt;br /&gt;
&lt;br /&gt;
== Sysinfo ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
: BIOS Manufacturer: American Megatrends Inc.&lt;br /&gt;
: Release Date: 10/23/2012&lt;br /&gt;
: BIOS Version: ALASKA - 1072009&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: Board Product ID: Gigabyte 990FXA-UD3&lt;br /&gt;
&lt;br /&gt;
: AMD FX-8350 Eight-Core Processor, 4 Ghz&lt;br /&gt;
: 16 GB RAM&lt;br /&gt;
: 480 Gb SSHD&lt;br /&gt;
: 1 Tb HD&lt;br /&gt;
: 650 W power supply&lt;br /&gt;
: AMD Radeon HD 7700 with 2 Gb RAM&lt;br /&gt;
&lt;br /&gt;
Report Generated at: 1/8/2013 1:02:45 AM&lt;br /&gt;
&lt;br /&gt;
OK, so the machine is sneaking up on its third year in service.  It still gets a decent rating from me and Windows:&lt;br /&gt;
&lt;br /&gt;
[[File:Homebrew 5 performance.jpg]]&lt;br /&gt;
&lt;br /&gt;
And, as with everything else except for Wikimedia version and the WAMPserver versions, I haven&#039;t changed anything from last week, when all was well in wikiland.&lt;br /&gt;
&lt;br /&gt;
=== OS ===&lt;br /&gt;
&lt;br /&gt;
: Windows 7 Professional, 64-bit&lt;br /&gt;
: Service Pack 1&lt;br /&gt;
&lt;br /&gt;
=== Browser ===&lt;br /&gt;
&lt;br /&gt;
: Chrome 46.0.2490.86 m&lt;br /&gt;
&lt;br /&gt;
=== Software Guardians ===&lt;br /&gt;
&lt;br /&gt;
: Malware Bytes&lt;br /&gt;
::: Set to exclude 127.0.0.1, httpd.exe, and mysql.exe from inspection.&lt;br /&gt;
&lt;br /&gt;
: CylanceProtect&lt;br /&gt;
::: I&#039;ve got no control over this.  All I can say is that with MediaWiki 1.20, I had no connection problems.&lt;br /&gt;
&lt;br /&gt;
: Firewall&lt;br /&gt;
::: Made sure port 3306 is open.&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround ==&lt;br /&gt;
&lt;br /&gt;
Because the connection ALWAYS worked on the very next try after a failure, I thought that perhaps I could arrange a sacrificial connection to feed the ravenous Connection Monster; while it was chomping on the carcass, the real Mediawiki connection might sneak by unnoticed.&lt;br /&gt;
&lt;br /&gt;
So I put this in my LocalSettings.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$servername = &amp;quot;127.0.0.1&amp;quot;;&lt;br /&gt;
$username = &amp;quot;dbuser&amp;quot;;&lt;br /&gt;
$password = &amp;quot;dbuserpassword&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Create connection&lt;br /&gt;
$conn = new mysqli($servername, $username, $password);&lt;br /&gt;
&lt;br /&gt;
// Check connection&lt;br /&gt;
if ($conn-&amp;gt;connect_error) {&lt;br /&gt;
    die(&amp;quot;Connection failed: &amp;quot; . $conn-&amp;gt;connect_error);&lt;br /&gt;
} &lt;br /&gt;
#echo &amp;quot;Connected successfully&amp;quot;;&lt;br /&gt;
mysqli_close($conn);&lt;br /&gt;
#die(&amp;quot;test finished&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This idiotic connection hasn&#039;t ever failed yet.&lt;br /&gt;
&lt;br /&gt;
And the wiki page hasn&#039;t yet failed to connect afterward, either.&lt;br /&gt;
&lt;br /&gt;
Pasta faggiole!&lt;br /&gt;
&lt;br /&gt;
I hate it.&lt;br /&gt;
&lt;br /&gt;
But not as much as I hate seeing the &amp;quot;connection failed&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Not yet, anyway.&lt;br /&gt;
&lt;br /&gt;
Using the [http://php.net/manual/en/book.hrtime.php &#039;&#039;hrtime&#039;&#039; extension,] I can see that this little connection check only takes a couple of milliseconds, so it&#039;s not costing me huge time in loading pages.  &lt;br /&gt;
&lt;br /&gt;
I&#039;m going to let it ride for a while, FWIW.&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.mail-archive.com/mediawiki-commits@lists.wikimedia.org/msg283522.html [MediaWiki-commits] [Gerrit] Add support for connect_timeout -	change (mediawiki...PoolCounter)]&lt;br /&gt;
:: The intriguing line: &#039;&#039;we implement here what we already do for mysql connections: if we set a connection timeout to a very small value (in the order of magnitude of twice the RTT to the poolcounter server) and retry twice, we can have very fast failures in case one server goes down, and the failover to the other active servers would happen almost harmlessly.&#039;&#039;  &lt;br /&gt;
:: I&#039;m convinced this is a clue, but I haven&#039;t waded into the code to see what I might be able to play with.  &lt;br /&gt;
* [http://serverfault.com/questions/408550/connecting-to-mysql-from-php-is-extremely-slow &amp;quot;Connecting to MySQL from PHP is extremely slow&amp;quot;]&lt;br /&gt;
:: David Random&#039;s essay on this page is superb.  It didn&#039;t fix what ailed me, but it made me feel that I was understanding the problem better.&lt;br /&gt;
* [https://ineed.coffee/1441/apache-php-mysql-slow-under-windows-8-how-to-fix/ &amp;quot;Apache, PHP, MySQL slow under Windows 8. How to fix.&amp;quot;]&lt;br /&gt;
:: Contains an excellent set of links to various tips and tricks, as well as making some fresh suggestions.&lt;br /&gt;
&lt;br /&gt;
[[Category:Computers]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
	<entry>
		<id>https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16389</id>
		<title>WAMP, localhost, Mediawiki: Cannot access the database</title>
		<link rel="alternate" type="text/html" href="https://moleski.net/cacwiki/index.php?title=WAMP,_localhost,_Mediawiki:_Cannot_access_the_database&amp;diff=16389"/>
		<updated>2015-12-03T00:16:11Z</updated>

		<summary type="html">&lt;p&gt;Laura: /* Ugly Workaround */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;This is just a draft.  There is more to the story than this.  I&#039;m still googling and tweaking.  Stay tuned for more morbid details on The Bug that Ate a Week of My Life!&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mediawiki on localhost ==&lt;br /&gt;
&lt;br /&gt;
Since 2:42 PM on 14 March 2009, I have run a private wiki for myself on a WAMP stack--6.5 years and counting.&lt;br /&gt;
&lt;br /&gt;
I have migrated the wiki from one desktop to another and installed it on two different laptops.&lt;br /&gt;
&lt;br /&gt;
I have never had everything work perfectly right out of the box, but I have never been frustrated for too long.  People have solved all of the basic problems more than once, and it has been just a matter of googling around long enough to debug the setup.&lt;br /&gt;
&lt;br /&gt;
All that has changed.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve found a bug that has defeated me.&lt;br /&gt;
&lt;br /&gt;
== Mediawiki 1.26, WAMPserver 2.5, and WAMPserver 3 ==&lt;br /&gt;
&lt;br /&gt;
== Error Messages ==&lt;br /&gt;
&lt;br /&gt;
=== Shorter version ===&lt;br /&gt;
&lt;br /&gt;
Sorry! This site is experiencing technical difficulties.&lt;br /&gt;
&lt;br /&gt;
Try waiting a few minutes and reloading.&lt;br /&gt;
&lt;br /&gt;
(Cannot access the database)&lt;br /&gt;
&lt;br /&gt;
=== With debugging and backtracking enabled ===&lt;br /&gt;
&lt;br /&gt;
Cannot access the database: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ())&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Backtrace:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
:  #0 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(842): DatabaseBase-&amp;gt;reportConnectionError(&#039;Unknown error (...&#039;)&lt;br /&gt;
:  #1 C:\wamp\www\mediawiki\includes\db\LoadBalancer.php(537): LoadBalancer-&amp;gt;reportConnectionError()&lt;br /&gt;
:  #2 C:\wamp\www\mediawiki\includes\GlobalFunctions.php(3631): LoadBalancer-&amp;gt;getConnection(-1, Array, false)&lt;br /&gt;
:  #3 C:\wamp\www\mediawiki\includes\User.php(1208): wfGetDB(-1)&lt;br /&gt;
:  #4 C:\wamp\www\mediawiki\includes\User.php(397): User-&amp;gt;loadFromDatabase(0)&lt;br /&gt;
:  #5 C:\wamp\www\mediawiki\includes\User.php(362): User-&amp;gt;loadFromId(0)&lt;br /&gt;
:  #6 C:\wamp\www\mediawiki\includes\User.php(2459): User-&amp;gt;load()&lt;br /&gt;
:  #7 C:\wamp\www\mediawiki\includes\User.php(1167): User-&amp;gt;getToken(false)&lt;br /&gt;
:  #8 C:\wamp\www\mediawiki\includes\User.php(365): User-&amp;gt;loadFromSession()&lt;br /&gt;
:  #9 C:\wamp\www\mediawiki\includes\User.php(2029): User-&amp;gt;load()&lt;br /&gt;
:  #10 C:\wamp\www\mediawiki\includes\User.php(3204): User-&amp;gt;getId()&lt;br /&gt;
:  #11 C:\wamp\www\mediawiki\includes\MediaWiki.php(627): User-&amp;gt;isLoggedIn()&lt;br /&gt;
:  #12 C:\wamp\www\mediawiki\includes\MediaWiki.php(476): MediaWiki-&amp;gt;main()&lt;br /&gt;
:  #13 C:\wamp\www\mediawiki\index.php(51): MediaWiki-&amp;gt;run()&lt;br /&gt;
:  #14 {main}&lt;br /&gt;
&lt;br /&gt;
:  reportConnectionError &amp;quot;Unknown error&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Failure message when MySQL is totally disabled ===&lt;br /&gt;
&lt;br /&gt;
Warning: mysqli::mysqli(): (HY000/2002): No connection could be made because the target machine actively refused it. in C:\wamp\www\mediawiki\LocalSettings.php on line 152&lt;br /&gt;
&lt;br /&gt;
Connection failed: No connection could be made because the target machine actively refused it.&lt;br /&gt;
&lt;br /&gt;
== Not a code or configuration problem ==&lt;br /&gt;
&lt;br /&gt;
Except for a few times when I shot myself in the foot while debugging, the proof that the PHP code base and my configuration are correct is that I can immediately obtain the page I want by reloading the page.  &lt;br /&gt;
&lt;br /&gt;
It is only on the first call after a long time (five minutes? ten?) of not accessing the wiki that the problem occurs.&lt;br /&gt;
&lt;br /&gt;
== Timing is everything ==&lt;br /&gt;
&lt;br /&gt;
The most common time for the bug to bite is when I open my browser.&lt;br /&gt;
&lt;br /&gt;
I&#039;ve got two tabs to pages on the local wiki in my collection of home pages.&lt;br /&gt;
&lt;br /&gt;
The first one usually fails if I&#039;ve had the browser closed for a while; the second never does.&lt;br /&gt;
&lt;br /&gt;
I dropped the second page from the set to see if that would help the first. &lt;br /&gt;
&lt;br /&gt;
It didn&#039;t.&lt;br /&gt;
&lt;br /&gt;
Once MySQL is awakened from its slumbers, all the links in the wiki work reasonably well--no worse than ever before--unless I spend a long time composing a page, and then the connection fails when I try to save the page.  Refresh the page, and it saves perfectly.&lt;br /&gt;
&lt;br /&gt;
Something somewhere keeps MySQL from answering the FIRST request for a connection in the time frame that Mediawiki expects.  After that, everything is normal enough until MySQL decides to fall asleep again.&lt;br /&gt;
&lt;br /&gt;
== Round up the usual suspects ==&lt;br /&gt;
&lt;br /&gt;
It&#039;s some interaction between Windows, Apache, MySQL, and the Wikimedia routines that has got me down.&lt;br /&gt;
&lt;br /&gt;
Why can&#039;t we all just get along?&lt;br /&gt;
&lt;br /&gt;
The articles in the [[#Links|links below]] have got excellent information and links in them.  They cover pretty much everything I&#039;ve tried, and then some.  I&#039;m just going to list the failed fixes that float into mind:&lt;br /&gt;
&lt;br /&gt;
* turn off IPv6 on my machine&lt;br /&gt;
* have Apache listen only to 127.0.0.1:80&lt;br /&gt;
* bind MySQL to 127.0.0.1 &lt;br /&gt;
* turn off name resolution in MySQL&lt;br /&gt;
* change localhost to 127.0.0.1 everywhere I can to avoid DNS calls&lt;br /&gt;
* edit Hosts file to make sure localhost is defined&lt;br /&gt;
* enable opcache and install APCu&lt;br /&gt;
* turn off Zend debugger&lt;br /&gt;
* moved from WAMPserver 2.5 to 3&lt;br /&gt;
&lt;br /&gt;
Total failure, but intriguing: get MySQL to use a socket.  There are paths for it in the configuration files, but I&#039;ve never gotten it going.  I must do more googling!  It seems as though it SHOULD work.&lt;br /&gt;
&lt;br /&gt;
== Sysinfo ==&lt;br /&gt;
&lt;br /&gt;
=== Hardware ===&lt;br /&gt;
&lt;br /&gt;
: BIOS Manufacturer: American Megatrends Inc.&lt;br /&gt;
: Release Date: 10/23/2012&lt;br /&gt;
: BIOS Version: ALASKA - 1072009&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: BIOS Version: BIOS Date: 10/23/12 15:23:54 Ver: 04.06.05&lt;br /&gt;
: Board Product ID: Gigabyte 990FXA-UD3&lt;br /&gt;
&lt;br /&gt;
: AMD FX-8350 Eight-Core Processor, 4 Ghz&lt;br /&gt;
: 16 GB RAM&lt;br /&gt;
: 480 Gb SSHD&lt;br /&gt;
: 1 Tb HD&lt;br /&gt;
: 650 W power supply&lt;br /&gt;
: AMD Radeon HD 7700 with 2 Gb RAM&lt;br /&gt;
&lt;br /&gt;
Report Generated at: 1/8/2013 1:02:45 AM&lt;br /&gt;
&lt;br /&gt;
OK, so the machine is sneaking up on its third year in service.  It still gets a decent rating from me and Windows:&lt;br /&gt;
&lt;br /&gt;
[[File:Homebrew 5 performance.jpg]]&lt;br /&gt;
&lt;br /&gt;
And, as with everything else except for Wikimedia version and the WAMPserver versions, I haven&#039;t changed anything from last week, when all was well in wikiland.&lt;br /&gt;
&lt;br /&gt;
=== OS ===&lt;br /&gt;
&lt;br /&gt;
: Windows 7 Professional, 64-bit&lt;br /&gt;
: Service Pack 1&lt;br /&gt;
&lt;br /&gt;
=== Browser ===&lt;br /&gt;
&lt;br /&gt;
: Chrome 46.0.2490.86 m&lt;br /&gt;
&lt;br /&gt;
=== Software Guardians ===&lt;br /&gt;
&lt;br /&gt;
: Malware Bytes&lt;br /&gt;
::: Set to exclude 127.0.0.1, httpd.exe, and mysql.exe from inspection.&lt;br /&gt;
&lt;br /&gt;
: CylanceProtect&lt;br /&gt;
::: I&#039;ve got no control over this.  All I can say is that with MediaWiki 1.20, I had no connection problems.&lt;br /&gt;
&lt;br /&gt;
: Firewall&lt;br /&gt;
::: Made sure port 3306 is open.&lt;br /&gt;
&lt;br /&gt;
== Ugly Workaround ==&lt;br /&gt;
&lt;br /&gt;
Because the connection ALWAYS worked on the very next try after a failure, I thought that perhaps I could arrange a sacrificial connection to feed the ravenous Connection Monster; while it was chomping on the carcass, the real Mediawiki connection might sneak by unnoticed.&lt;br /&gt;
&lt;br /&gt;
So I put this in my LocalSettings.php:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$servername = &amp;quot;127.0.0.1&amp;quot;;&lt;br /&gt;
$username = &amp;quot;dbuser&amp;quot;;&lt;br /&gt;
$password = &amp;quot;dbuserpassword&amp;quot;;&lt;br /&gt;
&lt;br /&gt;
// Create connection&lt;br /&gt;
$conn = new mysqli($servername, $username, $password);&lt;br /&gt;
&lt;br /&gt;
// Check connection&lt;br /&gt;
if ($conn-&amp;gt;connect_error) {&lt;br /&gt;
    die(&amp;quot;Connection failed: &amp;quot; . $conn-&amp;gt;connect_error);&lt;br /&gt;
} &lt;br /&gt;
#echo &amp;quot;Connected successfully&amp;quot;;&lt;br /&gt;
mysqli_close($conn);&lt;br /&gt;
#die(&amp;quot;test finished&amp;quot;);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This idiotic connection hasn&#039;t ever failed yet.&lt;br /&gt;
&lt;br /&gt;
And the wiki page hasn&#039;t yet failed to connect afterward, either.&lt;br /&gt;
&lt;br /&gt;
Pasta faggiole!&lt;br /&gt;
&lt;br /&gt;
I hate it.&lt;br /&gt;
&lt;br /&gt;
But not as much as I hate seeing the &amp;quot;connection failed&amp;quot; page.&lt;br /&gt;
&lt;br /&gt;
Not yet, anyway.&lt;br /&gt;
&lt;br /&gt;
Using the [http://php.net/manual/en/book.hrtime.php &#039;&#039;hrtime&#039;&#039; extension,] I can see that this little connection check only takes a couple of milliseconds, so it&#039;s not costing me huge time in loading pages.  &lt;br /&gt;
&lt;br /&gt;
I&#039;m going to let it ride for a while, FWIW.&lt;br /&gt;
&lt;br /&gt;
== Links ==&lt;br /&gt;
&lt;br /&gt;
* [https://www.mail-archive.com/mediawiki-commits@lists.wikimedia.org/msg283522.html [MediaWiki-commits] [Gerrit] Add support for connect_timeout -	change (mediawiki...PoolCounter)]&lt;br /&gt;
:: The intriguing line: &#039;&#039;we implement here what we already do for mysql connections: if we set a connection timeout to a very small value (in the order of magnitude of twice the RTT to the poolcounter server) and retry twice, we can have very fast failures in case one server goes down, and the failover to the other active servers would happen almost harmlessly.&#039;&#039;  &lt;br /&gt;
:: I&#039;m convinced this is a clue, but I haven&#039;t waded into the code to see what I might be able to play with.  &lt;br /&gt;
* [http://serverfault.com/questions/408550/connecting-to-mysql-from-php-is-extremely-slow &amp;quot;Connecting to MySQL from PHP is extremely slow&amp;quot;]&lt;br /&gt;
:: David Random&#039;s essay on this page is superb.  It didn&#039;t fix what ailed me, but it made me feel that I was understanding the problem better.&lt;br /&gt;
* [https://ineed.coffee/1441/apache-php-mysql-slow-under-windows-8-how-to-fix/ &amp;quot;Apache, PHP, MySQL slow under Windows 8. How to fix.&amp;quot;]&lt;br /&gt;
:: Contains an excellent set of links to various tips and tricks, as well as making some fresh suggestions.&lt;br /&gt;
&lt;br /&gt;
[[Category:Computers]]&lt;/div&gt;</summary>
		<author><name>Laura</name></author>
	</entry>
</feed>