Saturday, May 24, 2008

SharePoint Database Connection Timeout

So, I'm writing this program that imports content of a medical encyclopedia into a SharePoint publishing site. The content is delivered in the form of about 1500 XML files with each file representing a page in the encyclopedia. Data in each XML file describes how each page is linked the overall structure. (For the most part, it's a tree. Though a few pages have more than one parent.)

Anyway, while the import program works fine, I noticed while running it inside of my very overworked virtual machine, SQL Server periodically goes to "out to lunch" and pegs the CPU to 100% for a few minutes. I guess it's reorg-ing something or another. During that time, the SharePoint API will occasionally throw a "can't connect to the database" exception. Apparently the 45 second default value for timing out connection attempts to the SharePoint database is insufficient. Ouch.

Fortunately, bumping up the timeout value is easy with stsadm. Just invoke the following command to bump it up to (for example) 3 minutes.

stsadm -o setproperty -pn database-connection-timeout -pv 180

No comments: