in

Community Blogs

Blogs of different SQL/Developers Community Members

This Blog

Syndication

DamirDobric

prosinac 2010 - Posts

  • AppFabric Purge

    AppFabric Server has a feature called “automatic purge”. The purpose of this feature is to automatically and regularly check the growth of an AppFabric monitoring database on disk and reduce its disk footprint when needed. This ensures that a monitoring database does not grow uncontrollably and consume too much space on disk.

    The automatic purge operations are driven by a SQL Server stored procedure that AppFabric installs when it initializes the ApplicationServerMonitoring database during setup. There is one table in the AppFabric database called ASJobsTable.
    This table contains the list of several jobs which are scheduled by AppFabric Server. Here you can see if the purge operation has been started at all. The picture below shows that purge operation has been successfully  completed.

    image

    There is also another table ASConfigurationPropertiesTable which contains configuration parameters purging-stored procedure.

    image

    Each value in this table defines the behavior of purge operation. Following table (copied from MSDN site) describes all of them.

    Column Name Column Type Default Description

    ArchiveServer

    Nvarchar(128)

    NULL

    The name of a SQL server that is hosting a monitoring database.  This database will be used for archiving monitoring data.

    ArchiveDatabase

    Nvarchar(128)

    NULL

    The name of a monitoring database.  This database will be used for archiving monitoring data.

    APEnabled

    bit

    1

    Enables or disabled automatic purging of monitoring data.  When set to 1, the database will automatically purge data based on the other auto-purge configuration properties.

    APThreshold

    int

    1500

    This property is only read if APEnabled is set to 1.  When the size of the database exceeds this threshold (approximated in megabytes), the automatic purge is engaged and monitoring data will be deleted in accordance with the APTrimPercentage configuration property.

    APMaxEventAge

    float

    NULL

    This property is only read if APEnabled is set to 1.  Any monitoring event in the database that is older than this property’s value (in days) will be deleted.

    APTrimPercentage

    int

    10

    This property is only read if APEnabled is set to 1.  When the APThreshold purge mechanism engages, approximately APTrimPercantage percent of the oldest monitoring data will be deleted, making room for new data. The default value of this is 10 percent.

    Why the Purge does not work?

    The problem with this great feature is that purge removes events from monitoring tables (ASWcfEventsTable, ASWfEventsTable), but it doesn’t rebuild indexes.
    Unfortunately this is required, because indexes can take lot of space. To illustrate this, take a look on a real data at the picture below. The picture below shows that the largest table is ASWcfEventsTables.
    This is as expected, because the system consists majorly of WCF services. The WCF events take 13.5 GB in the table, after the purge has been successfully completed. 
    I noticed that last purge-operation has been successfully finished one hour before I created the report shown on the picture.

    image

    To workaround this issue you will have to manually rebuild indexes of largest tables. Following picture shows how to do this within SQL Management Studio:

    image

    After you have selected “Rebuild All” one dialog will appear (not shown here). Just confirm with OK and rebuild process will be started. In a case of ASWcfEventsTable (13.5 GB), this has taken 2-3 minutes at my server.
    The result looks now like shown at the next picture.

    image

    You will notice that the ASWcfEventsTable is no more the critical one. It  takes now just about 10MB. In my case I have rebuild indexes for ASWfEventsTable too.

    Recap:

    If the purge does not shrink size of monitoring tables as you would expect, rebuild indexes of ASWcfEventsTable and ASWfEventsTable manually.

     

    Hope this helps.

    Damir

    Posted pro 29 2010, 03:40 by anonymous
    Filed under:
  • Optimizing Performance

    Below is a list of self-help resources for this scenario. These resources may also be used by Microsoft Support Engineers during an Advisory Services engagement.

    http://support.microsoft.com/default.aspx?scid=kb;EN-US;974348

  • How to obtain a host instance within a workflow service?

    The Workflow Foundation programming model introduces a Workflow Service as a way to build a reach and robust long running composite applications. This model does not allow one to access the host.
    Unfortunately, sometimes it is required to access the host. For example, if you need to know the file name of the workflow, when building more sophisticated workflows.

    To make this working you need to implement interface IReceiveMessageCallback.

     

        /// <summary>

        /// This class implements interface which has a callback method, which is invoked
        /// when a message operation is invoked.

        /// This context.Properties.Add("ReceiveInstanceCallback", new ReceiveInstanceCallback());

        /// </summary>

        [DataContract(Namespace=”http://daenet.eu/accesshost”)]
        class ReceiveInstanceCallback :
    IReceiveMessageCallback

        {
            public void OnReceiveMessage(System.ServiceModel.OperationContext operationContext,
                        System.Activities.ExecutionProperties activityExecutionProperties)

            {
                 // This sets the instance of the host to Workflow instance.           
                
    WorkflowSchedulerActivity.ServiceHost = operationContext.Host as WorkflowServiceHost ;
            }
        }

    The method OnReceiveMessage provides you access to operation context and all hidden WCF staffs you might need. To make it working you will need to register it.
    A good place for it is in Execute method of an activity, which is executed before receive activity.

     

    protected override void Execute(NativeActivityContext context)

    {
         context.Properties.Add("ReceiveInstanceCallback", new ReceiveInstanceCallback());

    }

    Posted pro 14 2010, 11:44 by anonymous
    Filed under: ,
  • Workflow Compensation Sample

    Create an activity of type CompensableActivity add CompensationHandler and ConfirmationHandler:

    image

    Then create a variable of type CompensationToken . For example with name ‘token’ as shown below.

    image
    Select MyActivity and enter the name of CompensationToken variable:

    image

    Then you can use (out of CompensableActivity)  Compensate and/or Confirm Activities. Booth need a proper Target property set on the CompensableToken value:

    image   image

    Note that example shows both Confirm and Compensate. In a real world only one of them can be used!

    Posted pro 14 2010, 10:34 by anonymous
    Filed under:
  • Windows Azure SQL Server T-SQL issues

    When you move one database form SQL Server to Windows Azure SQL Server by using of SQL scripts you will run into several issues which are not that obvious.
    SQL Server in Windows Azure platform does not support full T-SQL. Here are few examples:

    This is the simple table which I want to move to Windows Azure SQL Server:

    USE AzureDb

    CREATE TABLE [calc].[TClient](
        [ID] [bigint] IDENTITY(1,1) NOT NULL,
        [Name] [nvarchar](50) NOT NULL,
        [ChangedBy] [nvarchar](50) NULL,
        [ChangedAt] [datetime] NULL,
        [CreatedBy] [nvarchar](50) NULL,
        [CreatedAt] [datetime] NULL,
        [ExternalId] [nvarchar](256) NULL,
        [ExternalSystemId] [nvarchar](20) NULL,
    CONSTRAINT [PK_TMandate] PRIMARY KEY CLUSTERED
    (
        [ID] ASC
    )WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]

    After you start this script following error appears:

    Msg 40508, Level 16, State 1, Line 1
    USE statement is not supported to switch between databases. Use a new connection to connect to a different Database
    .

    No problem. Just remove statement USE AzureDb.

    Now execute script again and uupss:


    Msg 40517, Level 16, State 1, Line 14
    Keyword or statement option 'pad_index' is not supported in this version of SQL Server.

    To work around this issue remove following part of script:

    WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
    ) ON [PRIMARY]

     

    At the end you script should look like:

    CREATE TABLE [tracking].[TClient](
        [ID] [bigint] IDENTITY(1,1) NOT NULL,
        [Name] [nvarchar](50) NOT NULL,
        [ChangedBy] [nvarchar](50) NULL,
        [ChangedAt] [datetime] NULL,
        [CreatedBy] [nvarchar](50) NULL,
        [CreatedAt] [datetime] NULL,
        [ExternalId] [nvarchar](256) NULL,
        [ExternalSystemId] [nvarchar](20) NULL,
    CONSTRAINT [PK_TMandate] PRIMARY KEY CLUSTERED
    (
        [ID] ASC
    ))

     

    This will work fine. This post might help you to solve your problem. Unfortinatelly my problem is that my script has contained 100+ tables Sad smile

    Posted pro 12 2010, 12:20 by anonymous
    Filed under: ,
  • Accessing Access Control Service in Windows Azure AppFabric

    When working with Access Control Service provided by Windows Azure AppFabric there is one “invisible fact”, which you have to b aware of.
    Following code snippet shows how to request the token by Access Control Service:

      NameValueCollection values = new NameValueCollection();
      values.Add("wrap_name", "gettingstarted");
      values.Add("wrap_password", issuerKey);

      values.Add("wrap_scope", http://localhost/ACSGettingStarted);
     

      byte[] responseBytes = client.UploadValues("WRAPv0.9/", "POST", values);
     

      string response = Encoding.UTF8.GetString(responseBytes);

    Note that the code shown above use original issuer and scope as provided in the SDK sample.
    When you execute this sample you will need to enter the namespace and the issuerKey to be able to send the request to ACS.
    The issuer key is in this case  not the management key which is usually provided by service bus in the AppFabric portal.
    If you use that one the request  (UploadValues) will fail with following error:

    "The remote server returned an error: (401) Unauthorized."

    If you dig in the fiddler for exact response you will find something like this:

    “Error:Code:401:SubCode:T2001:Detail:The issuer does not exist, or the secret or signature is invalid.”

    To fix this, open the Access Control Service Management Browser, which is installed with ACS samples. ?:\????\WindowsAzureAppFabricSDKSamples_V1.0-CS\AccessControl\ExploringFeatures\Management\AcmBrowser

    When using this tool enter the service namespace (this is hopefully clear) and the Management Key. Then lick on toolbar icon open “Load from Cloud”. After that you will get something like shown at the picture below.
    Note that is required to execute Setup.cmd provided by ACSGettingStarted sample (also contained in the same SDK). Setup.cmd will create the issuer, scope and policy shown at the picture.


    image

     

     

     

     

     

     

     

     

     

     

    The red frame show aht key has to be provided as issuerKey-parameter in the code above.

  • Windows Azure Forums

    Here is the list of all Windows Azure platform related forums.

     

Copyright of SQL/Developers Community
Powered by Community Server (Commercial Edition), by Telligent Systems