Tuesday, October 28, 2008

Named properties bloat

Every mail item has some MAPI properties on them perhaps some non MAPI properties. Each of these properties get’s an ID and is store in the Named properties cache table. This table is located in each Exchange database and consist of three categories, nonMAPI properties, MAPI properties and Replication ID’s
Named property cache has a limit of 32766 ID’s. You can monitor how much of the table that is used with performance counter but you must first enable additional Information Store logging. http://support.microsoft.com/?kbid=254606 Article is for older version of Exchange, but it still apply for Exchange 2007

Change the Library string located in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MSExchangeIS\Performance
Change the string value from c:\exchsrvr\bin\mdbperf.dll to C:\Program Files\Microsoft\Exchange Server\bin\mdbperfX.dll (or to wherever your mdbperfx.dll is located)
After you modify this registry value, you must restart Performance Monitor to see the new counters. The new counters are located under the MSExchangeIS Mailbox and MSExchange Public object. Counters that you should monitor is:
Rows in NamedProps Table
Rows in ReplidMap Table
Rows in NamedProps Table
Rows in ReplidMap Table

How does the named properties table get populated?
Remember that this table is per database, this means that when a message is stored in a database, property ID’s from the message is stored in named properties table and if those ID doesn’t exist they will be added. So over time this table grows. Message can be from outlook, a public folder replication message or a message received by SMTP.

Properties on messages within Exchange are transferred with help of the XEXCH50 blob or with help of X- headers. X- Header in SMTP messages is not mandatory and is user defined. This means that if some application wants to add functionality to SMTP they can add their own commands with help of the X- header. For more info about X- header see RFC822 and Extension-Field and User-Defined-Field. http://tools.ietf.org/html/rfc822
X- headers cannot only be for additional SMTP verbs but also for transferring information so when Exchange receives a mail with some x- header in it, Exchange will translate this x-header to a named property.
Exchange writes info to application log when there is something added to namedprop table.
Here you see the ‘x-myownheader’ getting added.

EventID: 9873
Source: MSExchangeIS
A named property has been created for the database "/o=Home/ou=Exchange Administrative Group (FYDIBOHF23SPDLT)/cn=Configuration/cn=Servers/cn=MB2/cn=Microsoft Private MDB".
ID: 0x8519
Named property GUID: 00020386-0000-0000-c000-000000000046
Named property name/ID: x-myownheader
The following user is attempting to create the named property: "N/A"
Protocol: MAPI
Client type: Transport
Client version: 2049.0.33059.1

This is all good, but there is one problem, you can run out of space in the named properties table and when this happens you’re in deep problem since it will cause mail flow issues.
Here is some more info about named properties http://technet.microsoft.com/en-us/library/bb851495(EXCHG.80).aspx there is also a resolution at the end of the article.
The short version is to move all mailboxes to another database, delete the original database files and move mailboxes back to its original database, nothing you want to do more than necessary.
Here is more info about this problem http://technet.microsoft.com/en-us/library/bb851492(EXCHG.80).aspx

When this table start to get near the quota limit you get warnings in the application eventlog like this.

The number of named properties created for database "SG02\Store02" is close to quota limit.
Current number of named properties: 8172
Quota limit for named properties: 8192
User attempting to create the named property: "MB2$"
Named property GUID: 00020386-0000-0000-c000-000000000046
Named property name/id: "x-myownheader"

There is some tweaking you can do regarding to the cache, but it will probably not help you in the long run since there is a hardcoded upper limit on 32766 ID’s in the table. http://technet.microsoft.com/en-us/library/bb851493(EXCHG.80).aspx

How to stop the named prop table population?
Well you cannot stop the population but you can stop unwanted x- headers to reach Information Store and that will stop most of the population. Most of these x- headers come with mail received from Internet. If you have a gateway that can strip out the x-headers from mail you’re lucky. If you don’t have this functionality in your gateway you can install the HeaderFilterAgent on your Exchange 2007 Edge or Hub server. Download and installation instruction is at http://www.codeplex.com/HeaderFilterAgent

This beautiful small piece of code strips all x- headers from anonymous received mail except from a white list that you can create. By only handle anonymous mail; you will allow mail between Exchange servers flow untouched.
This agent is something that help protect your databases from getting the named properties table full and you into trouble.

But what if you don’t have Exchange 2007?
With Exchange 2003 or Exchange 2000 you should be able to write a SMTP transport sink that does the same thing even though it’s much harder than writing managed code for Exchange 2007.
There is also KB 941060 http://support.microsoft.com/kb/941060 that doesn’t say it handles namedproperties cache but it contains some other handling that decrease the problem a bit.
of course you can also put an Exchange 2007 Edge or Hub server role in front of your Exchange 2000/2003 servers and run HeaderFilterAgent on Exchange 2007