Snapshot isolation in combination with service broker

Hi all,
I'm currently using the service broker in combination with snapshot isolation on the database.
The notification request is executed under read commited isolation. The code looks like this:
SqlDependency dependency = new SqlDependency(command, null, 0);
dependency.OnChange += eventHandler;
using (SqlConnection conn = new SqlConnection(connectionString))
using (SqlTransaction tran = conn.BeginTransaction(IsolationLevel.ReadCommitted))
command.Transaction = tran;
command.ExecuteNonQuery();
tran.Commit();
The request is successfully created and works fine at the first glance.
Now here is my problem:
I created a notification request that should monitor two objects. The query (executed under read committed) looks something like this:
SELECT Id, DataVersion FROM dbo.MyObjects WHERE Id = 1 OR Id = 2
Afterwards I delete both objects in separate nested transactions. Both of them are running under snapshot isolation. It looks something like this:
using (SqlConnection conn1 = new SqlConnection(connectionString))
conn1.Open();
using (SqlTransaction tran1 = connection1.BeginTransaction(IsolationLevel.Snapshot))
using (SqlConnection conn2 = new SqlConnection(connectionString))
conn2.Open();
using (SqlTransaction tran2 = conn2.BeginTransaction(IsolationLevel.Snapshot))
SqlCommand command2 = conn2.CreateCommand();
command2.Transaction = tran2;
command2.CommandText = "DELETE FROM MyObjects WHERE Id = 2";
command2.ExecuteNonQuery();
tran2.Commit();
SqlCommand command1 = conn1.CreateCommand();
command1.CommandText = "DELETE FROM MyObjects WHERE Id = 1";
command1.Transaction = tran1;
command1.ExecuteNonQuery();
tran1.Commit(); //-> Conflict exception
A conflict exception is raised during the commit of last transaction. The conflict seems to occur in the table "sys.query_notifcations_xxxxxxxxx". This is the exact message:
An unhandled exception of type 'System.Data.SqlClient.SqlException' occurred in System.Data.dll
Additional information: Snapshot isolation transaction aborted due to update conflict. You cannot use snapshot isolation to access table 'sys.query_notification_45295271' directly or indirectly in database 'MyDatabase' to update, delete,
or insert the row that has been modified or deleted by another transaction. Retry the transaction or change the isolation level for the update/delete statement.
Is there any restriction for the service broker that prohibits the usage of snapshot isolation.
Thanks in advance.

No, the error has nothing to do with Service Broker. Or for that matter, query notifications, which is the feature you are actually using. (Query notifications uses Service Broker, but Service Broker != Query notification.)
You would get the same error if you had a trigger in MyObjects that tried to update the same row for both deletions. A snapshot transaction gives you a consistent view of the database in a certain point in time. Consider this situation:
Snapshot transaction A that started at time T update a row R at time T2. Snapshot transaction B starts at time T1 updates the same row at time T3. Had they been regular non-snapshot transaction, transaction B would have been blocked already when it tried
to read R, but snapshot transactions do not get blocked. But if B would be permitted to update R, the update from transaction A would be lost. Assume that the update is an incremental one, for instance updating cash balance for an account. You can see that
this is not permittable.
In your case, the row R happens to be a row in an internal table for query notifications, but it is the application design which is the problem. There is no obvious reason to use snapshot isolation in your example since you are only deleting. And there is
even less reason to have two transactions and connections for the task.
Erland Sommarskog, SQL Server MVP, [email protected]

Similar Messages

  • SQL server service broker

    Hi All,
    I have requirement to implement SQL server service broker in SQL server 2008, please guide me for that, how and why we use for that, then have any other option to achieve. 
    Please give any good stuff to learn service broker.
    Thanks,
    Jai.

    This is a very good book to learn about Service Broker:
    http://www.amazon.com/Rational-Server-Service-Broker-Guides/dp/1932577270/ref=sr_1_1?ie=UTF8&qid=1418942042&sr=8-1&keywords=%22roger+wolter%22+%22service+broker%22&pebp=1418942044114
    In difference from many other computer books, this is not a brick, but only 220 pages.
    Also, Remus Rusanu's blog covers many important concepts with Service Broker:
    http://rusanu.com/?s=service+broker
    Erland Sommarskog, SQL Server MVP, [email protected]

  • How to use Service Broker, where and when we gonna use it.

    Hi all,
    I have task to implement SQL service broker for some insert statement, am bit confused where i start and how to implement like it may in Database or Server side(ASP.Net- c#), some where.
    What the main advantage of using SQL Service broker?
    Thanks,
    Jai.

    There is more than one place where Service Broker fits in. Generally, one can say that Service Broker permits you to implement things asynchronously. For instance, when a row is updated in a table a mail should be sent to someone. Rather than having a trigger
    that sends the mail on the spot, the trigger could post a message on a Service Broker queue. Then there could be an activation procedure which reacts to this message and composes and sends the mail. This activation can be in the same database - but it can
    also be on a completely different server which does not even have a direct connection to the actual server.
    Activation can also be external. That is, there is an application that polls the queue, and again this could be on an other server, and when there is a message in the queue the application processes it.
    Roger Wolter's book is an excellent introduction to Service Broker:
    http://www.amazon.com/Rational-Server-Service-Broker-Guides/dp/1932577270/ref=sr_1_1?ie=UTF8&qid=1420025225&sr=8-1&keywords=Roger+Wolter+service+broker
    Also, don't overlook Remus Rusanu's blog, which is an excellent resource for development patterns with Service Broker:
    http://rusanu.com/?s=service+broker
    Both Roger and Remus worked on the development of Service Broker, so they know what they are talking about.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Segmentation fault when using snapshot isolation with Berkeley DB 6.1.19 and 5.1.29

    Hello,
    I have been experimenting with snapshot isolation with Berkeley DB, but I find that it frequently triggers a segmentation fault when write transactions are in progress.  The following test program reliably demonstrates the problem in Linux using either 5.1.29 or 6.1.19. 
    https://anl.app.box.com/s/3qq2yiij2676cg3vkgik
    Compilation instructions are at the top of the file.  The test program creates a temporary directory in /tmp, opens a new environment with the DB_MULTIVERSION flag, and spawns 8 threads.  Each thread performs 100 transactional put operations using DB_TXN_SNAPSHOT.  The stack trace when the program crashes generally looks like this:
    Program received signal SIGSEGV, Segmentation fault.
    [Switching to Thread 0x7ffff7483700 (LWP 11871)]
    0x00007ffff795e190 in __memp_fput ()
       from /usr/lib/x86_64-linux-gnu/libdb-5.1.so
    (gdb) where
    #0  0x00007ffff795e190 in __memp_fput ()
       from /usr/lib/x86_64-linux-gnu/libdb-5.1.so
    #1  0x00007ffff7883c30 in __bam_get_root ()
       from /usr/lib/x86_64-linux-gnu/libdb-5.1.so
    #2  0x00007ffff7883dca in __bam_search ()
       from /usr/lib/x86_64-linux-gnu/libdb-5.1.so
    #3  0x00007ffff7870246 in ?? () from /usr/lib/x86_64-linux-gnu/libdb-5.1.so
    #4  0x00007ffff787468f in ?? () from /usr/lib/x86_64-linux-gnu/libdb-5.1.so
    #5  0x00007ffff79099f4 in __dbc_iput ()
       from /usr/lib/x86_64-linux-gnu/libdb-5.1.so
    #6  0x00007ffff7906c10 in __db_put ()
       from /usr/lib/x86_64-linux-gnu/libdb-5.1.so
    #7  0x00007ffff79191eb in __db_put_pp ()
       from /usr/lib/x86_64-linux-gnu/libdb-5.1.so
    #8  0x0000000000400f14 in thread_fn (foo=0x0)
        at ../tests/transactional-osd/bdb-snapshot-write.c:154
    #9  0x00007ffff7bc4182 in start_thread (arg=0x7ffff7483700)
        at pthread_create.c:312
    #10 0x00007ffff757f38d in clone ()
        at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
    I understand that this test program, with 8 concurrent (and deliberately conflicting) writers, is not an ideal use case for snapshot isolation, but this can be triggered in other scenarios as well.
    You can disable snapshot isolation by toggling the value of the USE_SNAP #define near the top of the source, and the test program then runs fine without it.
    Can someone help me to identify the problem?
    many thanks,
    -Phil

    Hi Phil,
       We have taken a look at this in more detail and there was a bug in the code.   We have fixed the bug.     We will roll it into our next 6.1 release that we do.   If you would like an early patch that will go on top of 6.1.19, please email me at [email protected], reference this forum post and I can get a patch sent out to you.   It will be a .diff file that apply on the source code and then rebuild the library.  Once again thanks for finding the issue, and providing a great test program which tremendously helped in getting this resolved.
    thanks
    mike

  • Best Possible Approach : Service Broker or replication?

    I have a business scenario. I have an application whose DB resides on SQL Server A. My application resides on SQL server B. Both SQL servers are on the same network. Server A has a table that is being constantly updated via a web application. We want that
    table to be on Server B. At present it is updated nightly from Server A to Server B.
    We want the changes to be replicated to server B in almost real time. 30 minutes delay could work.
    Now considering this business case what would eb my best options:
    1. Implement CDC on server A for the interested table ( Please note that CDC is only for 1 table, I'm not sure if this is possible) . Bring the table from Server A once to Server B using a Linked Server. Then use the CDC from server A to Merge and Update
    on table on Server b using a SP and Schedule this SP after 30 minutes.
    OR
    2. Use CDC and Service combination.
    OR
    3. use Replication.
    OR  ...???
    Any help will greatly be appreciated.

    Snapshot Replication is OK solution here.  You would need to set the snapshot period to 30 min or less. If you want changes to get populated immediately use transactional replication. Service Broker is the best approach since you wouldn't
    have to maintain infrastructures associated with establishing replication facility. But use of Service Broker will require some expertise. Also take a look at this product called SnipeDB framework SnipeDB.com SnipeDB framework would not replicate the
    table, but would allow any subscriber application to get an update on any change in your data.

  • Turning On Snapshot Isolation Gotchas

    Hello Experts,
    We have been experiencing high number of Deadlocks while using MERGE statement and turning on Snapshot Isolation perfectly solves our problem and our throughput and concurrency didn't get affected at all.
    We did load testing and monitored TempDB VersionStore size and it was nothing significant and we have 64 Gig Memory allocated in Prod Server. Our team did the reading and research primarily from these online sources.
    My Question is "Is there any gotchas in turing on SnapShot Isolation you won't see right away?". I want learn from experiences before we venture into turning it on in our production Environment?. I saw some folks experienced 60 Gig Version Store
    because there was 3 month old active transaction. 
    What kind of preventive and maintenance scripts would be useful to monitor the system and take corrective action?.
    I have few scripts to monitor tempdb version store size, and peformon Transaction Counters. Is there any other better scripts/tools available?.
    Kimberly Tripp Video on Isolation Levels :
    http://download.microsoft.com/download/6/7/9/679B8E59-A014-4D88-9449-701493F2F9FD/HDI-ITPro-TechNet-mp4video-MCM_11_SnapshotIsolationLecture(4).m4v
    Kendra Little on SnapShot Isolatioin :
    http://www.brentozar.com/archive/2013/01/implementing-snapshot-or-read-committed-snapshot-isolation-in-sql-server-a-guide/
    Microsoft Link: https://msdn.microsoft.com/en-us/library/ms188277(v=sql.105).aspx
    https://msdn.microsoft.com/en-us/library/bb522682.aspx
    SQL Team Link : http://www.sqlteam.com/article/transaction-isolation-and-the-new-snapshot-isolation-level
    Idera Short article on TempDB : http://sqlmag.com/site-files/sqlmag.com/files/uploads/2014/01/IderaWP_Demystifyingtempdb.pdf
    Jim Gray Example by Craig Freedman : http://blogs.msdn.com/b/craigfr/archive/2007/05/16/serializable-vs-snapshot-isolation-level.aspx
    Thanks in advance.
    ~I90Runner
    I90Runner

    It is unclear what isolation level have you enabled RCSI or SI?
    Downsides:
    Excessive tempdb usage due to version store activity. Think about session that deletes 1M rows. All those rows must be copied to version store regardless of session transaction isolation level and/or if there are other sessions
    that running in optimistic isolation levels at the moment when deletion started.
    Extra fragmentation – SQL Server adds 14-byte version tag (version store pointer) to the rows in the data files when they are modified. This tag stayed until index is rebuild
    Development challenges – again, error 3960 with snapshot isolation level. Another example in both isolation levels – trigger or code based referential integrity. You can always solve it by adding with (READCOMMITTED) hint
    if needed. 
    While switching to RCSI could be good emergency technique to remove blocking between readers and writers (if you can live with overhead AND readers are using read committed), I would suggest to find root cause of the blocking.
    Confirm that you have locking issues – check if there are shared lock waits in wait stats, that there is no lock escalations that block readers, check that queries are optimized, etc.  
    Best Regards,Uri Dimant SQL Server MVP,
    http://sqlblog.com/blogs/uri_dimant/
    MS SQL optimization: MS SQL Development and Optimization
    MS SQL Consulting:
    Large scale of database and data cleansing
    Remote DBA Services:
    Improves MS SQL Database Performance
    SQL Server Integration Services:
    Business Intelligence

  • SQL Service Broker 2012: the connection was closed by the remote end, or an error occurred while receiving data: '64(The specified network name is no longer available.)'

    Anyone can help with the below issue please? Much appreciated.
    We have about 2k+ messages in sys.transmission_queue
    Telnet to the ports 4022 is working fine.
    Network connectivity has been ruled out.
    The firewalls are OFF.
    We also explicitly provided the permissions to the service account on Server A and Server B to the Service broker end points.
    GRANT
    CONNECT ON
    ENDPOINT <broker> <domain\serviceaccount>
    Currently for troubleshooting purposes, the DR node is also out of the Availability Group, which means that we right now have only one replica the server is now a traditional cluster.
    Important thing to note is when a SQL Server service is restarted, all the messages in the sys.transmission queue is cleared immediately. After about 30-40 minutes, the errors are continued to be seen with the below
    The
    connection was
    closed by the
    remote end,
    or an
    error occurred while
    receiving data:
    '64(The specified network name is no longer available.)'

    We were able to narrow down the issue to an irrelevant IP coming into play during the data transfer. We tried ssbdiagnose runtime and found this error:
    Microsoft Windows [Version 6.1.7601]
    Copyright (c) 2009 Microsoft Corporation.  All rights reserved.
    C:\Windows\system32>SSBDIAGNOSE -E RUNTIME -ID 54F03D35-1A94-48D2-8144-5A9D24B24520 Connect to -S <SourceServer> -d <SourceDB> Connect To -S <DestinationServer> -d <DestinationDB>
    Microsoft SQL Server 11.0.2100.60
    Service Broker Diagnostic Utility
    An internal exception occurred: Timeout expired.  The timeout period elapsed prior to completion of the operation or the server is not responding.
    P  29830                                 Could not find the connection to the SQL Server that
    corresponds to the routing address tcp://XX.XXX.XXX.199:4022. Ensure the tool is connected to this server to allow investigation of runtime events
    The IP that corresponds to routing address is no where configured within the SSB. We are yet unsure why this IP is being referred despite not being configured anywhere. We identified that this IP belongs to one of nodes other SQL Server cluster, which has
    no direct relation to the source server. We failed over that irrelevant SQL Server cluster and made another node active and to our surprise, the data from sys.transmission_queue started flowing. Even today we are able to reproduce the issue, if we bring
    back this node [XX.XXX.XXX.199] as active. Since, its a high business activity period, we are not investigating further until we get an approved downtime to find the root cause of it.
    When we get a approved downtime, we will bring the node [XX.XXX.XXX.199] as active and we will be running Network Monitor, Process Monitor and the SSB Diagnose all in parallel to capture the process/program that is accessing the irrelevant IP.
    Once, we are able to nail down the root cause, I will share more information.

  • Snapshot isolation transaction aborted due to update conflict

    Hi Forum,
    Can anyone help me to give the solution for this below problem.
    We are developing MVC3 application with SQL Server 2008, we are facing as
    Snapshot isolation transaction aborted due to update conflict
    Snapshot isolation transaction aborted due to update conflict. You cannot use snapshot isolation to access table 'dbo.Tb_M_Print' directly or indirectly in database 'DB_Production' to update, delete, or insert the row that has been modified or deleted
    by another transaction. Retry the transaction or change the isolation level for the update/delete statement .
    Please tell me the solution how to proceed for the above problem
    Rama

    change the isolation level for the update/delete statement .
    The error message already mentions the solution.
    See also MSDN
    Lesson 1: Understanding the Available Transaction Isolation Levels => Update Conflicts
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Using own SQLite DB in combination with Data Management

    Hi,
    Currently on a huge project we're we are using LCDS 3.1 in combination with a AIR 2.5 client.
    I've been reading "Using Adobe LiveCycle Data Services ES2 version 3.1" and I have a question. In the chapter "Building an offline-enabled application" it says on the very first line:
    "You can use an offline adapter with an AIR SQLite database to perform offline fills when a desktop client is disconnected from the LiveCycle Data Services server. An offline adapter contains the SQL queries for AIR SQLite for retrieving cached items like an assembler on the server retrieves items from the data source."
    However, in my experience that AIR SQLite database is not just any DB but one that Datamanagment designs and generates itself, based on the Dto the DataManagement destination is managing. The offline adapter doesn't work like an assembler at all, because the documentation says you can only override the methods pertaining to constructing the WHERE, and ORDER BY parts of the queries, not the SELECT, CREATE, FROM,... parts.
    In our case, we have a database on the server, constructed according to a very specific ERD, and we have a SQLite database on the client, also constructed according to a very specific ERD. What we want to do is execute every fill, create, update, delete against the offline cache and only synchronize with the backend when we want it the synchronize (technically possible by playing with the autoMerge, autoSaveCache, autoConnect,... properties). So what part of datamanagement can we customize to use our DB instead of a generated one?
    Thx in advance!

    You are correct in noting that Data Management does not allow you to use your own database to store offline data.  This data is exclusively managed by the LCDS library for the developer.  The intent is that the local cache is a reflection of the server data, not an independent copy.
    If you have an existing database in AIR, then you will have much more direct control over the querying and updating of that data by using the SQLite APIs directly.
    That being said, you can in essence replicate the data stored on the server, managed by Data Management, in the offline cache.  In an upcoming release (winter 2011) we will have a few features ('briefcases' and a 'changes-only' fill) that will make this story even more compelling for your use cases.  But even with the 3.1 functionality, you can do something like the following:
    Perform a fill() to collect the data you want to have available on the client, save this in the offline cache
    Construct an Offline Adapter Actionscript class that implements the fills you want to perform on the local data
    Use the DataService.localFill() API to perform all of the client application fills, turn off autoCommit.
    When the client is online, call commit() to store client changes and call fill() to refresh the cached data.
    This should give you some ideas on how you could go about constructing your app to leverage the offline features of Data Services.
    Tom

  • If an airport Extreme is combined with one or more airport expresses, what is the max number of connections? Is it just 50, or 50 plus 10 for each Express?

    I would like to set up a wireless network with an Airport Extreme, plus one or more Airport Expresses to extend the range. I know an Extreme supports 50 users and an Express 10 users, but when they're combined does the number of users go up according to the number of Expresses combined with the Extreme, or is it limited at 50 no-matter how many Expresses are added?
    Thanks
    Steve

    50 users + 10 users + 10 users + etc. I am assuming that each Express device will be connected using a wired Ethernet connection.
    But, unless you have a truly fantastic Internet connection with your ISP, things are going to be mighty slow on the network since all users split up the available bandwidth.
    So, if you have a 50 Mbps Internet connection, 50 users will have approximately 1 Mbps of bandwidth to work with. Few of us would consider having a 1 Mbps service in our home, even if we only had one computer....way too slow.

  • SSIS Catalog views are not executing from PROC calling from a service broker

    Hi Exprets,
    I have a package deployed on SSISDB (the new concept in MS SQL 2012, SSIS catalogs). I have t-sql code in which i will be able to execute SSIS package in SSISDB with no problems. But if i place the same t-sql code inside of a procedure which will be called
    by a service broker , the code is not executing.
    I am using the following code to execute a package in the SSISDB catalog
    Declare @execution_id bigint
    EXEC [SSISDB].[catalog].[create_execution] @package_name=N'LoadToABC.dtsx',
    @execution_id=@execution_id OUTPUT, @folder_name=N'ABC', @project_name=N'LoadToABC',
    @use32bitruntime=False, @reference_id=Null
    DECLARE @var0 NVARCHAR(200)
    = N'D:\MyData\SampleText20120830100001.txt'
    EXEC [SSISDB].[catalog].[set_execution_parameter_value] @execution_id, @object_type=30,
    @parameter_name=N'strFileName', @parameter_value=@var0
    EXEC [SSISDB].[catalog].[start_execution] @execution_id
    This code executes if run it alone or placed in a regular stored procedure , but not executes if i palce this same code inside of a procedure which is being called/executed by a service broker call like this:
    CREATE QUEUE dbo.SampleQueue
    WITH STATUS=ON, ACTIVATION
    (STATUS = ON, MAX_QUEUE_READERS
    = 1,
    PROCEDURE_NAME = spMessageProcSample,  
    EXECUTE AS OWNER);
    The problem occurs if we call the SSIS catalogs inside a proc which will be calling through a service broker queue.
    I am running all these steps on my local instance of SQL SERVER 2012 in which i am the administrator.
    Please advice where i am doing wrong ?
    Thanks,
    Jyodhu.

    Hi ArthurZ,
    Thanks for reply. What i ment was i tried with all the "EXECUTE AS" options. but no luck.
    Can you please explain step by step if you can ? That would be great help.
    This is the error message from server log.
    Message
    The activated proc '[dbo].[spMessageProcSample]' running on queue 'FileTableDB.dbo.SampleQueue' output the following:  'The server principal "USA\cccsat1nmg" is not able to access the database "SSISDB" under the current security context.'
    I logged in with WIndows authentication (Admin) and i created all the objects including Integration services Catalog.
    Thanks,
    Jyodhu.

  • Combining a service and item invoice in one print out

    Happy New Year everyone!
    Hope you are all well and are fresh for work! I have a dilemma with a client. They want to be able to combine a service invoice with its corresponding item (kept in the item master data) and produce a print out. The service is taxable.
    Can Crystal report or any other engine achieve that?
    Your assistance will be greatly appreciated.
    Patricia

    You could define a non-inventory item for the service and then both can be seen on the same document!

  • Can service broker work between SQL Server 2008 and 2012, ssbdiagnose returned an error !

    Hello, 
    We have a setup of three applications that sends and receive messages using Service Broker.
    One part is on a server, we'll call 'S' have Microsoft SQL Server 2008 (SP3) - 10.0.5512.0 (X64)
    The other part, we'll call 'E' use to have Microsoft SQL Server 2008 (SP3) - 10.0.5512.0 (X64).
    But I am migrating these apps to a new server, we'll call 'C' that has: Microsoft SQL Server 2012 (SP1) - 11.0.3339.0 (X64)
    I have used this command line tool to test it :
    ssbdiagnose -E CONFIGURATION FROM SERVICE "//E/S/CService" -S "ServerC" -d EDatabase TO SERVICE "//S/S/ECService" -S ServerS -d SDatabase ON CONTRACT //E/S/ECContact
    It returned: 
    An internal exception occurred: Cannot read property ServiceBrokerGuid.
    This property is not available on SQL Server 7.0.
    So, I am wondering, is it supposed to work between these two versions ?
    As more info, in the previous setup, it was using certificates but I have changed the Endpoints to use only Windows Authentication.
    Thanks for any advice.
    Claude

    Hello, 
    Many thanks to you and Fanny for looking at my question.
    In fact I was unclear, please let me provide you with more details.
    Maybe the use of "always on" plays a role here...  I will use different names so it might be clearer...
    ServerSoftware2008 server has SoftwareDB database.
    ServerEmployees2008 server has EmployeesDB database.
    Service broker use to work fine between those two above, with certificates.
    The new server comes in, two virtual servers with SQL Server 2012 Enterprise Edition with Always On.
    I call it ServerEmployeesC but this is the listener.  Behind, there is ServerEmployees2012_A and ServerEmployees2012_B and of course, both have a EmployeesDB database.
    So, to use SSBDiagnose, I wonder if I need to use quotes around values and if I can use the listener name with FQDN.  Concerning the use of instance name in the syntax, there is only one instance per server, is it best practice to use it on the command
    line ?
    Here is again, my command :
    ssbdiagnose -E CONFIGURATION FROM SERVICE "//E/S/E" -S "ServerEmployeesC.sub.acme.com" -d EmployeesDB TO SERVICE "//S/S/E" -S "ServerSoftware2008.sub.acme.com" -d SoftwareDB ON CONTRACT //E/S/E
    Again, many thanks for any help you will be able to provide, the people who configured this application at first are no longer here and I am trying to configure the new server in a task of migrating to SQL Server 2012 for one of the two servers involved
    and I am having a lot of problems doing it.
    Best regards,
    Claude

  • Configuring Service Broker between SQL Server 2008 and 2012 on Intranet

    Hello, I would need help in configuring Service broker. As both servers are on the intranet, I wanted to remain the most simple so I used no certificates and allowed anonymous access but still, using SSBDiagnose, I can see errors.
    I would like to paste here my configuration and my usage of SSBDiagnose, I already asked a question about SSBDiagnose usage but this new question is rather on the usage of certificates and the configuration of SSB, for me to know if I am doing this in the
    best possible way.
    Reading on the web, I have read in few places that certificates are not mandatory and that Windows Authentication only can be used. Then, I read that even if endpoints don't request certificates, the communication between two servers will still requires
    certificates so I am wondering where is the truth... 
    I have two servers:
    EmployeesSvr (SQL Server 2012 Enterprise Edition with Always On, EmployeesSvr is the listener name in front of two virtual servers)
    CREATE MESSAGE TYPE [//E/S/ETChanged] VALIDATION = WELL_FORMED_XML
    CREATE CONTRACT [//E/S/ECContract] ([//E/S/ETChanged] SENT BY INITIATOR)
    CREATE QUEUE [dbo].[ECQueue] WITH STATUS = ON , RETENTION = OFF , ACTIVATION ( STATUS = ON , PROCEDURE_NAME = [dbo].[SSB_ECQueueProc] , MAX_QUEUE_READERS = 1 , EXECUTE AS N'dbo' )
    CREATE SERVICE [//E/S/ECService] ON QUEUE [dbo].[ECQueue] ([//E/S/ECContract])
    CREATE ROUTE [RouteToSECService] WITH SERVICE_NAME = N'//S/S/ECService' , BROKER_INSTANCE = N'F...' , ADDRESS = N'TCP://SoftwaresSrv.test.com:4022'
    CREATE REMOTE SERVICE BINDING [SECServiceBinding] TO SERVICE N'//S/S/ECService' WITH USER = [domain\SvcBrokerTestUser] , ANONYMOUS = ON
    CREATE ENDPOINT [ESBEndpoint] STATE=STARTED AS TCP (LISTENER_PORT = 4022, LISTENER_IP = ALL) FOR SERVICE_BROKER (MESSAGE_FORWARDING = DISABLED, MESSAGE_FORWARD_SIZE = 10, AUTHENTICATION = WINDOWS NEGOTIATE, ENCRYPTION = DISABLED)
    SoftwaresSvr (SQL Server 2008 R2)
    CREATE MESSAGE TYPE [//E/S/ETChanged] VALIDATION = WELL_FORMED_XML
    CREATE CONTRACT [//E/S/ECContract] ([//E/S/ETChanged] SENT BY INITIATOR)
    CREATE QUEUE [dbo].[ECQueue] WITH STATUS = ON , RETENTION = OFF , ACTIVATION ( STATUS = ON , PROCEDURE_NAME = [dbo].[SSB_ECQueueProc] , MAX_QUEUE_READERS = 1 , EXECUTE AS N'dbo' )
    CREATE SERVICE [//S/S/ECService] ON QUEUE [dbo].[ECQueue] ([//E/S/ECContract])
    CREATE ROUTE [RouteToECService] WITH SERVICE_NAME = N'//E/S/ECService' , BROKER_INSTANCE = N'2...' , ADDRESS = N'TCP://EmployeesSvr.test.com:4022'
    CREATE REMOTE SERVICE BINDING [EECServiceBinding] TO SERVICE N'//E/S/ECService' WITH USER = [domain\SvcBrokerTestUser] , ANONYMOUS = ON
    CREATE ENDPOINT [SSBEndpoint] STATE=STARTED AS TCP (LISTENER_PORT = 4022, LISTENER_IP = ALL) FOR SERVICE_BROKER (MESSAGE_FORWARDING = DISABLED, MESSAGE_FORWARD_SIZE = 10, AUTHENTICATION = WINDOWS NEGOTIATE, ENCRYPTION = DISABLED)
    My SSBDiagnose command :
    ssbdiagnose -E CONFIGURATION
    FROM SERVICE //E/S/ECService
    -S EmployersSvr
    -d EmployersDB
    TO SERVICE //S/S/ECService
    -S SoftwaresSvr
    -d SoftwaresDB
    ON CONTRACT //E/S/ECContract
    The result :
    Microsoft SQL Server 10.50.1600.1
    Service Broker Diagnostic Utility
    D 29978 EmployersSvr EmployersDB
    No valid certificate was found for user domain\SvcBrokerTestUser
    D 29977 SoftwaresSvr SoftwaresDB
    The user domain\SvcBrokerTestUser from database EmployersDB on EmployersSvr cannot be mapped into this database using certificates
    D 29933 SoftwaresSvr SoftwaresDB
    The routing address TCP://EmployeesSvr.test.com:4022 for service //E/S/ECService does not match any of the IP addresses for EmployersSvr
    An internal exception occurred: An exception occurred while executing a Transact-SQL statement or batch.
    Thank you for any help, I am searching for several answers :
    Can I use the setup as I defined, with no certificate ?  Is it risky ?
    Is there too many objects defined ?  Is it mandatory to have a Route and a Remote Service Binding ?  I don't understand how those two are working togheter...
    Is it ok to use the same windows account on each side, do they only need an 'Open' access rigth or do they need to be db_owner ?
    Best regards,
    Claude

    Hi Claude,
    1.Can I use the setup as I defined, with no certificate ?  Is it risky ?
    Service broker does not have to use certificate. The Certificate is necessary when you want to use dialog security, by which you can encrypt all messages sent outside a SQL Server instance.
    http://technet.microsoft.com/en-us/library/ms166036(v=SQL.105).aspx
    2.Is there too many objects defined ?  Is it mandatory to have a Route and a Remote Service Binding ?
    Remote Service Binding is used to privde dialog security. If you donnot need the dialog security, the Remote Service Binding is not mandatory.
    http://technet.microsoft.com/en-us/library/ms166042(v=SQL.105).aspx
    By default, each database contains a route that specifies that messages for any service which does not have an explicit route are delivered within the SQL Server instance. Since you have communications between different instances, creating a route between
    them is necessary.
    http://technet.microsoft.com/en-us/library/ms166032(v=SQL.105).aspx
    3.Is it ok to use the same windows account on each side, do they only need an 'Open' access rigth or do they need to be db_owner ?
    The windows account must own the certificate used for authentication. You can find more information below.
    http://technet.microsoft.com/en-us/library/ms166045(v=SQL.105).aspx
    http://technet.microsoft.com/en-us/library/ms186278(v=sql.105).aspx
    Best regards,

  • Behaviour of Service Broker during clustered SQL Server failover

    Hi, 
    I have 3 instances of SQL Server 2005 hosted on a 3-node cluster, using Polyserve clustering.  Each instance is nominally hosted on its own node in the cluster.
    I have configured Service Broker to route messages from INST-A (on NODE-1) to INST-C (on NODE-3), using TCP and a NetBIOS name.  This NetBIOS name obviously uses the machine name of the node, rather than the virtual machine name of the instance.
    Under normal conditions, this works, messages sent from INST-A to INST-C are received and processed.
    However, should INST-C failover (for example to NODE-1), the route created to INST-C from INST-A is no longer valid; INST-C is now on a different node to that specified in the route.
    Service Broker stops, unable to put messages onto the queue on INST-C, so backing them up in sys.transmission_queue on INST-A.  To fix, I have to update the route as appropriate.
    We have thousands of messages being sent every minute.  While a delay in sending them during an actual failover is expected, would it not also be expected to recover itself and process any backlog without manual intervention?
    Is there something I'm missing in my configuration?  Or do I need to set up some other means to automatically update the route upon failover?  In which case, how can I programmatically determine the node to which it has failed-over?
    Configuration scripts:
    Target Endpoint:
    CREATE ENDPOINT ServiceBrokerTargetEndpoint
    STATE = STARTED
    AS TCP(LISTENER_PORT = xxxx)
    FOR SERVICE_BROKER(AUTHENTICATION = WINDOWS, ENCRYPTION = REQUIRED)
    CREATE ROUTE RouteToTargetService
    WITH SERVICE_NAME = 'ServiceBrokerTargetService', ADDRESS = 'TCP://INST-C:xxxx'
    INST-A and INST-C are both SQL 2005 Enterprise edition.
    Thanks for any assistance.
    Simon

    Hi David, 
    Thanks for correctly guessing our longer term plans.  It's good to know this won't be a problem in the future.
    However, that doesn't answer my original question, which is a bit more pressing than waiting until we have migrated.  If it can't be done, it can't be done, and we'll just bear that in mind when responding to failover events.  But I would prefer
    a definitive "no, it can't" rather than a speculative "no".  
    Regards, 
    Simon

Maybe you are looking for