Giter VIP home page Giter VIP logo

Comments (4)

JinsPeter avatar JinsPeter commented on June 10, 2024

An internal database error occurred. ---> System.Data.SqlClient.SqlException: Transaction (Process ID 66) was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
We identified that the

I am also getting a similar issue. I have a huge traffic of nearly 100-1000 updates per second in the listened columns.
I update the screen in 3 seconds by querying from DB. The data received in the table changed event cannot suffice my requirement as the grid I show has a JOIN with other 5+ tables.

Is SQLTableDependency ideal for this scenario with this high traffic?
Is it worth it if I actually build infrastructure to rerun the transaction?
Is there a way to debounce / throttle the trigger from the DB itself?

from monitor-table-change-with-sqltabledependency.

hdamis avatar hdamis commented on June 10, 2024

so please can anyone answer me ?

from monitor-table-change-with-sqltabledependency.

MaximG1234 avatar MaximG1234 commented on June 10, 2024

My experience is that this code does not function particularly well under extremely high load where you have a complex schema and I have seen similar errors to what you describe. Frankly at 100-1000 updates per second I don't believe this library is designed for dealing with such high load, nor do I believe it is appropriate to bombard an SQL database in such a way.

If I was dealing with such a high load I would probably be looking at database designed specifically for such scenarios or at the very least batching my updates in some sort of intermediary service.

With that said I have generally used a retry pattern similar to that described in this question. Along with the following code which ensures that all the queues and contracts related to this library are cleaned up prior to restarting the service.


PRINT 'Starting Killing Services'

DECLARE @name VARCHAR(5000) 

DECLARE db_services_cursor CURSOR FOR 
SELECT [name] FROM sys.services 
WHERE service_id > 3

OPEN db_services_cursor  
FETCH NEXT FROM db_services_cursor INTO @name  

WHILE @@FETCH_STATUS = 0  
BEGIN  
	PRINT ('Current Name: ' + @name)
    EXEC('drop service [' + @name + ']')
    FETCH NEXT FROM db_services_cursor INTO @name 
END 

CLOSE db_services_cursor  
DEALLOCATE db_services_cursor 

PRINT 'Ended'



PRINT 'Starting Killing Contracts'

DECLARE @contract_name VARCHAR(5000) 

DECLARE db_contract_cursor CURSOR FOR 
SELECT [name] FROM sys.service_contracts where service_contract_id > 6

OPEN db_contract_cursor  
FETCH NEXT FROM db_contract_cursor INTO @contract_name  

WHILE @@FETCH_STATUS = 0  
BEGIN  
	PRINT ('Current Name: ' + @contract_name)
    EXEC('drop contract [' + @contract_name + ']')
    FETCH NEXT FROM db_contract_cursor INTO @contract_name 
END 

CLOSE db_contract_cursor  
DEALLOCATE db_contract_cursor 

PRINT 'Ended'


PRINT 'Starting Killing Triggers Procs'

DECLARE @triggers_name VARCHAR(5000) 

DECLARE db_triggers_cursor CURSOR FOR 
SELECT name FROM sys.triggers WHERE type = 'TR' and name LIKE 'tr_dbo%_Sender'

OPEN db_triggers_cursor  
FETCH NEXT FROM db_triggers_cursor INTO @triggers_name  

WHILE @@FETCH_STATUS = 0  
BEGIN  
	PRINT ('Current Name: ' + @triggers_name)
    EXEC('drop trigger [' + @triggers_name + ']')
    FETCH NEXT FROM db_triggers_cursor INTO @triggers_name 
END 

CLOSE db_triggers_cursor  
DEALLOCATE db_triggers_cursor 

PRINT 'Ended'



PRINT 'Starting Killing Stored Procs'

DECLARE @storedprocs_name VARCHAR(5000) 

DECLARE db_storedprocs_cursor CURSOR FOR 
SELECT [name] from sysobjects where type = 'P' and category = 0 and name LIKE '%QueueActivationSender'

OPEN db_storedprocs_cursor  
FETCH NEXT FROM db_storedprocs_cursor INTO @storedprocs_name  

WHILE @@FETCH_STATUS = 0  
BEGIN  
	PRINT ('Current Name: ' + @storedprocs_name)
    EXEC('drop PROCEDURE [' + @storedprocs_name + ']')
    FETCH NEXT FROM db_storedprocs_cursor INTO @storedprocs_name 
END 

CLOSE db_storedprocs_cursor  
DEALLOCATE db_storedprocs_cursor 

PRINT 'Ended'


PRINT 'Starting Killing Message Types'

DECLARE @messagetype_name VARCHAR(5000) 

DECLARE db_messagetype_cursor CURSOR FOR 
SELECT [name] FROM sys.service_message_types where message_type_id > 14

OPEN db_messagetype_cursor  
FETCH NEXT FROM db_messagetype_cursor INTO @messagetype_name  

WHILE @@FETCH_STATUS = 0  
BEGIN  
	PRINT ('Current Name: ' + @messagetype_name)
    EXEC('drop MESSAGE TYPE [' + @messagetype_name + ']')
    FETCH NEXT FROM db_messagetype_cursor INTO @messagetype_name 
END 

CLOSE db_messagetype_cursor  
DEALLOCATE db_messagetype_cursor 

PRINT 'Ended'




PRINT 'Starting Killing Queues'

DECLARE @queue_name VARCHAR(5000) 

DECLARE db_queue_cursor CURSOR FOR 
SELECT [name] FROM sys.service_queues where is_ms_shipped = 0

OPEN db_queue_cursor  
FETCH NEXT FROM db_queue_cursor INTO @queue_name  

WHILE @@FETCH_STATUS = 0  
BEGIN  
	PRINT ('Current Name: ' + @queue_name)
    EXEC('drop QUEUE [' + @queue_name + ']')
    FETCH NEXT FROM db_queue_cursor INTO @queue_name 
END 

CLOSE db_queue_cursor  
DEALLOCATE db_queue_cursor 

PRINT 'Ended'

from monitor-table-change-with-sqltabledependency.

hdamis avatar hdamis commented on June 10, 2024

Dear Maxim,
but this will drop the trigger and the clients will not notify for any farther changes. as the trigger is dropped.
and please tell me do you mean to make a job using the above code or a Stored Procedure and when I have to call it.
Thanks,

from monitor-table-change-with-sqltabledependency.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.