Comments (4)
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.
so please can anyone answer me ?
from monitor-table-change-with-sqltabledependency.
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.
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)
- Use DataTable or DataRow
- Permission error
- SqlTableDependency event trigger is not working if running as a BackgroundService HOT 1
- I cannot find a database table named "Table name"
- Nested object
- Returning dynamic Object / ExpandoObject
- Monitor multiple tables HOT 2
- Incorrect syntax near 'POISON_MESSAGE_HANDLING'
- The event object always returns null
- Design question - feasible to use in Azure DevOps and PowerShell script?
- OnChanged doesn't work after some time
- Text column type is not an supperted by SqlTableDependency
- Old stuff. Anyone maintaining this or new approach? HOT 7
- Detecting only Insert and update but not the Delete
- Is there a limit to the number of fields that can be declared in the C# class for trigger detecting?
- Keyword 'trust server certificate' not supported HOT 1
- Could not load file or assembly 'TableDependency.SqlClient, Version=8.5.8.0 HOT 1
- Delete command not working
- .net 8.0.100-rc.2.23502.2 error for SqlTableDependency HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from monitor-table-change-with-sqltabledependency.