Showing posts with label scenario. Show all posts
Showing posts with label scenario. Show all posts

Monday, March 19, 2012

Blocking with RECEIVE and SqlDataReader for real-time updates

I have this scenario which is working fine, but would like to know if others have tried it or can recommend a better approach. Below is a brief description, but code should fully explain:

A process updates a SQL Server table via a stored proc, which in turn writes information to a service broker target queue. In my client/server architecture, I would like clients to see this new information as soon as it gets written to the target queue. To do this, I have a WCF service that calls a stored procedure; the stored proc contains an infinite loop which has a RECEIVE statement with an infinite timeout. Once RECEIVE reads data from the SB queue, data is retrieved via a SqlDataReader and results are sent to clients via a pub/sub. I then wait for more rows until RECEIVE unblocks and so on.

Stroed Proc

Code Snippet

-- ...
WHILE 1 = 1
BEGIN
-- Param declarations

...

BEGIN TRANSACTION;
WAITFOR
(
-- Blocks while TargetQueue is empty
RECEIVE
TOP(1)
@.conversation_handle = conversation_handle,
@.message_type_name = message_type_name,
@.conversation_group_id = conversation_group_id,
@.message_body =
CASE
WHEN validation = 'X' THEN CAST(message_body AS XML)
ELSE CAST(N'' AS XML)
END
FROM [dbo].[TargetQueue] -- No time out!
)

-- Handle errors
...

-- Return received information. After this statement is executed,
-- reader.NextResult unblocks and reader.Read() can read these
-- new values
SELECT 'Conversation Group Id' = @.conversation_group_id,
'Conversation Handle' = @.conversation_handle,
'Message Type Name' = @.message_type_name,
'Message Body' = @.message_body ;

COMMIT TRANSACTION


END -- WHILE

C# Code

Code Snippet

// Create a SqlCommand, and initialize to execute above stored proc
// (set command time to zero!)
...

// ExecuteReader blocks until RECEIVE reads data from the target queue
using (SqlDataReader reader = cmd.ExecuteReader())
{
// Begin an infinite loop
while (true)
{
// Process data retrieved by RECEIVE
while (reader.Read())
{
Trace.WriteLine("Conversation Group Id :" + reader.GetGuid(0) +
"Conversation Handle: " + reader.GetGuid(1) +
"Message Type Name : " + reader.GetString(2) +
"Message Body : " + reader.GetString(3));
// Send data via pub/sub
...
}

// Blocks until stored procedure returns another select statement
// i.e., blobks until RECEIVE unblocks and retrieves more data from queue
reader.NextResult();
} // while
}

There isn't anything wrong with your approach from what you show, but I do have a few questions:

Who ends the dialogs and how? The RECEIVE loop has to be prepared to process the with EndDialog and Error messages, otherwise you will leak conversations and your database will grow indefinetly. Also the stored procedure you mention, how does it find the dialog to send on and how does it end it?

Are the notifications important? Can you afford to loose one? You will lose notifications because WCF is cannot guarantee reliable delivery.

What scale are you talking about? One single RECEIVE loop with TOP(1) will have problems if you expect thousands of notifications per second.

|||

Remus,

Thanks for your thoughtful questions. My comments are below:

>What scale are you talking about? One single RECEIVE loop with TOP(1) will have problems if you expect thousands of notifications per second

Currently there will be less than 100 (One hundred) notifications per day. It is likely however, that these notifications will come in bursts as the process that ultimately populates the target queue (via uspSendMessage below) kicks in multiple times during the day. I can remove TOP(1) if necessary.

>Are the notifications important? Can you afford to loose one? You will lose notifications because WCF is cannot guarantee reliable delivery

Yes notifications to clients are very important as they will be used for trade position management. With WCF I am planning on using MSMQ to gurarantee delivery to clients. Is this what you meant?

> Who ends the dialogs and how? how does the stored proc find the dialog to send on and how does it end it?

I have two stored proc. uspSendMessage which updates a database table with new information, also does BEGIN DIALOG, then SEND ON CONVERSATION, then END CONVERSATION and COMMIT TRAN. uspReceiveMessage on the other hand does a RECEIVE (does not specify a conversion group id order to retreive all data), SELECT to select and send data to the SqlDataReader, END CONVERSATION, and then COMMIT TRAN.

Both stored proc from my test harness are shown below:

Code Snippet

CREATE PROCEDURE uspSendMessage

-- Add the parameters for the stored procedure here

@.CompanyName nvarchar(40),

@.PhoneName nvarchar(24)

AS

BEGIN

-- SET NOCOUNT ON added to prevent extra result sets from

-- interfering with SELECT statements.

SET NOCOUNT ON

begin try

-- Begin a transaction.

BEGIN TRANSACTION;

-- Insert data

insert into Shippers (CompanyName, Phone) values(@.CompanyName, @.PhoneName)

-- Create the message.

DECLARE @.message XML

SET @.message = N'<Shipper><CompanyName>' + @.CompanyName + '</CompanyName><Phone>' + @.PhoneName + '</Phone></Shipper>'

-- Declare a variable to hold the conversation handle, and then start the conversation

DECLARE @.conversationHandle UNIQUEIDENTIFIER

BEGIN DIALOG CONVERSATION @.conversationHandle

FROM SERVICE InitiatorService

TO SERVICE 'TargetService'

ON CONTRACT NewShipperContract

WITH ENCRYPTION = OFF;

-- Send the message on the dialog.

SEND ON CONVERSATION @.conversationHandle MESSAGE TYPE NewShipperMessage (@.message);

-- End the conversation.

END CONVERSATION @.conversationHandle

COMMIT TRANSACTION

end try

begin catch

select error_number() as ErrorNum, error_message() as ErrorMSg

-- Test XACT_STATE

IF (XACT_STATE()) = -1 -- Uncmmitable transaction state

BEGIN

ROLLBACK TRANSACTION;

END;

IF (XACT_STATE()) = 1 -- Tranaction active

BEGIN

COMMIT TRANSACTION;

END;

end catch

END

Code Snippet

CREATE PROCEDURE uspReceiveMessage

AS

BEGIN

-- SET NOCOUNT ON added to prevent extra result sets from

-- interfering with SELECT statements.

SET NOCOUNT ON;

WHILE 1 = 1

BEGIN

DECLARE @.conversation_handle UNIQUEIDENTIFIER,

@.conversation_group_id UNIQUEIDENTIFIER,

@.message_body XML,

@.message_type_name NVARCHAR(128);

BEGIN TRANSACTION;

WAITFOR

(

RECEIVE TOP(1)

@.conversation_handle = conversation_handle,

@.message_type_name = message_type_name,

@.conversation_group_id = conversation_group_id,

@.message_body =

CASE

WHEN validation = 'X' THEN CAST(message_body AS XML)

ELSE CAST(N'<none/>' AS XML)

END

FROM [dbo].[TargetQueue]

)

-- Handle error

IF @.@.ERROR <> 0

BEGIN

COMMIT TRANSACTION

BREAK

END

-- Show received information

SELECT 'Conversation Group Id' = @.conversation_group_id,

'Conversation Handle' = @.conversation_handle,

'Message Type Name' = @.message_type_name,

'Message Body' = @.message_body ;

-- If the message_type_name indicates that the message is an error

-- or an end dialog message, end the conversation.

IF @.message_type_name = 'http://schemas.microsoft.com/SQL/ServiceBroker/EndDialog'

OR @.message_type_name = 'http://schemas.microsoft.com/SQL/ServiceBroker/Error'

BEGIN

END CONVERSATION @.conversation_handle ;

END ;

COMMIT TRANSACTION

END -- WHILE

END

|||

Yazan Diranieh wrote:

>What scale are you talking about? One single RECEIVE loop with TOP(1) will have problems if you expect thousands of notifications per second

Currently there will be less than 100 (One hundred) notifications per day. It is likely however, that these notifications will come in bursts as the process that ultimately populates the target queue (via uspSendMessage below) kicks in multiple times during the day. I can remove TOP(1) if necessary.

If you will hit scalabilty problems removing TOP(1) will not help, as you are sending only one message per dialog anyway, so RECEIVE can only return one message at a time. See http://blogs.msdn.com/remusrusanu/archive/2007/04/24/reusing-conversations.aspx and http://blogs.msdn.com/remusrusanu/archive/2007/05/02/recycling-conversations.aspx on how to send more than one message per dialog. I wouldn't focus on this at the moment though.

Yazan Diranieh wrote:

>Are the notifications important? Can you afford to loose one? You will lose notifications because WCF is cannot guarantee reliable delivery

Yes notifications to clients are very important as they will be used for trade position management. With WCF I am planning on using MSMQ to gurarantee delivery to clients. Is this what you meant?

As it is now, if the process crashes after the RECEIVE was commited but before the WCF send occured (or reached the outgoing MSMQ queue), your notification is lost. You must use a distributed transaction and enroll both the SqlCommand.ExecuteReader and the WCF send in the same transaction context. This also means you cannot use one infintely executing batch, but instead loop in CLR code and call one RECEIVE at a time.

Yazan Diranieh wrote:

> Who ends the dialogs and how? how does the stored proc find the dialog to send on and how does it end it?

I have two stored proc. uspSendMessage which updates a database table with new information, also does BEGIN DIALOG, then SEND ON CONVERSATION, then END CONVERSATION and COMMIT TRAN. uspReceiveMessage on the other hand does a RECEIVE (does not specify a conversion group id order to retreive all data), SELECT to select and send data to the SqlDataReader, END CONVERSATION, and then COMMIT TRAN.

You are doing Fire-and-Forget, this will get you into trouble, see http://blogs.msdn.com/remusrusanu/archive/2006/04/06/570578.aspx. Try to end the conversation from the target side first and have the sender end its side as a response to the target's EndDialog message.

|||Very informative. Thanks very much.

Sunday, March 11, 2012

Blocking sa user

Hi All,
I have a hypothetical scenario. I have few developers who all know the sa password. I want to block one developer from accessing the SQL server eventhough he knows the sa password.

Do we have any mechanism in SQL Server 2000 to block client based on the IP address of the client?

SQl Server is installed on Windows 2000 server. It uses SQL Server & Windows authentication.

Regards,
AnandChange the sa password|||Thanks for the reply.
I know that would be the best alternative :)
But currently I am not in a position to change it immediately.

Can you suggest something else

Regards,
Anand|||sa login is built-in login as well as assigned sysadmin fixed server role. You can change sa password, but if someone knows the password he/she can login the SQL Server.

Use mixed mode security or give separate SQL Login to the developers with the db_owner or db_ddladmin database role, according to your requirement.|||How about VPN, router settings, IP or MAC filtering?|||You can filter ports to keep an IP address from making any connection to a SQL Server database, but that's rather drastic for limiting a developer. There are solutions to this problem, but all of the ones that I can think of require intimate knowledge of the problem... I don't know of any generic answer to this kind of problem.

-PatP|||change the f'n sa password

sa shouldn't be used...some writers have even suggested creating a very strong password...write it down, put it in a safe and never use it..and create a new, "unknown" login that has sa rights|||change the f'n sa password

sa shouldn't be used...some writers have even suggested creating a very strong password...write it down, put it in a safe and never use it..and create a new, "unknown" login that has sa rights

Yep. First thing I do. Select newid() (on a different server). Copy and paste results into the install screen. Forget about it. Never use sa for anything.

Regards,

hmscott|||Yep. First thing I do. Select newid() (on a different server). Copy and paste results into the install screen. Forget about it. Never use sa for anything.

Regards,

hmscott

Humm... really unique password..! :rolleyes:

blocking issue.

I have "scenario 2" blocking issue. the process is sleeping and open transac
tions is 1 or more.
However the command that was run was a prodedure that has "No Begin Transact
ion, or rollback or commit."
Any ideas?
I don't understand how the open transactions can be greater then zero.You are probably have SET IMPLICIT_TRANSACTIONS ON .
Andrew J. Kelly SQL MVP
"mannie" <anonymous@.discussions.microsoft.com> wrote in message
news:5F627C7E-59AD-4232-B80D-588E58B932C0@.microsoft.com...
> I have "scenario 2" blocking issue. the process is sleeping and open
transactions is 1 or more.
> However the command that was run was a prodedure that has "No Begin
Transaction, or rollback or commit."
> Any ideas?
> I don't understand how the open transactions can be greater then zero.|||I have not. Perhapes the default mode has been set in some configuration at
the server level. Is this possible?|||Yes, the default for a lot of drivers is to set implicit transactions on.
You can run profiler and make sure to include the Existing connections event
to see what gets set.
Andrew J. Kelly SQL MVP
"mannie" <anonymous@.discussions.microsoft.com> wrote in message
news:A558E87B-FA4C-4FE4-B4D1-15D745B50F17@.microsoft.com...
> I have not. Perhapes the default mode has been set in some configuration
at the server level. Is this possible?

Wednesday, March 7, 2012

Blocked Resources Never Release

In what appears to be a deadlock scenario, why doesn’t the deadlock manager engage and determine a victim?
Here is an example of what I am talking about:
Query 1
Select statement on table "A" with a suitable where clause to define only the records desired.
Query 2
Multiple insert statements within a single transaction to several different tables including table "A."
The resulting scenario is that query 2 has crossed the magic threshold of 1250 locks and therefore escalates its lock to a table lock. Query 1, which is now blocked, also escalates to a table lock. The two queries then sit around waiting for each other to
finish, but they never do.
Here are my questions:
The lock manager will begin escalation if a single resource is using more than 1250 locks on table resources, or 765 locks on index resources. If the machine in question has 2GB of physical memory, how big is the memory pool for locks?
Even though this isn't the classic deadlock scenario, why doesn't the deadlock manager recognize this as a deadlock and choose a victim to help free up the resources?
Thanks.
Hi,
From your descriptions, I understood that you would like to know how much
memory will be allocated to locks and what happened in the scenario you
described. Have I understood you? If there is anything I misunderstood,
please feel free to let me know
For the first question, based on my knowledge, there are no standard for
allocating memory pool for locks, so I cannot tell how much it will be
For the second question, could you reporduce ti? It is appreciated if you
could provide me some sample scenario, which, I believe, will make us
closer to the resolution.
Thank you for your patience and cooperation. If you have any questions or
concerns, don't hesitate to let me know.
Sincerely yours,
Michael Cheng
Microsoft Online Support
************************************************** *********
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks.
|||Lock Pool:
According to a resource that I have now, the number of slots in the lock hash table directly relates to physical memory size. Since we have more than 1GB of physical memory, the number of slots in the hash table is 2 to the 19th, or 512K. If this has
h table gets fulls because of the number of locks in the system does it engage the escalation process and start upgrading locks to table locks?
Block Scenario:
Yes, we can reproduce this problem very easily. The best way to do it is to setup one query to read a set of rows (< 10) from table "A." This should be the first query executed. Then while that query is running, start another query that insert at leas
t 200 rows into table "A" within a transaction. What we are seeing here is that both resources get blocked, and never return.
Let me know if you need further details. Thanks.
Ken L
|||Hello Ken,
The lock escalation attempts are never blocked in SQL Server. If the lock
threshold is crossed and we decide we want to escalate but someone holds an
incompatible lock on the table, we simply cancel the escalation attempt and
continue acquiring locks at the page, row or key level.
Also, if there was truly a simple lock-based deadlock then the deadlock
monitor should detect it and roll back one of the participants.
As far as the particulars of lock escalation thresholds, they are
undocumented and have changed between 7.0 and SQL 2000, and again with
service packs for SQL 2000.
Investigation of your scenario would need trace, blocker script and
errorlog analysis which would be done quickly and effectively with direct
assistance from a Microsoft Support Professional through Microsoft Product
Support Services. You can contact Microsoft Product Support directly to
discuss additional support options you may have available, by contacting us
at 1-(800)936-5800 or by choosing one of the options listed at
http://support.microsoft.com/default...=sz;en-us;top.
If this is not an urgent issue and your would like us to create an incident
for you and have Microsoft Customer Service Representative contact you
directly, please send email to (remove "online." from this no Spam email
address): mailto:dscommhf@.online.microsoft.com with the following
information,
*Include "Followup: <Tomcat IssueID>" in the email Subject.
*Location of the post
*Subject Line
*First Name, Last Name
*MSDN Subscriber ID
*Company name (if any)
*Phone number
*e-mail address
Thanks for using MSDN Managed Newsgroup.
Vikrant Dalwale
Microsoft SQL Server Support Professional
Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computers security.
This posting is provided "AS IS" with no warranties, and confers no rights.
--
>Thread-Topic: Blocked Resources Never Release
>thread-index: AcQ4/1L2Dymf0MfBRy6pVZIiiOpc7A==
>X-WN-Post: microsoft.public.sqlserver.server
>From: "=?Utf-8?B?S2VuIEw=?=" <visDev@.online.nospam>
>References: <AC3EA969-391B-4849-8473-99BBA5EC96B5@.microsoft.com>
<cEHqVuNOEHA.424@.cpmsftngxa10.phx.gbl>
>Subject: RE: Blocked Resources Never Release
>Date: Thu, 13 May 2004 08:31:13 -0700
>Lines: 9
>Message-ID: <24381669-EE80-4206-9EDF-8D36C1C5CA3E@.microsoft.com>
>MIME-Version: 1.0
>Content-Type: text/plain;
>charset="Utf-8"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>Content-Class: urn:content-classes:message
>Importance: normal
>Priority: normal
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
>Newsgroups: microsoft.public.sqlserver.server
>Path: cpmsftngxa10.phx.gbl
>Xref: cpmsftngxa10.phx.gbl microsoft.public.sqlserver.server:341150
>NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
>X-Tomcat-NG: microsoft.public.sqlserver.server
>Lock Pool:
According to a resource that I have now, the number of slots in the
lock hash table directly relates to physical memory size. Since we have
more than 1GB of physical memory, the number of slots in the hash table is
2 to the 19th, or 512K. If this hash table gets fulls because of the number
of locks in the system does it engage the escalation process and start
upgrading locks to table locks?
Block Scenario:
Yes, we can reproduce this problem very easily. The best way to do it
is to setup one query to read a set of rows (< 10) from table "A." This
should be the first query executed. Then while that query is running, start
another query that insert at least 200 rows into table "A" within a
transaction. What we are seeing here is that both resources get blocked,
and never return.
Let me know if you need further details. Thanks.
Ken L
>

Blocked Resources Never Release

In what appears to be a deadlock scenario, why doesn’t the deadlock manage
r engage and determine a victim?
Here is an example of what I am talking about:
Query 1
Select statement on table "A" with a suitable where clause to define only th
e records desired.
Query 2
Multiple insert statements within a single transaction to several different
tables including table "A."
The resulting scenario is that query 2 has crossed the magic threshold of 12
50 locks and therefore escalates its lock to a table lock. Query 1, which is
now blocked, also escalates to a table lock. The two queries then sit aroun
d waiting for each other to
finish, but they never do.
Here are my questions:
The lock manager will begin escalation if a single resource is using more th
an 1250 locks on table resources, or 765 locks on index resources. If the ma
chine in question has 2GB of physical memory, how big is the memory pool for
locks?
Even though this isn't the classic deadlock scenario, why doesn't the deadlo
ck manager recognize this as a deadlock and choose a victim to help free up
the resources?
Thanks.Hi,
From your descriptions, I understood that you would like to know how much
memory will be allocated to locks and what happened in the scenario you
described. Have I understood you? If there is anything I misunderstood,
please feel free to let me know
For the first question, based on my knowledge, there are no standard for
allocating memory pool for locks, so I cannot tell how much it will be
For the second question, could you reporduce ti? It is appreciated if you
could provide me some sample scenario, which, I believe, will make us
closer to the resolution.
Thank you for your patience and cooperation. If you have any questions or
concerns, don't hesitate to let me know.
Sincerely yours,
Michael Cheng
Microsoft Online Support
****************************************
*******************
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks.|||Lock Pool:
According to a resource that I have now, the number of slots in the lock has
h table directly relates to physical memory size. Since we have more than 1G
B of physical memory, the number of slots in the hash table is 2 to the 19th
, or 512K. If this has
h table gets fulls because of the number of locks in the system does it enga
ge the escalation process and start upgrading locks to table locks?
Block Scenario:
Yes, we can reproduce this problem very easily. The best way to do it is to
setup one query to read a set of rows (< 10) from table "A." This should be
the first query executed. Then while that query is running, start another qu
ery that insert at leas
t 200 rows into table "A" within a transaction. What we are seeing here is t
hat both resources get blocked, and never return.
Let me know if you need further details. Thanks.
Ken L|||Hello Ken,
The lock escalation attempts are never blocked in SQL Server. If the lock
threshold is crossed and we decide we want to escalate but someone holds an
incompatible lock on the table, we simply cancel the escalation attempt and
continue acquiring locks at the page, row or key level.
Also, if there was truly a simple lock-based deadlock then the deadlock
monitor should detect it and roll back one of the participants.
As far as the particulars of lock escalation thresholds, they are
undocumented and have changed between 7.0 and SQL 2000, and again with
service packs for SQL 2000.
Investigation of your scenario would need trace, blocker script and
errorlog analysis which would be done quickly and effectively with direct
assistance from a Microsoft Support Professional through Microsoft Product
Support Services. You can contact Microsoft Product Support directly to
discuss additional support options you may have available, by contacting us
at 1-(800)936-5800 or by choosing one of the options listed at
http://support.microsoft.com/defaul...d=sz;en-us;top.
If this is not an urgent issue and your would like us to create an incident
for you and have Microsoft Customer Service Representative contact you
directly, please send email to (remove "online." from this no Spam email
address): mailto:dscommhf@.online.microsoft.com with the following
information,
*Include "Followup: <Tomcat IssueID>" in the email Subject.
*Location of the post
*Subject Line
*First Name, Last Name
*MSDN Subscriber ID
*Company name (if any)
*Phone number
*e-mail address
Thanks for using MSDN Managed Newsgroup.
Vikrant Dalwale
Microsoft SQL Server Support Professional
Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computers security.
This posting is provided "AS IS" with no warranties, and confers no rights.
--
>Thread-Topic: Blocked Resources Never Release
>thread-index: AcQ4/1L2Dymf0MfBRy6pVZIiiOpc7A==
>X-WN-Post: microsoft.public.sqlserver.server
>From: "examnotes" <visDev@.online.nospam>
>References: <AC3EA969-391B-4849-8473-99BBA5EC96B5@.microsoft.com>
<cEHqVuNOEHA.424@.cpmsftngxa10.phx.gbl>
>Subject: RE: Blocked Resources Never Release
>Date: Thu, 13 May 2004 08:31:13 -0700
>Lines: 9
>Message-ID: <24381669-EE80-4206-9EDF-8D36C1C5CA3E@.microsoft.com>
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="Utf-8"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>Content-Class: urn:content-classes:message
>Importance: normal
>Priority: normal
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
>Newsgroups: microsoft.public.sqlserver.server
>Path: cpmsftngxa10.phx.gbl
>Xref: cpmsftngxa10.phx.gbl microsoft.public.sqlserver.server:341150
>NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
>X-Tomcat-NG: microsoft.public.sqlserver.server
>Lock Pool:
According to a resource that I have now, the number of slots in the
lock hash table directly relates to physical memory size. Since we have
more than 1GB of physical memory, the number of slots in the hash table is
2 to the 19th, or 512K. If this hash table gets fulls because of the number
of locks in the system does it engage the escalation process and start
upgrading locks to table locks?
Block Scenario:
Yes, we can reproduce this problem very easily. The best way to do it
is to setup one query to read a set of rows (< 10) from table "A." This
should be the first query executed. Then while that query is running, start
another query that insert at least 200 rows into table "A" within a
transaction. What we are seeing here is that both resources get blocked,
and never return.
Let me know if you need further details. Thanks.
Ken L
>

Blocked Resources Never Release

In what appears to be a deadlock scenario, why doesnâ't the deadlock manager engage and determine a victim?
Here is an example of what I am talking about
Query
Select statement on table "A" with a suitable where clause to define only the records desired
Query
Multiple insert statements within a single transaction to several different tables including table "A.
The resulting scenario is that query 2 has crossed the magic threshold of 1250 locks and therefore escalates its lock to a table lock. Query 1, which is now blocked, also escalates to a table lock. The two queries then sit around waiting for each other to finish, but they never do
Here are my questions
The lock manager will begin escalation if a single resource is using more than 1250 locks on table resources, or 765 locks on index resources. If the machine in question has 2GB of physical memory, how big is the memory pool for locks
Even though this isn't the classic deadlock scenario, why doesn't the deadlock manager recognize this as a deadlock and choose a victim to help free up the resources
ThanksHi,
From your descriptions, I understood that you would like to know how much
memory will be allocated to locks and what happened in the scenario you
described. Have I understood you? If there is anything I misunderstood,
please feel free to let me know :)
For the first question, based on my knowledge, there are no standard for
allocating memory pool for locks, so I cannot tell how much it will be
For the second question, could you reporduce ti? It is appreciated if you
could provide me some sample scenario, which, I believe, will make us
closer to the resolution.
Thank you for your patience and cooperation. If you have any questions or
concerns, don't hesitate to let me know.
Sincerely yours,
Michael Cheng
Microsoft Online Support
***********************************************************
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
Please reply to newsgroups only, many thanks.|||Hello Ken,
The lock escalation attempts are never blocked in SQL Server. If the lock
threshold is crossed and we decide we want to escalate but someone holds an
incompatible lock on the table, we simply cancel the escalation attempt and
continue acquiring locks at the page, row or key level.
Also, if there was truly a simple lock-based deadlock then the deadlock
monitor should detect it and roll back one of the participants.
As far as the particulars of lock escalation thresholds, they are
undocumented and have changed between 7.0 and SQL 2000, and again with
service packs for SQL 2000.
Investigation of your scenario would need trace, blocker script and
errorlog analysis which would be done quickly and effectively with direct
assistance from a Microsoft Support Professional through Microsoft Product
Support Services. You can contact Microsoft Product Support directly to
discuss additional support options you may have available, by contacting us
at 1-(800)936-5800 or by choosing one of the options listed at
http://support.microsoft.com/default.aspx?scid=sz;en-us;top.
If this is not an urgent issue and your would like us to create an incident
for you and have Microsoft Customer Service Representative contact you
directly, please send email to (remove "online." from this no Spam email
address): mailto:dscommhf@.online.microsoft.com with the following
information,
*Include "Followup: <Tomcat IssueID>" in the email Subject.
*Location of the post
*Subject Line
*First Name, Last Name
*MSDN Subscriber ID
*Company name (if any)
*Phone number
*e-mail address
Thanks for using MSDN Managed Newsgroup.
Vikrant Dalwale
Microsoft SQL Server Support Professional
Microsoft highly recommends to all of our customers that they visit the
http://www.microsoft.com/protect site and perform the three straightforward
steps listed to improve your computer?s security.
This posting is provided "AS IS" with no warranties, and confers no rights.
>Thread-Topic: Blocked Resources Never Release
>thread-index: AcQ4/1L2Dymf0MfBRy6pVZIiiOpc7A==>X-WN-Post: microsoft.public.sqlserver.server
>From: "=?Utf-8?B?S2VuIEw=?=" <visDev@.online.nospam>
>References: <AC3EA969-391B-4849-8473-99BBA5EC96B5@.microsoft.com>
<cEHqVuNOEHA.424@.cpmsftngxa10.phx.gbl>
>Subject: RE: Blocked Resources Never Release
>Date: Thu, 13 May 2004 08:31:13 -0700
>Lines: 9
>Message-ID: <24381669-EE80-4206-9EDF-8D36C1C5CA3E@.microsoft.com>
>MIME-Version: 1.0
>Content-Type: text/plain;
> charset="Utf-8"
>Content-Transfer-Encoding: 7bit
>X-Newsreader: Microsoft CDO for Windows 2000
>Content-Class: urn:content-classes:message
>Importance: normal
>Priority: normal
>X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
>Newsgroups: microsoft.public.sqlserver.server
>Path: cpmsftngxa10.phx.gbl
>Xref: cpmsftngxa10.phx.gbl microsoft.public.sqlserver.server:341150
>NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
>X-Tomcat-NG: microsoft.public.sqlserver.server
>Lock Pool:
According to a resource that I have now, the number of slots in the
lock hash table directly relates to physical memory size. Since we have
more than 1GB of physical memory, the number of slots in the hash table is
2 to the 19th, or 512K. If this hash table gets fulls because of the number
of locks in the system does it engage the escalation process and start
upgrading locks to table locks?
Block Scenario:
Yes, we can reproduce this problem very easily. The best way to do it
is to setup one query to read a set of rows (< 10) from table "A." This
should be the first query executed. Then while that query is running, start
another query that insert at least 200 rows into table "A" within a
transaction. What we are seeing here is that both resources get blocked,
and never return.
Let me know if you need further details. Thanks.
Ken L
>

Friday, February 24, 2012

Blank window Problem

Hi everyone...
I ve a problem that is-
Scenario:
I open report using url access from html page. Parameters are passed in from
html page as hidden fields. Url of report is in Action attribute of form in
the page. So, when i submit it it opens BLANK WINDOW and the opens prompt
window for saving or opening option.
Problem:
I dont want this blank window.
Please help! I am looking replies from MS guys as i couldnt find it anywhere!
--
Suneet Mohan
Microsoft Certified ProfessionalOn Sat, 2 Apr 2005 10:51:02 -0800, Suneet <suneetmohan@.gmail.com>
wrote:
>Hi everyone...
>I ve a problem that is-
>Scenario:
>I open report using url access from html page. Parameters are passed in from
>html page as hidden fields. Url of report is in Action attribute of form in
>the page. So, when i submit it it opens BLANK WINDOW and the opens prompt
>window for saving or opening option.
>Problem:
>I dont want this blank window.
>Please help! I am looking replies from MS guys as i couldnt find it anywhere!
>--
>Suneet Mohan
>Microsoft Certified Professional
It would be helpful to see the URL that is created and which seems to
fail.
Andrew Watt
MVP - InfoPath