in

SharePoint Blogs

The Best Place for SharePoint-related Blogs

Sander's Blog

July 2008 - Posts

  • Using database snaphots for testing SharePoint

    This can be a real time-saver! Do you know of the concept of Snapshots in SQL Server 2005? No? It is one of the new features available in the Enterprise edition of SQL 2005.

    Database Snapshots allows you to create a read-only copy of your database that can be used for other purposes, such as reporting, auditing or recovering data. Currently, you can do that by running a backup and restoring it to another database. However, the big advantage you gain by using Database Snapshots instead is the speed at which a snapshot occurs, as well as the ability to create multiple snapshots at different points in time quickly.

    If you want to read more about the concept, the advantages and the disadvantages you can read the great post of Greg Robidoux at:
    http://searchsqlserver.techtarget.com/tip/0,289483,sid87_gci1176142,00.html#cons

    For SharePoint development it is a great way to test some configuration, and if you changed your mind, roll back all the changes you've made in just a few seconds! This can be handy for testing scripts, for manual configuration in the UI, or for example to give demo's.

    The following scripts create and restore a snapshot on a SharePoint Content Database (please see the limitions at the bottom of this post)

    Creating the snapshot

    To create the snapshot you can run the following T-SQL (run a new Query dialog in SQL Server Management Studio or create a .sql file)

    CREATE DATABASE WSS_Content_Snapshot ON -- [The name of the snapshot]
    (
        NAME = WSS_Content_Snapshot, -- [The name of the logical filename]
        FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Data\Snapshots\WSS_Content_Snapshot.ss'  -- [The filename and location of the snapshot]
    )

    AS SNAPSHOT OF WSS_Content -- [The original Content Database]

    Restoring 

    Restoring a database is as easy as the following line:
    RESTORE DATABASE WSS_Content FROM DATABASE_SNAPSHOT = 'WSS_Content_Snapshot'

    You might run into an error if other users (SharePoint processes) are still connected to the database: 

    Database state cannot be changed while other users are using the database 'WSS_Content'
    RESTORE DATABASE is terminating abnormally.

    To avoid this you can first run a script to kill all existing processes:

    -- First, kill all active processes
    DECLARE @DatabaseName nvarchar(50)
    SET @DatabaseName = N'WSS_Content'

    DECLARE @SQL varchar(max)
    SET @SQL = ''

    SELECT @SQL = @SQL + 'Kill ' + Convert(varchar, SPId) + ';' FROM MASTER..SysProcesses WHERE DBId = DB_ID(@DatabaseName) AND SPId <> @@SPId

    EXEC(@SQL)

    -- Second, Restore the database from the snapshot
    RESTORE DATABASE WSS_Content FROM DATABASE_SNAPSHOT = 'WSS_Content_Snapshot'

    Limitions

    Please note that the snapshot above is limited to the Content Database, the changes you can restore include:
    - Adding/Deleting/Editing Subsites
    - Adding/Deleting/Editing Lists
    - Adding/Deleting/Editing List-items
    - Adding/Deleting/Editing Content Types
    - Adding/Deleting/Editing Webparts
    -
    Enabling/Disabling Features
    - Adding/Deleting/Editing Workflows
    - Editing the Navigation
    - Editing the Sitecollection in the Site Settings (not deleting or creating sitecollections!)
    - ...

    Some things you cannot do:
    - Sitecollections are registered in the configuration database, if you add or delete sitecollections you must ensure you also snapshot the configuration database
    - Solution packages (wsp files) are registered at the Farm level, if you add or delete solution packages you must ensure you also snapshot the configuration database

    This is not an exhausting list, please beware of any configuration done at the Farm level since this is registered in the configuration database. If you really want to snapshot your whole environment I suggest you lock all databases, create snapshots of all databases and restore all databases at the same time. You might want to try some variations, but I would not recommend using it in any environment containing critical data since it is not supported my MS. 

  • Troubleshooting tempdb growth when crawling SharePoint data

    Today I received a message from our Database admin concerning the Temp Database. It seems a SharePoint process is filling the TempDB up to 15gb. After that it reaches it physical limit (disk space is very limited..) and throws an exception:

    "The transaction log for database 'tempdb' is full. To find out why space in the log cannot be reused, see the log_reuse_wait_desc column in sys.databases"

    From this moment on you can consider your SQL server to be crashed, since probably every application uses the Temp database and every query using the TempDB will result in an error.

    If you follow the suggestion given in de event-log exception you're going to check the log_reuse_wait_desc, in my case this quotes: "ACTIVE_TRANSACTION".
    In the SQL Server Activity Monitor you can see the current application using the TempDB is "Windows SharePoint Server". The details of this activity shows that there is a MOSS Crawler stored procedure (forgot to copy the name) running.

    Usually the crawler will use the Temp DB while indexing, it will then flush this data to the file system and clear the Temp database. I don't know what triggers this 'flush', but I assume it flushes between different sitecollections. Why this assumption?
    1. Because I've only got 1 (extremely large) sitecollection to index and the Temp database never shrinks in the crawl process, it just grows until it crashes.
    2. Because I can't find any other information about this process..

    When you will stop a crawl (Manage Content Sources -> Stop Crawl) it will wait until the current data is flushed, in my case  (1 extremely large sitecollection) this means it will wait until it crashes. After it crashes you'll have to empty the Temp database manually. 

    I'm now in the process of telling SharePoint not to do the crawling. This is not easy since it must complete the current crawl before it can flush the data and inherently stop crawling. You can't even stop the "Microsoft Office SharePoint Search" service, it will tell you it's busy. To stop this thing you will really need to kill the MSSearch process (I don't advice you to do this, but it is a last resort..).

    After you've killed the process it is automatically started again by the "Microsoft Office SharePoint Search" service. Workaround is to disable the service and then kill the process. 

    Now you might think you can re-configure or re-schedule the Content Source, wrong! Since you've stopped the "Microsoft Office SharePoint Search" service, you cannot use the Search Settings pages in your Shared Service Provider. 

    Once you will re-start the "Microsoft Office SharePoint Search" service it will automatically continue the Crawl, even before you can stop it. 

    Following question will now be; how can I stop this full Crawl? As far as I found I've got 2 options left:
    1. Give the Temp database more space and wait for the crawl to be finished
    2. Hack in the database to remove the current Crawl according to this thread: http://msmvps.com/blogs/obts/archive/2006/12/18/432542.aspx
    3. ...

    Of course I opt for the first one which is obviously the most healthy and logical option. 

    I hope you will never need it, but if you will you now have my experience at your dispense..

  • [Dutch] Nintex Workflow presentation - DIWUG

    (Sorry for this post being Dutch. Tonight I presented Nintex workflow at the Dutch Information Worker Group. In this post I will publish the sheets and code I've used)

    In navolging tot de Nintex Workflow presentatie kan je nu de slides downloaden van m'n blog.

    Ik heb de presentatie bijgewerkt met:
    - Een aantal dingen die ik vergeten ben
    - Toelichtingen en details over de demo's
    - Verwijzigingen naar help-files en de Nintex SDK
    - Contact gegevens 
    - De cut-scenes: sheets die de presentatie niet gered hebben..

    De code voor een Custom Activity project kan je eveneens downloaden van m'n blog. Gebruik hierbij de Nintex SDK om dit voorbeeld te installeren en aan te passen.

    Ik wil jullie via deze weg nogmaal bedanken voor de grote opkomst en de interesse. Vragen kan je uiteraard kwijt in de comments.

    Sander


Need SharePoint Training? Attend a SharePoint Bootcamp!

Posts (c) their respective authors. Everything else (c) 2007 SharePoint Experts