Posts

Showing posts with the label DEADLOCK

A special post: One day at work with me!

Image
Hi Guys, I just got back from the cinema where I watched The Lost City with Sandra Bullock and Channing Tatum.  Yess, a cool film! But now it is the time to turn on the laptop and, as promised in the last post, click on the publish button for a special post!   A day at work with me! Remember , when a day starts before 8:00 with a business phone call it's usually never a good sign! And if an important customer is blocked and you start the day without coffee, this is all ... confirmed! Ok, let's be more precise! When the call from your customer "X" arrives, whose procedure for calculating the stocks of his material is no longer successful! Enjoy the reading! Deadlock & warehouse stock It's urgent! Let's connect with the customer to see what's happening! What to say ...often an error message can tell us a lot: Well, yes (houston!) we have a deadlock problem !   And now, how to proceed? We activate a couple of trace flags: DBCC TRACEON (1204,-1) GO...

SQL Server, How to find deadlocks: the easy way DBCC TRACEON (1204, 1222,-1)

Image
Hi Guys! While in the previous post we talked about finding who's locking our table today i want to show you how to find deadlock! How many times does the customer call you to tell you that they were all blocked? Yeah, today let's talk about how to identify deadlocks! However, we use a method that can trace them in such a way as to avoid being called by the customer when the block occurs . Enjoy the reading! Activate trace flags First of all we need to activate two trace flags through the T-SQL commands below: DBCC TRACEON (1204,-1) GO DBCC TRACEON (1222,-1) GO Now deadlocks will be stored in the SQL Server error log Important: Just remember to disable these trace flag after detected your deadlock. Remember that in this manner these trace flag are enabled until the SQL Server restart Where is located the Error Log You can locate the error log under the SQL Server Agent menu. Look at the image below: Now click on the check hi...

SQL Server: Transazioni, Lock e Deadlock. Un po di teoria spiegata in modo semplice!

Image
Buongiorno a tutti e nuovamente ben ritrovati! Oggi vi volevo parlare di alcuni concetti basilari relativi ai database relazionali che sono assolutamente da sapere. Parleremo di Transazioni , di lock e anche di un tipo particolare di lock detto deadlock . Vi racconterò un po di teoria ma non temete: come al solito cercherò di essere quanto più possibile chiaro! Sei pronti? Allora buona lettura! Diciamo subito cos'è una transazione. Una transazione è una sequenza di operazioni che, se giunta a termine senza errori, produce una variazione di stato nella nostra base dati . Ad esempio: BEGIN TRAN INSERT INTO TABELLA_A (CAMPO1, CAMPO2) VALUES ('VAL1','VAL2') INSERT INTO TABELLA_B(CAMPO1,CAMPO2,CAMPO3) VAULES ('VAL1','VAL2','VAL3') COMMIT oppure INSERT INTO TABELLA_A (CAMPO1, CAMPO2) VALUES ('VAL1','VAL2') Nel primo caso parliamo di transazione esplicita , nel secondo invece ...