Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Strange blocking issue Expand / Collapse
Author
Message
Posted Tuesday, December 11, 2012 3:50 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, November 12, 2014 10:44 AM
Points: 2,634, Visits: 3,985
Hi Experts,

I came across a blocking issue in which the below two process are involved the second statement is blocked by first,but the strange part is they don't have anything in common

insert bulk [dbo].[table1]([MeterReadID] uniqueidentifier,[MeterID] uniqueidentifier,[AssetID] uniqueidentifier,[EntryDate] datetime,[ReadDate] datetime,[Count] bigint,[UserName] nvarchar(50),[MeterSourceID] uniqueidentifier,[MeterExtendedSourceID] uniqueidentifier,[IsRollOver] bit,[StartRead] bigint,[Comment] nvarchar(50),[IsInvalid] bit,[IsCredit] bit,[Credits] bigint,[IsEstimate] bit,[IsSuspect] bit,[IsSuspectHigh] bit,[IsVirtual] bit,[IsRefill] bit,[RefillCount] bigint,[CreatedDate] datetime,[CreatedBy] uniqueidentifier,[ModifiedDate] datetime,[ModifiedBy] uniqueidentifier,[DWIsDeleted] bit,[DWStartDate] datetime,[DWEndDate] datetime,[IsInstall] bit,[IsFinal] bit)


DECLARE @DuplicateRows bigint, @RowsUpdated bigint ; DELETE c FROM dbo.[table2] AS c INNER JOIN dbo.[table2_Deletes] AS a ON c.[MeterReadID] = a.[_MeterReadID] AND c.DWEndDate = a.[ModifiedDate] ; SET @DuplicateRows = @@ROWCOUNT ; UPDATE c SET c.DWEndDate = ISNULL(a.[ModifiedDate], GETDATE()) FROM dbo.[table2] AS c INNER JOIN dbo.[table2_Deletes] AS a ON c.[MeterReadID] = a.[_MeterReadID] WHERE c.DWEndDate IS NULL AND a.IsPruned = 0 ; SET @RowsUpdated = @@ROWCOUNT ; DROP TABLE dbo.[table2_Deletes] ; SELECT @DuplicateRows AS DuplicateRows, @RowsUpdated as RowsUpdated ;

The delete statement is blocked by bulk insert. Can anyone please point out why this happened?
Post #1395009
Posted Tuesday, December 11, 2012 4:52 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: 2 days ago @ 12:03 AM
Points: 1,380, Visits: 2,708
Any chance of referential integrity between these 2 tables?
Post #1395049
Posted Tuesday, December 11, 2012 4:55 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Monday, December 8, 2014 1:45 AM
Points: 5,221, Visits: 5,120
The delete must have been waiting for the bulk insert to release a lock on some resource it had held open.

If you have historic reporting, try looking at what locks where held for the bulk insert, or debug where both of the statements could execute at the same time for transactional concurency and things not committing transactions where they should etc.




Want an answer fast? Try here
How to post data/code for the best help - Jeff Moden
Need a string splitter, try this - Jeff Moden
How to post performance problems - Gail Shaw
CrossTabs-Part1 & Part2 - Jeff Moden
SQL Server Backup, Integrity Check, and Index and Statistics Maintenance - Ola Hallengren
Managing Transaction Logs - Gail Shaw
Troubleshooting SQL Server: A Guide for the Accidental DBA - Jonathan Kehayias and Ted Krueger

Post #1395050
Posted Tuesday, December 11, 2012 5:17 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, November 3, 2014 1:44 AM
Points: 103, Visits: 111
Hi,

Check sp_whoisactive procedure after running the above statements. It will tell you which session id is blocing the table.

OR

U can check the information sys.dm_tran_locks to see if there are any shared and exclusive locks on it.

For more information goto

Adam machanic blog.
http://sqlblog.com/blogs/adam_machanic/archive/tags/sp_5F00_whoisactive/default.aspx
Post #1395060
Posted Tuesday, December 11, 2012 5:19 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Wednesday, November 12, 2014 10:44 AM
Points: 2,634, Visits: 3,985
Thanks SQLACT & Anthony for the reply.

Will check those and update you guys
Post #1395061
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse