Quantcast
Channel: SQL Service Broker forum
Viewing all 461 articles
Browse latest View live

The query notification subscription message is invalid

$
0
0
Hi!
I have some code that uses System.Web.Caching.Cache object to cache some data and invalidate them automatically using SqlDepenency. The command related with the SqlDependency is a simple select statement from a table. Although the code works smoothly most of the times, every now and then (1 in 5 cases) I get exception 'The query notification subscription message is invalid'. I see that this problem is only mentioned once in these forums without any answer.
Does anybody have any idea?
Dimitris Papadimitriou, Software Development Professional

Could not obtain information about Windows NT group/user .......error code 0x534...

$
0
0

== I asked this question directly to Remus and wanted to share the response to all of those people using this forum ==

We recently moved our database server from SQL Server 2000 to SQL Server 2005. All applications on our intranet development server stay the same [VS.NET 2003], but recently resources in our Dev DB server ran out of space. While doing a thorough investigation, I noticed ERRORLOG file was occupying about 35 Gig of HDD space. I immediately checked SQL Server error log and noticed an entry which says –

===========================================================================================

Date                 7/7/2006 4:45:37 PM

Log                   SQL Server (Current - 7/7/2006 4:45:00 PM)

Source              spid77s

Message

The activated proc [dbo].[SqlQueryNotificationStoredProcedure-5eaf8465-d0cb-4be7-93b6-44bb979dd41c] running on queue BW_Content.dbo.SqlQueryNotificationService-5eaf8465-d0cb-4be7-93b6-44bb979dd41c output the following:  'Could not obtain information about Windows NT group/user 'BWCINC\HoffK', error code 0x534.'

===========================================================================================

What is this SqlQueryNotificationService in my database? Is it a SQL Server 2005 thing? Why the same kind of stored procedure does not exist in other databases, but BW_Content? This error is getting repeated most probably every second and is filling up our server.

 I believe our corporate IT people removed our domain accounts from BWCINC domain to BWCORP domain and probably some application which is using BWCINC\HoffK credential is getting errored out. I tried to locate this application and was not successful.

 Is there anyway that I can stop this ERRORLOG from growing? How can I delete these log entries so that I can make space on our Hard Drive? Is there an easy way in SQL Server 2005 to locate which application is creating this error?

Response from Remus:

The 'SqlQueryNotificationService-...' is the service created by SqlDependency when you call SqlDependency.Start (). The problem you describe appears because the 'dbo' user of the database is mapped to the login that originally created this database. The SqlDependency created queue has an EXECUTE AS OWNER clause, owner is 'dbo' and therefore this is equivalent to an EXECUTE AS USER = 'dbo'. The error you see is reported by the domain controller when asked to give information about the original account 'dbo' mapps to (that is, BWCINC\HoffK'): Error code: (Win32) 0x534 (1332) - No mapping between account names and security IDs was done.
 
To solve the issue, change 'dbo' to match a correct login, using either sp_changedbowneror ALTER AUTHORIZATION ON DATABASE::[dbname] TO [somavalidlogin]
To find the databases that have this problem, run this query:

select

name,suser_sname(owner_sid)fromsys.databases
The databses that have the problem will show NULL on the second column.
 
To remove the entries, use sp_cycle_errorlog to force a new errorlog file, then delete the huge log file.
---------------------------------------
 
I executed ALTER AUTHORIZATION ON DATABASE::[BW_Content] TO [sa];
 
I got this error in SQL Error Log once and the growth of ERRORLOG was stopped.
===============================================================
Date                         7/10/2006 1:16:55 PM
Log                          SQL Server (Current - 7/10/2006 1:17:00 PM)
Source                    spid20s
 
Message

The query notification dialog on conversation handle '{6BDE95F7-0EFB-DA11-9064-000C2921B41B}.' closed due to the following error: '<?xml version="1.0"?><Error xmlns="http://schemas.microsoft.com/SQL/ServiceBroker/Error"><Code>-8490</Code><Description>Cannot find the remote service &apos;SqlQueryNotificationService-c15bb868-ed56-47d2-bf91-ce18b320989a&apos; because it does not exist.</Description></Error>'.
===============================================================
 
Should I be concerned about this error?
 
Thanks
-Binoy

SqlDependency for lookup caches, mirroring, and performing an online rebuild of an index

$
0
0
We use SqlDependency to cache some lookup tables to our IIS servers, and have database mirroring configured as well. Just recently when I went to do an online rebuild of a few indexes to change the fillfactor (as there was wasted space in these particular ones) I found that the service broker queries monitoring the lookup tables all started failing - not for the duration of the index rebuild, but for the duration of the mirror catching up with all of the transactions. Is this expected behavior for SqlDependency and database mirroring?

Service broker stopped working

$
0
0

Hi,

I'm new to Service Broker. Our existing Service Broker suddenly stops working and I can't figure out why.

When I try to enable Service Broker (which is already enabled) I get this in SQL error log:

An error occurred in the service broker manager 
Error: 3602, State: 25.

Also tried creating new message queues. I am able to see the created queues undersys.service_queues and sys.objects but not in sys.dm_broker_queue_monitors.

Disabling Service Broker.

$
0
0
I have two service broker applications on one instance of database.
One sends/recieve messages locally and other one sends/recieve messages to remote server.

I wanted to disable the Remote service broker so that sender can no longer send messages to the remote queue
I disabled the Queueue but I still see the Reciever is still getting messages and tables getting updated as a result.

I want to stop the Remote Sender queue and I dont want transmission_queue to pile up.

How to restart Service Broker without recreating the objects

$
0
0
I have a system I created on 2008 R2 which is using Service Broker to execute a specific procedure unsynchronously: 
1. The user executes Procedure A with a parameter, 
2. Procedure A begins a Dialog and sends a message with the parameter to a Queue which uses the PROCEDURE_NAME option to initiate the execution of Procedure B. 
3. Procedure B runs and does several tasks. The user can trace its execution through a log table which is updated by the procedure. 

Some time ago I was informed that the execution of Procedure A doesn't initiate the execution of Procedure B. 
I didn't find any reason for the problem: the definitions of the database as Is_broker_enabled was OK, and sys.transmission_queue was empty. 
I tried to Drop & Create all the objects (except the log table), and fortunately that fixed the problem. 

Today I had a similar problem and I fixed it in the same way. 

So far everything is fine and I have a solution, but I wonder: 
1. What can be the reason for the problem? 
2. Maybe I don't have to drop & create *all* the objects in such case?

El castellano no es mi lengua materna. Discúlpenme por los errores gramaticales, y, si pueden, corríjanme en los comentarios, o por correo electrónico. ¡Muchas gracias! Blog: http://about.me/GeriReshef

SB floods with query notifications

$
0
0

I'm working on a super simple C# SQLDependency app which seems to work fine on a test DB I created with a very simple implementation. I enable Service Broker on the DB, and register a few queries with the C# SQLDependency class.. here's some pseudo-code:

void Start(){
    SqlDependency.Start(connectionString);
}

void SetupDependency(){
    SqlCommand currentCommand = new SqlCommand("SELECT AccountId FROM dbo.Accounts WHERE AccountId=123", this.CurrentConnection);
    SqlDependency dependency = new SqlDependency(currentCommand);
    dependency.OnChange += this.dependency_OnChange;
    currentCommand.ExecuteNonQuery();
}


void dependency_OnChange(object sender, SqlNotificationEventArgs e)
{
    SqlDependency dependency = sender as SqlDependency;

    dependency.OnChange -= new OnChangeEventHandler(dependency_OnChange);
    // do some things with the event, re-register the dependency again etc.
}


In my test DB this all works fine. When I update the record, I get the notification.

However, in my production DEV database as soon as I connect and register dependencies I receive back a constant stream (thousands) of Query notifications on that single record. The SqlNotificationEventArgs reveal:

SqlNotification.Info = Query
SqlNotification.Source = Statement
SqlNotification.Type = Subscribe

I don't seem to receive any other types of notifications, such as when updating the data (SqlNotification:: Info.Update Source.Data Type.Change type events), I only get these Query events. I've checked the SB Queue that gets automatically created when I do a SqlDependency.Start(), and it's filling up with thousands of these notifications. The message body is:

<qn:QueryNotification xmlns:qn="http://schemas.microsoft.com/SQL/Notifications/QueryNotification" id="0" type="subscribe" source="statement" info="query" database_id="0" sid="0xFA3808D148F75649A905EB8EE9C02842"><qn:Message>84208d96-67fc-4847-b80c-18afa2bd0c81;683d992f-45ad-4701-9032-6316ecb8716b</qn:Message></qn:QueryNotification>

Does anybody have any idea where these could be coming from? And why I don't see them on my test database? There may be a small amount of read activity on my DEV database, but I confirmed there were no updates running and certainly not thousands of reads on a single record. I'm stumped!

Thanks!


Michael Brown, 360 Replays Ltd. (don't forget that 'Mark As Answer' button!)

Service broker intermitent problems with remote db

$
0
0
I am having an intermitent problem with service broker where the intiator's sys.transmission queue will fill up with outbound messages. I've looked at the transmission queue message status and it is blank on the sender's db. I've profiled the target db and i'm getting a duplicate message error.

When i run select get_transmission_status('93C9FBF6-F951-DE11-9F2F-0022198CADC8') with the conversation handle i get the following message back,
A previously existing connection with the same peer was found after DNS lookup. This connection will be closed. All traffic will be redirected to the previously existing connection. This is an informational message only. No user action is required. State 116.
Now i would assume that it should be restarting the tcp connection between the 2 servers and then sending the ack messages back to the sender without problem but it never does. The only way i've found to fix the problem is to restart the sql server service on the sender's machine which closes and reopens the tcp connection and the messages will continue to process. Does anyone have any suggestions on what I should try to do to prevent this in the future?
http://www.nootz.net

SQLDependency (C#) w/custom queue name isn't working

$
0
0

Hello all,

I've written an application that uses the .Net SQLDependency class as directed in the docs. It works fine when I let the default behavior create the SB service/queue automatically as follows:

SqlDependency.Start(connectionString);

However when I give it a queue name in the constructor it doesn't receive any events:

SqlDependency.Start(connectionString, "SBQueueService");

I don't want SqlDependency to create the queue for me each time, as during development I end up with dozens of services/queues registered all with a default max queue readers of 1. My service broker SQL is:

ALTER PROCEDURE [dbo].[SBQueryProc] AS 
BEGIN 
	BEGIN TRANSACTION; 
	RECEIVE TOP(0) conversation_handle FROM [SBQueueService]; 
	COMMIT TRANSACTION; 
END;

CREATE QUEUE [dbo].[SBQueueService] WITH STATUS = ON , RETENTION = ON , ACTIVATION (  
STATUS = ON , PROCEDURE_NAME = [dbo].[SBQueryProc] , MAX_QUEUE_READERS = 16 , EXECUTE AS OWNER  ) ON [PRIMARY] 

CREATE SERVICE [SBQueueService] AUTHORIZATION sb ON QUEUE [dbo].[SBQueueService] ([http://schemas.microsoft.com/SQL/Notifications/PostQueryNotification]);
IF (SELECT COUNT(*) FROM sys.database_principals WHERE name='sql_dependency_subscriber' AND type='R') <> 0 
BEGIN 
	GRANT SEND ON SERVICE::[SBQueueService] TO sql_dependency_subscriber; 
END;  

Does anyone see any issue with how it's being setup? I've captured the SQL that the SqlDependency class sends and I seem to be doing the same thing, but I don't receive notification events.


Michael Brown, 360 Replays Ltd. (don't forget that 'Mark As Answer' button!)


transmission_status contains weird characters, Broker is frozen

$
0
0

Hi,

We recently faced the following problematic situation since we switched on brand new 64 cores / 500GB servers:

- Service broker frozen for all local activites
- Service broker for external servers were still functionnal
- One queue monitor in state "DROPPED" (sys.dm_broker_queue_monitors)
- Thousand lines with weird characters (unreadable ASCII chars)
- every incoming messages were stacked into sys.transmission_queues
- queues where empty
- Active tasks looking frozng were not receptive to KILL actions (sys.dm_broker_activated_tasks)
- Same load, same code on 16 cores servers did never encounter this problem

This was looking like corrupted memory situation and the only solution was to FAILOVER our servers.

Is one of you aware of such a behavior or efficient ways to troubleshoot ? I see no explanation of those weird chars into transmission_status column...

Thanks for your feedback.

Queue is empty

$
0
0

I have created queue and service, but when i start timet to send message in queue, it is empty.
Why? What could be wrong?

CREATE PROCEDURE dbo.myProcedure
AS
RETURN 'test'

CREATE QUEUE [dbo].[myQueue] WITH STATUS = ON , RETENTION = OFF ,
ACTIVATION (  STATUS = ON , PROCEDURE_NAME = [dbo].[myProcedure], MAX_QUEUE_READERS = 1 , EXECUTE AS N'dbo'  ),
POISON_MESSAGE_HANDLING (STATUS = OFF)  ON [PRIMARY] 

CREATE SERVICE [myService]  AUTHORIZATION [dbo] 
ON QUEUE [dbo].[myQueue]([DEFAULT])


DECLARE @DialogHandle UNIQUEIDENTIFIER; BEGIN dialog CONVERSATION @DialogHandle FROM SERVICE myService TO SERVICE 'myService' ON CONTRACT [DEFAULT] WITH ENCRYPTION = OFF; BEGIN CONVERSATION TIMER (@DialogHandle) TIMEOUT = 1;

SELECT * from myQueue --is empty

--I can see the result in conversation endPoints:

SELECT * FROM sys.conversation_endpoints WHERE far_service='myService'

--what else should I check?

Thanks

SqlDependency class throws "The given key was not present in the dictionary." during SqlDependency.Start()

$
0
0

Today I ran into an issue when using the .Net SqlDependency class when calling SqlDependency.Start(connectionName, queueName). The class would throw the exception "KeyNotFound" - "The given key was not present in the dictionary.". After scratching my head for a few moments I found that in the queue there were a number of messages stuck in the queue that did not have conversation handles that did not exist.

It is possible that somewhere in my code it did not call SqlDependency.Stop() when the webserver was recycled or due to an unhandled exception - but could easily have been Service Broker itself.

I found the solution was to clear the queue of any items that had invalid conversation handles (or completely clear the queue).

DECLARE item_cursor CURSOR LOCAL FAST_FORWARD FOR
    SELECT s.conversation_handle FROM clients.dbo.MySBQueueName s LEFT JOIN sys.conversation_endpoints e ON e.conversation_handle=s.conversation_handle WHERE e.conversation_handle IS NULL;
	-- or completely clear it below
	--SELECT s.conversation_handle FROM clients.dbo.MySBQueueName s;
OPEN item_cursor
DECLARE @conversation UNIQUEIDENTIFIER
FETCH NEXT FROM item_cursor INTO @conversation
WHILE @@FETCH_STATUS = 0 
BEGIN
    END CONVERSATION @conversation WITH CLEANUP
    FETCH NEXT FROM item_cursor INTO @conversation
END

There wasn't much on Google about this error (though people are reporting it), I hope this helps someone.


Michael Brown, 360 Replays Ltd. (don't forget that 'Mark As Answer' button!)


An error occurred in Service Broker internal activation while trying to scan the user queue

$
0
0

After Migrating our Production database from sql 2008 to Sql 2012 SPI, our service broker queues are showing errors in the event logs. Prior to the upgrade we were not seeing any errors. We can determine that the queues are working, but are wondering why we are seeing these errors all of a sudden? I have found other postings where people have seen the same problem after the upgrade.

Here is an example of the errors we are seeing.

 

An error occurred in Service Broker internal activation while trying to scan the user queue 'XX' for its status. Error: 1222, State: 51. Lock request time out period exceeded. This is an informational message only. No user action is required.

SQL Service Broker activated proc writes all print messages into SQL Error Log...

$
0
0

If any print message exists in a Service Broker activated proc, it generates a message (9724) : like  

The activated proc '[dbo].[reply_proc]' running on queue 'test.dbo.InitiatorQueue1DB' output the following: '789'

 the message itself has the severity level of 10 and flag not write to log... This gets me to a serious implications like overpouring ErrorLog with insufficient disk space problem, when running a proc likesp_updatestats on a large database... such a proc generates thousands of singe rows and if it runs on a quite regular basis (several times in hour) that problem becomes an a headache... I can wrap it up to CLR proc and suppress those info messages... but , I'm just wondering if it could be done in a simplier way like change a setting in somewhere I'm not aware of place...

Thanks to everybody's attention...

Denis.

SQLQueryNotificationStoredProcedure exception filling up the log

$
0
0

I'm seeing this exception over and over again for different users (exceptions seen via SQL Profiler).  Any idea/clues as to where these are coming from and why?

ExceptionThere is already an object named 'SqlQueryNotificationStoredProcedure-6b3cfc31-1210-44d0-9e9b-b049ec8d54f9' in the database.SqlQueryNotificationService-6b3cfc31-1210-44d0-9e9b-b049ec8d54f9


An error occurred in Service Broker internal activation while trying to scan the user queue 'msdb.dbo.InternalMailQueue' for its status. Error: 1222, State: 51. Lock request time out period exceeded. This is an informational message only. No user action i

$
0
0

Hello!

We recently upgraded some of our servers from SQL Server 2008 R2 to SQL Server 2012.  Since that point, I have noticed the following error repeatedly in the error logs:

Date  6/7/2013 10:22:09 AM
Log  SQL Server (Current - 6/7/2013 5:46:00 AM)

Source  spid44s

Message
An error occurred in Service Broker internal activation while trying to scan the user queue 'msdb.dbo.InternalMailQueue' for its status. Error: 1222, State: 51. Lock request time out period exceeded. This is an informational message only. No user action is required.

I found the following article in the forums:

http://social.msdn.microsoft.com/Forums/en-US/sqlservicebroker/thread/00e70f1e-eede-40f2-9e76-3ac7a9b567b2

but this does not explain the actual course of action.  Should I be setting HONOR_BROKER_PRIORITY to ON to eliminate these error messages? I would love to test this, but it only shows up in our production environment.

Any help would be greatly appreciated!

Thanks!

SQLQueryNotificationService-GUID running on queue databasename.dbo.sqlqueryNotificationService-GUID output the followoing, 'Can not execute as teh database principal because "dbo" does not exits, This type of Principal cannot be impersonated, or you do

$
0
0

I have gone through many threads which advocate the above problem is may be due to insufficient privliges OR a falsy setup of broker service.

I have checked the articles which present solution i.e
http://rusanu.com/2006/06/17/the-mysterious-notification/

AND

http://rusanu.com/2007/11/10/when-it-rains-it-pours/

these are nice article to find the solution but in my case these are not helpfull as i have done what is listed in these articles but the problem remains the same:)

i am frequently observing the following error in my windows Application log

The activated proc [dbo].[SqlQueryNotificationStoredProcedure-f27ecb39-bbaf-4ef7-b9bf-5aa301511d64] running on queue Database.dbo.SqlQueryNotificationService-f27ecb39-bbaf-4ef7-b9bf-5aa301511d64 output the following:  'Cannot execute as the database principal because the principal "dbo" does not exist, this type of principal cannot be impersonated, or you do not have permission.'

i have checked the queues and service and none is available with the name [dbo].[SqlQueryNotificationStoredProcedure-f27ecb39-bbaf-4ef7-b9bf-5aa301511d64], Also no stored procedure is available with this name in the convern database!

Can someone please explain!

1:  How to stop these errors as these are bloating the applicaiton log with event iID 9724
2:  How to reslove the problem :)
3:  Does SQLQueryNotification create problem for IIS as a whole?

4: It Seems the notification brings the website to its knees why ?

I realy appritiate if someone has any clue?

Talib


Talib Butt

Message in transmission_queue with error although security context is right

$
0
0

Hi,

I'm testing the dialog sample from "TSQL Programming" book, sending a message from one db to a target that is on a different db in the same instance. As expected, the transmission_queue shows the error about the security context, so I follow the next steps (users with certificates, grants and remote service binding) to configure the security. When I send another message, everything is fine and the dialog ends successfully. But the initial message is still in the transmission_queue with the same error.

The only way to resolve this situation is setting the TRUSTWORTHY option in the initiator database to ON. Why? It seems that the security dialog that I configure AFTER I sent the initial message don't affect to the retries of this first message, buth the TRUSTWORTHY option yes... Don't understand it.

Thanks in advance.


External Activator not launching Application

$
0
0

Hello

I am setup an External Activator solution . I think I got everything as it should be, but the application is just not launching on the QUEUE_ACTIVATION event

External Activator service start successfully and its shows a RECEIVES_OCCURRING status in sys.dm_broker_queue_monitors.

The sys.transmission_queue is empty and I can see the messages appearing in sys.conversation_endpoints with a state of CONVERSING

If I run my Application manually it completes the “Receive” command and reply a message without error.

Any ideas?

Regards, WDV

Error using RECEIVE with xml

$
0
0

I have a Stored procedure that acts upon a queue with the following code:

DECLARE @message_body as XML, @MessageTypeName as varchar(256), @ConversationHandle as UniqueIdentifier

WAITFOR (RECEIVE TOP (1)  @MessageTypeName = message_type_name

,@message_body = message_body

,@ConversationHandle = Conversation_Handle

FROM MyQueue

), TIMEOUT 5000;

This works well for 90% of the messages in the queue, but bugs out the other 10% of the time. The SQL Log error message being:

The activated proc '[dbo].[usp_ReadMyQueue]' running on queue 'DBName.dbo.MyQueue' output the following:  'XML parsing: line 1, character 519, illegal xml character'

When I checked the message_body for the message causing the error, I found that the character position was represented by a character: ã

I therefore changed the code by adding a new variable @message_body2 as varchar(max), and placing that inside the RECEIVE statement, thus:

.....

,@message_body2 = message_body

......

and following this I added the next line after the TIMEOUT being:

SET @message_body = CAST(@message_body2 as XML)

It all works perfectly well.

My question is why would an xml error be raised in the RECEIVE statement when it is not outside of that statement?

I did try using ,@message_body = CAST(message_body as xml) but that also errored out the same as before.

Just being curious as to whether this should be expected behaviour, or a little-known bug.

Thanks, 

Viewing all 461 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>