Database Transactions and SQL Server Concurrency

Boris Hristov
Boris HristovFounder at 356labs and SQL Server Cosnultant en 356labs
Database Transactions
Transaction Management
and Concurrency Control
SoftUni Team
Technical Trainers
Software University
http://softuni.bg
 Transactions
 The magical “ACID” word
 Locks and SQL Server Concurrency
 Troubleshooting locking problems
 Transaction Isolation Levels
Agenda
What is a Transaction?
 Transactions is a sequence of actions (database operations)
executed as a whole:
 Either all of them complete successfully
 Or none of the them
 Example of transaction:
 A bank transfer from one account into another (withdrawal +
deposit)
 If either the withdrawal or the deposit fails the whole operation is
cancelled
Transactions
4
A Transaction
Rollback
Commit
Read Write
WriteDurable
starting
state
Durable,
consistent,
ending state
Sequence
of reads and
writes
5
 Transactions guarantee the consistency and the integrity of the
database
 All changes in a transaction are temporary
 Changes are persisted when COMMIT is executed
 At any time all changes can be canceled by ROLLBACK
 All of the operations are executed as a whole
 Either all of them or none of them
Transactions Behavior
6
Transactions: Example
Withdraw $100
1. Read savings
2. New savings =
current - $100
3. Read checking
4. New checking =
current + $100
5. Write savings
6. Write checking
1. Read current
balance
2. New balance =
current - $100
3. Write new
balance
4. Dispense cash
Transfer $100
7
 Some actions fail to complete
 For example, the application software or database server crashes
 Interference from another transaction
 What will happen if several transfers run for the same account in
the same time?
What Can Go Wrong?
8
ACID Transactions
 Modern DBMS servers have built-in transaction support
 Implement “ACID” transactions
 E.g. MS SQL Server, Oracle, MySQL, …
 ACID means:
 Atomicity
 Consistency
 Isolation
 Durability
Transactions Properties
10
Atomicity
 Atomicity means that
 Transactions execute as a whole
 DBMS to guarantee that either all of the operations are performed
or none of them
 Atomicity example:
 Transfer funds between bank accounts
 Either withdraw + deposit both execute successfully or none of them
 In case of failure the DB stays unchanged
11
Consistency
 Consistency means that
 The database is in a legal state when the transaction begins and
when it ends
 Only valid data will be written in the DB
 Transaction cannot break the rules of the database, e.g. integrity
constraints
 Primary keys, foreign keys, alternate keys
 Consistency example:
 Transaction cannot end with
a duplicate primary key in a table
12
 Isolation means that
 Multiple transactions running at the same time do not impact
each other’s execution
 Transactions don’t see other
transaction’s uncommitted changes
 Isolation level defines how deep
transactions isolate from one another
 Isolation example:
 If two or more people try to buy the last copy of a product, just
one of them will succeed.
Isolation
13
Durability
 Durability means that
 If a transaction is committed
it becomes persistent
 Cannot be lost or undone
 Ensured by use of database transaction logs
 Durability example:
 After funds are transferred and committed the power supply at
the DB server is lost
 Transaction stays persistent (no data is lost)
14
Managing Transactions in SQL
 Start a transaction
 BEGIN TRANSACTION
 Some RDBMS use implicit start, e.g. Oracle
 Ending a transaction
 COMMIT
 Complete a successful transaction and persist all changes made
 ROLLBACK
 “Undo” changes from an aborted transaction
 May be done automatically when failure occurs
Transactions and SQL
16
 We have a table with bank accounts:
 We use a transaction to transfer money from one account into another
Transactions in SQL Server: Example
CREATE TABLE Accounts(
Id int NOT NULL PRIMARY KEY,
Balance decimal NOT NULL)
CREATE PROCEDURE sp_Transfer_Funds(
@from_account INT,
@to_account INT,
@amount MONEY) AS
BEGIN
BEGIN TRAN;
(example continues)
17
Transactions in SQL Server: Example (2)
UPDATE Accounts SET Balance = Balance - @amount
WHERE Id = @from_account;
IF @@ROWCOUNT <> 1
BEGIN
ROLLBACK;
RAISERROR('Invalid src account!', 16, 1);
RETURN;
END;
UPDATE Accounts SET Balance = Balance + @amount
WHERE Id = @to_account;
IF @@ROWCOUNT <> 1
BEGIN
ROLLBACK;
RAISERROR('Invalid dest account!', 16, 1);
RETURN;
END;
COMMIT;
END;
18
 Default transaction mode
 Every TSQL statement is committed or rolled back on completion
 Compile errors result in entire batch not being executed
 Run time errors may allow part of the batch to commit
Auto Commit Transactions
---run time error - partially executed
USE AdventureWorks2012;
GO
CREATE TABLE TestBatch (Cola INT PRIMARY KEY, Colb CHAR(3));
GO
INSERT INTO TestBatch VALUES (1, 'aaa');
INSERT INTO TestBatch VALUES (2, 'bbb');
INSERT INTO TestBatch VALUES (1, 'ccc'); -- Duplicate key error.
GO
SELECT * FROM TestBatch; -- Returns rows 1 and 2.
GO
 SQL Server is responsible for opening the transaction
 We are responsible for committing or rolling it back
 Can be turned on from Connections tab in Server Properties
Implicit Transactions
SET IMPLICIT_TRANSACTIONS ON
USE AdventureWorks2012
GO
UPDATE [Person].[Address]
SET AddressLine1='SoftUni, Sofia'
WHERE AddressID=2
COMMIT
– this will write a change to the db
SET IMPLICIT_TRANSACTIONS ON
USE AdventureWorks2012
GO
UPDATE [Person].[Address]
SET AddressLine1='SoftUni, Sofia'
WHERE AddressID=2
ROLLBACK
– this will not write a change to the db
Explicit Transactions
 A transaction in which start and end of transaction is explicitly declared
 BEGIN TRANSACTION
 COMMIT TRANSACTION OR ROLLBACK TRANSACTION
 XACT_ABORT ON/OFF – control the rollback behavior
SET XACT_ABORT ON – if run time error is generated everything is rolled back
USE AdventureWorks2012
GO
BEGIN TRANSACTION FundsTransfer
GO
EXEC HumanResources.DebitAccount '100', 'account1';
EXEC HumanResources.CreditAccount '100', 'account2';
COMMIT TRANSACTION;
Managing Transactions in SQL
Demo
Locks and SQL Server Concurrency
 Pessimistic
– SQL Server uses locks, causes blocks and who said deadlocks?
 Optimistic
– SQL Server generates versions for everyone, but the updates…
Methods of Concurrency Control
What Are Locks and what is locking?
 Lock – internal memory structure that “tells” us what we all do with the
resources inside the system
 Locking – mechanism to protect the resources and guarantee consistent data
Intent
Used for: Preventing
incompatible locks
Duration: End of the
transaction
Shared (S)
Used for: Reading
Duration: Released almost
immediately
(depends on the isolation level)
Update (U)
Used for: Preparing to modify
Duration: End of the
transaction or until converted
to exclusive (X)
Exclusive (X)
Used for: Modifying
Duration: End of the
transaction
Common Lock Types
Not all locks are compatible with other locks.
Lock Compatibility
Lock Shared Update Exclusive
Shared (S)
  X
Update (U)
 X X
Exclusive (X)
X X X
Lock Hierarchy
Database
Table
Page
Row
Let’s update a row!
What do we need?
Header
Row
Row
Row
Row
Row
USE AdventureWorks2012
GO
UPDATE [Person].[Address]
SET AddressLine1='SoftUni, Sofia'
WHERE AddressID=2
IX
S
IX
X
Methods to View Locking Information
Dynamic
Management
Views
SQL Server
Profiler or
Extended Events
Performance
monitor or
Activity Monitor
Troubleshooting Locking Problems
Locking and blocking are often confused!
Locking
 The action of taking and potentially holding locks
 Used to implement concurrency control
Blocking is result of locking!
 One process needs to wait for another process to release locked resources
 In a multiuser environment, there is always, always blocking!
 Only a problem if it lasts too long
Locking and blocking
Lock escalation
>= 5000
IX
Header
Row
Row
Row
Row
Row
S
IX
X
X
X
X
S
X
Controlling Lock escalation
SELECT lock_escalation_desc
FROM sys.tables
WHERE name = 'Person.Address'
ALTER TABLE Person.Address SET (LOCK_ESCALATION = {AUTO | TABLE | DISABLE}
 Switch the escalation level (per table)
AUTO – Partition-level escalation if the table is partitioned
TABLE – Always table-level escalation
DISABLE – Do not escalate until absolutely necessary
 Just disable it (that’s not Nike’s “Just do it!”)
 Trace flag 1211 – disables lock escalation on server level
 Trace flag 1224 – disables lock escalation if 40% of the memory used is consumed
 Who is victim?
 Cost for Rollback
 Deadlock priority – SET DEADLOCK_PRIORITY
What Are Deadlocks?
Task A
Task B
Resource 1
Resource 2
Resolve blocking a.k.a lokcking
 Keep the transactions as short as possible
 No user interactions required in the middle of the transaction
 Use indexes (proper ones)
 Consider a server to offload some of the workloads
 Choose proper isolation level
Locks and SQL Server Concurrency
Demo
Transaction Isolation Levels
Demo
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED (NOLOCK?)
Read Uncommitted
Transaction 1
Transaction 2
Suggestion: Better offload the reads or go with optimistic level concurrency!
Select
Update
eXclusive lock
Dirty read
SET TRANSACTION ISOLATION LEVEL REPEATABLE READ
Repeatable Read
Transaction 1
S(hared) lock
select
No non-repeatable reads possible (updates during Transaction 1)
Phantom records still possible (inserts during Transaction 1)
Update
Transaction 2
Serializable
Transaction 1 S(hared) lock
select
Even phantom records are not possible!
Highest pessimistic level of isolation, lowest level of concurrency
Insert
Transaction 2
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
Optimistic Concurrency
 Based on Row versioning (stored inside tempdb’s version store area)
 No dirty, non-repeatable reads or phantom records
 Every single modification is versioned even if not used
 Adds 14 bytes per row
 Readers do not block writers and writers do not block readers
 Writers can and will block writers, this can cause conflicts!
Read Committed and Snapshot Isolation levels
V1 V2
Transaction 1
Transaction 2
Select in RCSISelect
Select in SI
 RCSI – Read Committed Snapshot Isolation Level
 Statement level versioning
 Requires ALTER DATABASE SET READ_COMMITTED_SNAPSHOT ON
 Snapshot Isolation Level
 Transaction level versioning
 Requires ALTER DATABASE SET ALLOW_SNAPSHOT_ISOLATION ON
 Requires SET TRANSACTION ISOLATION LEVEL SNAPSHOT
Concurrency Phenomenon in Isolation Levels
44
Level of Isolation
Dirty
Reads
Repeatable Reads Phantom Reads
Read uncommitted yes yes yes
Read committed no yes yes
Repeatable read no no yes
Serializable no no No
Read Committed Snapshot no no yes
Snapshot no no no
Transaction Isolation Levels
Demo
 Transactions
 The magical “ACID” word
 Locks and SQL Server Concurrency
 Troubleshooting locking problems
 Transaction Isolation Levels
Summary
?
https://softuni.bg/courses/databases
Databases
Resources
MCM Readiness videos on locking lecture and demo
MCM Readiness video on Snapshot Isolation Level
http://blogs.msdn.com/b/bartd/archive/tags/sql+locking
http://www.sqlskills.com/blogs/paul/category/locking/
Lock hints - http://www.techrepublic.com/article/control-sql-
server-locking-with-hints/5181472
License
 This course (slides, examples, demos, videos, homework, etc.)
is licensed under the "Creative Commons Attribution-
NonCommercial-ShareAlike 4.0 International" license
49
 Attribution: this work may contain portions from
 "Databases" course by Telerik Academy under CC-BY-NC-SA license
Free Trainings @ Software University
 Software University Foundation – softuni.org
 Software University – High-Quality Education,
Profession and Job for Software Developers
 softuni.bg
 Software University @ Facebook
 facebook.com/SoftwareUniversity
 Software University @ YouTube
 youtube.com/SoftwareUniversity
 Software University Forums – forum.softuni.bg
1 de 50

Recomendados

Concurrency in SQL Server (SQL Night #24) por
Concurrency in SQL Server (SQL Night #24)Concurrency in SQL Server (SQL Night #24)
Concurrency in SQL Server (SQL Night #24)Antonios Chatzipavlis
2.5K vistas74 diapositivas
SQL Server Transaction Management por
SQL Server Transaction ManagementSQL Server Transaction Management
SQL Server Transaction ManagementMark Ginnebaugh
4.2K vistas22 diapositivas
11. transaction sql por
11. transaction sql11. transaction sql
11. transaction sqlUmang Gupta
2.3K vistas23 diapositivas
15. Transactions in DBMS por
15. Transactions in DBMS15. Transactions in DBMS
15. Transactions in DBMSkoolkampus
80.5K vistas42 diapositivas
17. Recovery System in DBMS por
17. Recovery System in DBMS17. Recovery System in DBMS
17. Recovery System in DBMSkoolkampus
40.5K vistas71 diapositivas
ACID- Database Transaction Properties por
ACID- Database Transaction PropertiesACID- Database Transaction Properties
ACID- Database Transaction PropertiesMarkajul Hasnain Alif
1.2K vistas17 diapositivas

Más contenido relacionado

La actualidad más candente

Transaction Management - Deadlock Handling por
Transaction Management - Deadlock HandlingTransaction Management - Deadlock Handling
Transaction Management - Deadlock Handlingkavitha muneeshwaran
689 vistas13 diapositivas
Introduction to transaction management por
Introduction to transaction managementIntroduction to transaction management
Introduction to transaction managementDr. C.V. Suresh Babu
440 vistas18 diapositivas
Transaction management DBMS por
Transaction  management DBMSTransaction  management DBMS
Transaction management DBMSMegha Patel
16.3K vistas20 diapositivas
ACID Property in DBMS por
ACID Property in DBMSACID Property in DBMS
ACID Property in DBMSTechtud Network
3.2K vistas7 diapositivas
MYSQL.ppt por
MYSQL.pptMYSQL.ppt
MYSQL.pptwebhostingguy
40.4K vistas41 diapositivas
Sql joins por
Sql joinsSql joins
Sql joinsGaurav Dhanwant
2.3K vistas31 diapositivas

La actualidad más candente(20)

Transaction management DBMS por Megha Patel
Transaction  management DBMSTransaction  management DBMS
Transaction management DBMS
Megha Patel16.3K vistas
Transaction por Amin Omi
TransactionTransaction
Transaction
Amin Omi3K vistas
Transaction Processing Concept por Nishant Munjal
Transaction Processing ConceptTransaction Processing Concept
Transaction Processing Concept
Nishant Munjal5.4K vistas
16. Concurrency Control in DBMS por koolkampus
16. Concurrency Control in DBMS16. Concurrency Control in DBMS
16. Concurrency Control in DBMS
koolkampus39.6K vistas
Transaction states and properties por Chetan Mahawar
Transaction states and propertiesTransaction states and properties
Transaction states and properties
Chetan Mahawar9.5K vistas
Types Of Join In Sql Server - Join With Example In Sql Server por programmings guru
Types Of Join In Sql Server - Join With Example In Sql ServerTypes Of Join In Sql Server - Join With Example In Sql Server
Types Of Join In Sql Server - Join With Example In Sql Server
programmings guru25.8K vistas
Integrity Constraints por madhav bansal
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
madhav bansal17.2K vistas
Web server por Ankit Raj
Web serverWeb server
Web server
Ankit Raj6K vistas
Inner join and outer join por Nargis Ehsan
Inner join and outer joinInner join and outer join
Inner join and outer join
Nargis Ehsan2.9K vistas
3 Level Architecture por Adeel Rasheed
3 Level Architecture3 Level Architecture
3 Level Architecture
Adeel Rasheed3.3K vistas
Relational Algebra,Types of join por raj upadhyay
Relational Algebra,Types of joinRelational Algebra,Types of join
Relational Algebra,Types of join
raj upadhyay17.9K vistas

Destacado

Transaction management and concurrency control por
Transaction management and concurrency controlTransaction management and concurrency control
Transaction management and concurrency controlDhani Ahmad
9.6K vistas50 diapositivas
Database Performance por
Database PerformanceDatabase Performance
Database PerformanceBoris Hristov
3.6K vistas39 diapositivas
The Nightmare of Locking, Blocking and Isolation Levels! por
The Nightmare of Locking, Blocking and Isolation Levels!The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!Boris Hristov
2K vistas29 diapositivas
The World of Business Intelligence por
The World of Business IntelligenceThe World of Business Intelligence
The World of Business IntelligenceBoris Hristov
2.4K vistas24 diapositivas
Locking And Concurrency por
Locking And ConcurrencyLocking And Concurrency
Locking And Concurrencysqlserver.co.il
2.8K vistas39 diapositivas
Transaction concurrency control por
Transaction concurrency controlTransaction concurrency control
Transaction concurrency controlAnand Grewal
10.6K vistas44 diapositivas

Destacado(20)

Transaction management and concurrency control por Dhani Ahmad
Transaction management and concurrency controlTransaction management and concurrency control
Transaction management and concurrency control
Dhani Ahmad9.6K vistas
Database Performance por Boris Hristov
Database PerformanceDatabase Performance
Database Performance
Boris Hristov3.6K vistas
The Nightmare of Locking, Blocking and Isolation Levels! por Boris Hristov
The Nightmare of Locking, Blocking and Isolation Levels!The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!
Boris Hristov2K vistas
The World of Business Intelligence por Boris Hristov
The World of Business IntelligenceThe World of Business Intelligence
The World of Business Intelligence
Boris Hristov2.4K vistas
Transaction concurrency control por Anand Grewal
Transaction concurrency controlTransaction concurrency control
Transaction concurrency control
Anand Grewal10.6K vistas
Concurrency control por Virender Kumar
Concurrency controlConcurrency control
Concurrency control
Virender Kumar156.5K vistas
The Nightmare of Locking, Blocking and Isolation Levels! por Boris Hristov
The Nightmare of Locking, Blocking and Isolation Levels!The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!
Boris Hristov1K vistas
First Steps with Microsoft SQL Server por Boris Hristov
First Steps with Microsoft SQL ServerFirst Steps with Microsoft SQL Server
First Steps with Microsoft SQL Server
Boris Hristov2K vistas
Using grouping sets in sql server 2008 tech republic por Kaing Menglieng
Using grouping sets in sql server 2008   tech republicUsing grouping sets in sql server 2008   tech republic
Using grouping sets in sql server 2008 tech republic
Kaing Menglieng416 vistas
Sql tuning guideline por Sidney Chen
Sql tuning guidelineSql tuning guideline
Sql tuning guideline
Sidney Chen1.6K vistas
Sql xp 04 por Niit Care
Sql xp 04Sql xp 04
Sql xp 04
Niit Care845 vistas
Statistics por Riteshkiit
StatisticsStatistics
Statistics
Riteshkiit1.6K vistas
e computer notes - Subqueries por ecomputernotes
e computer notes - Subqueriese computer notes - Subqueries
e computer notes - Subqueries
ecomputernotes936 vistas

Similar a Database Transactions and SQL Server Concurrency

Svetlin Nakov - Database Transactions por
Svetlin Nakov - Database TransactionsSvetlin Nakov - Database Transactions
Svetlin Nakov - Database TransactionsSvetlin Nakov
2.6K vistas59 diapositivas
Intro to tsql unit 12 por
Intro to tsql   unit 12Intro to tsql   unit 12
Intro to tsql unit 12Syed Asrarali
612 vistas44 diapositivas
Database concurrency and transactions - Tal Olier por
Database concurrency and transactions - Tal OlierDatabase concurrency and transactions - Tal Olier
Database concurrency and transactions - Tal Oliersqlserver.co.il
396 vistas57 diapositivas
Transaction por
TransactionTransaction
TransactionDimara Hakim
560 vistas32 diapositivas
Dbms por
DbmsDbms
Dbmsnaresh sharma
553 vistas28 diapositivas
Lecture 5. MS SQL. Transactions por
Lecture 5. MS SQL. TransactionsLecture 5. MS SQL. Transactions
Lecture 5. MS SQL. TransactionsAlexey Furmanov
646 vistas16 diapositivas

Similar a Database Transactions and SQL Server Concurrency(20)

Svetlin Nakov - Database Transactions por Svetlin Nakov
Svetlin Nakov - Database TransactionsSvetlin Nakov - Database Transactions
Svetlin Nakov - Database Transactions
Svetlin Nakov2.6K vistas
Database concurrency and transactions - Tal Olier por sqlserver.co.il
Database concurrency and transactions - Tal OlierDatabase concurrency and transactions - Tal Olier
Database concurrency and transactions - Tal Olier
sqlserver.co.il396 vistas
Lecture 5. MS SQL. Transactions por Alexey Furmanov
Lecture 5. MS SQL. TransactionsLecture 5. MS SQL. Transactions
Lecture 5. MS SQL. Transactions
Alexey Furmanov646 vistas
Welcome to the nightmare of locking, blocking and isolation levels! por Boris Hristov
Welcome to the nightmare of locking, blocking and isolation levels!Welcome to the nightmare of locking, blocking and isolation levels!
Welcome to the nightmare of locking, blocking and isolation levels!
Boris Hristov810 vistas
Dbms sixth chapter_part-1_2011 por sumit_study
Dbms sixth chapter_part-1_2011Dbms sixth chapter_part-1_2011
Dbms sixth chapter_part-1_2011
sumit_study5.3K vistas
The Nightmare of Locking, Blocking and Isolation Levels! por Boris Hristov
The Nightmare of Locking, Blocking and Isolation Levels!The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!
Boris Hristov527 vistas
Transactions and Concurrency Control por Dilum Bandara
Transactions and Concurrency ControlTransactions and Concurrency Control
Transactions and Concurrency Control
Dilum Bandara4.2K vistas
Welcome to the nightmare of locking, blocking and isolation levels! por Boris Hristov
Welcome to the nightmare of locking, blocking and isolation levels!Welcome to the nightmare of locking, blocking and isolation levels!
Welcome to the nightmare of locking, blocking and isolation levels!
Boris Hristov2.3K vistas
Transaction and concurrency pitfalls in Java por Ersen Öztoprak
Transaction and concurrency pitfalls in JavaTransaction and concurrency pitfalls in Java
Transaction and concurrency pitfalls in Java
Ersen Öztoprak294 vistas
dokumen.tips_silberschatz-korth-and-sudarshan1-transactions-transaction-conce... por DrCViji
dokumen.tips_silberschatz-korth-and-sudarshan1-transactions-transaction-conce...dokumen.tips_silberschatz-korth-and-sudarshan1-transactions-transaction-conce...
dokumen.tips_silberschatz-korth-and-sudarshan1-transactions-transaction-conce...
DrCViji14 vistas
database management system Chapter 5 por Mohamad Syazwan
database management system Chapter 5database management system Chapter 5
database management system Chapter 5
Mohamad Syazwan1.4K vistas
Managing Memory & Locks - Series 2 Transactions & Lock management por DAGEOP LTD
Managing  Memory & Locks - Series 2 Transactions & Lock managementManaging  Memory & Locks - Series 2 Transactions & Lock management
Managing Memory & Locks - Series 2 Transactions & Lock management
DAGEOP LTD350 vistas
Transaction Properties in database | ACID Properties por nomanbarki
Transaction Properties in database | ACID PropertiesTransaction Properties in database | ACID Properties
Transaction Properties in database | ACID Properties
nomanbarki3.4K vistas

Más de Boris Hristov

The Secret to Engaging Presentations por
The Secret to Engaging PresentationsThe Secret to Engaging Presentations
The Secret to Engaging PresentationsBoris Hristov
903 vistas47 diapositivas
Presentation Design Fundamentals por
Presentation Design FundamentalsPresentation Design Fundamentals
Presentation Design FundamentalsBoris Hristov
482 vistas64 diapositivas
The 5 Hidden Performance Gems of SQL Server 2014 por
The 5 Hidden Performance Gems of SQL Server 2014The 5 Hidden Performance Gems of SQL Server 2014
The 5 Hidden Performance Gems of SQL Server 2014Boris Hristov
2.6K vistas33 diapositivas
Securing SQL Azure DB? How? por
Securing SQL Azure DB? How?Securing SQL Azure DB? How?
Securing SQL Azure DB? How?Boris Hristov
1.6K vistas31 diapositivas
How to Deliver Technical Presentations: The Right Way! por
How to Deliver Technical Presentations: The Right Way!How to Deliver Technical Presentations: The Right Way!
How to Deliver Technical Presentations: The Right Way!Boris Hristov
2K vistas33 diapositivas
Securing SQL Azure DB? How? por
Securing SQL Azure DB? How?Securing SQL Azure DB? How?
Securing SQL Azure DB? How?Boris Hristov
1.5K vistas28 diapositivas

Más de Boris Hristov(20)

The Secret to Engaging Presentations por Boris Hristov
The Secret to Engaging PresentationsThe Secret to Engaging Presentations
The Secret to Engaging Presentations
Boris Hristov903 vistas
Presentation Design Fundamentals por Boris Hristov
Presentation Design FundamentalsPresentation Design Fundamentals
Presentation Design Fundamentals
Boris Hristov482 vistas
The 5 Hidden Performance Gems of SQL Server 2014 por Boris Hristov
The 5 Hidden Performance Gems of SQL Server 2014The 5 Hidden Performance Gems of SQL Server 2014
The 5 Hidden Performance Gems of SQL Server 2014
Boris Hristov2.6K vistas
Securing SQL Azure DB? How? por Boris Hristov
Securing SQL Azure DB? How?Securing SQL Azure DB? How?
Securing SQL Azure DB? How?
Boris Hristov1.6K vistas
How to Deliver Technical Presentations: The Right Way! por Boris Hristov
How to Deliver Technical Presentations: The Right Way!How to Deliver Technical Presentations: The Right Way!
How to Deliver Technical Presentations: The Right Way!
Boris Hristov2K vistas
Securing SQL Azure DB? How? por Boris Hristov
Securing SQL Azure DB? How?Securing SQL Azure DB? How?
Securing SQL Azure DB? How?
Boris Hristov1.5K vistas
Top 5 T-SQL Improvements in SQL Server 2014 por Boris Hristov
Top 5 T-SQL Improvements in SQL Server 2014Top 5 T-SQL Improvements in SQL Server 2014
Top 5 T-SQL Improvements in SQL Server 2014
Boris Hristov1.1K vistas
Presentation Skills: The Next Level por Boris Hristov
Presentation Skills: The Next LevelPresentation Skills: The Next Level
Presentation Skills: The Next Level
Boris Hristov1.1K vistas
The Nightmare of Locking, Blocking and Isolation Levels! por Boris Hristov
The Nightmare of Locking, Blocking and Isolation Levels!The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!
Boris Hristov2.1K vistas
SQL Server 2014: Ready. Steady. Go! por Boris Hristov
SQL Server 2014: Ready. Steady. Go!SQL Server 2014: Ready. Steady. Go!
SQL Server 2014: Ready. Steady. Go!
Boris Hristov1.7K vistas
BI PoC for the Telco Industry por Boris Hristov
BI PoC for the Telco IndustryBI PoC for the Telco Industry
BI PoC for the Telco Industry
Boris Hristov469 vistas
Presentation Design Basics por Boris Hristov
Presentation Design BasicsPresentation Design Basics
Presentation Design Basics
Boris Hristov1.5K vistas
Deep Into Isolation Levels por Boris Hristov
Deep Into Isolation LevelsDeep Into Isolation Levels
Deep Into Isolation Levels
Boris Hristov2.4K vistas
Top 5 T-SQL Improvements in SQL Server 2014 por Boris Hristov
Top 5 T-SQL Improvements in SQL Server 2014Top 5 T-SQL Improvements in SQL Server 2014
Top 5 T-SQL Improvements in SQL Server 2014
Boris Hristov1.1K vistas
You want rules? You need Policy-Based Management! por Boris Hristov
You want rules? You need Policy-Based Management!You want rules? You need Policy-Based Management!
You want rules? You need Policy-Based Management!
Boris Hristov800 vistas
The Nightmare of Locking, Blocking and Isolation Levels! por Boris Hristov
The Nightmare of Locking, Blocking and Isolation Levels!The Nightmare of Locking, Blocking and Isolation Levels!
The Nightmare of Locking, Blocking and Isolation Levels!
Boris Hristov899 vistas
The Nightmare of Locking, Blocking and Isolation Levels por Boris Hristov
The Nightmare of Locking, Blocking and Isolation LevelsThe Nightmare of Locking, Blocking and Isolation Levels
The Nightmare of Locking, Blocking and Isolation Levels
Boris Hristov825 vistas
Welcome to the nightmare of locking, blocking and isolation levels! por Boris Hristov
Welcome to the nightmare of locking, blocking and isolation levels!Welcome to the nightmare of locking, blocking and isolation levels!
Welcome to the nightmare of locking, blocking and isolation levels!
Boris Hristov656 vistas
The nightmare of locking, blocking and isolation levels! por Boris Hristov
The nightmare of locking, blocking and isolation levels!The nightmare of locking, blocking and isolation levels!
The nightmare of locking, blocking and isolation levels!
Boris Hristov1.2K vistas
Top 5 TSQL Improvements in SQL Server 2014 por Boris Hristov
Top 5 TSQL Improvements in SQL Server 2014Top 5 TSQL Improvements in SQL Server 2014
Top 5 TSQL Improvements in SQL Server 2014
Boris Hristov7.3K vistas

Último

Kyo - Functional Scala 2023.pdf por
Kyo - Functional Scala 2023.pdfKyo - Functional Scala 2023.pdf
Kyo - Functional Scala 2023.pdfFlavio W. Brasil
449 vistas92 diapositivas
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti... por
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...ShapeBlue
98 vistas29 diapositivas
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online por
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineKVM Security Groups Under the Hood - Wido den Hollander - Your.Online
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineShapeBlue
181 vistas19 diapositivas
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... por
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...ShapeBlue
144 vistas12 diapositivas
"Surviving highload with Node.js", Andrii Shumada por
"Surviving highload with Node.js", Andrii Shumada "Surviving highload with Node.js", Andrii Shumada
"Surviving highload with Node.js", Andrii Shumada Fwdays
53 vistas29 diapositivas
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... por
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...James Anderson
156 vistas32 diapositivas

Último(20)

DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti... por ShapeBlue
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
DRaaS using Snapshot copy and destination selection (DRaaS) - Alexandre Matti...
ShapeBlue98 vistas
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online por ShapeBlue
KVM Security Groups Under the Hood - Wido den Hollander - Your.OnlineKVM Security Groups Under the Hood - Wido den Hollander - Your.Online
KVM Security Groups Under the Hood - Wido den Hollander - Your.Online
ShapeBlue181 vistas
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ... por ShapeBlue
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
Backup and Disaster Recovery with CloudStack and StorPool - Workshop - Venko ...
ShapeBlue144 vistas
"Surviving highload with Node.js", Andrii Shumada por Fwdays
"Surviving highload with Node.js", Andrii Shumada "Surviving highload with Node.js", Andrii Shumada
"Surviving highload with Node.js", Andrii Shumada
Fwdays53 vistas
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N... por James Anderson
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
GDG Cloud Southlake 28 Brad Taylor and Shawn Augenstein Old Problems in the N...
James Anderson156 vistas
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O... por ShapeBlue
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
Declarative Kubernetes Cluster Deployment with Cloudstack and Cluster API - O...
ShapeBlue88 vistas
DRBD Deep Dive - Philipp Reisner - LINBIT por ShapeBlue
DRBD Deep Dive - Philipp Reisner - LINBITDRBD Deep Dive - Philipp Reisner - LINBIT
DRBD Deep Dive - Philipp Reisner - LINBIT
ShapeBlue140 vistas
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava... por ShapeBlue
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
Centralized Logging Feature in CloudStack using ELK and Grafana - Kiran Chava...
ShapeBlue101 vistas
The Power of Heat Decarbonisation Plans in the Built Environment por IES VE
The Power of Heat Decarbonisation Plans in the Built EnvironmentThe Power of Heat Decarbonisation Plans in the Built Environment
The Power of Heat Decarbonisation Plans in the Built Environment
IES VE69 vistas
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda... por ShapeBlue
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
Hypervisor Agnostic DRS in CloudStack - Brief overview & demo - Vishesh Jinda...
ShapeBlue120 vistas
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And... por ShapeBlue
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
Enabling DPU Hardware Accelerators in XCP-ng Cloud Platform Environment - And...
ShapeBlue63 vistas
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT por ShapeBlue
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBITUpdates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
Updates on the LINSTOR Driver for CloudStack - Rene Peinthor - LINBIT
ShapeBlue166 vistas
Ransomware is Knocking your Door_Final.pdf por Security Bootcamp
Ransomware is Knocking your Door_Final.pdfRansomware is Knocking your Door_Final.pdf
Ransomware is Knocking your Door_Final.pdf
Security Bootcamp90 vistas
Initiating and Advancing Your Strategic GIS Governance Strategy por Safe Software
Initiating and Advancing Your Strategic GIS Governance StrategyInitiating and Advancing Your Strategic GIS Governance Strategy
Initiating and Advancing Your Strategic GIS Governance Strategy
Safe Software140 vistas
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T por ShapeBlue
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&TCloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
CloudStack and GitOps at Enterprise Scale - Alex Dometrius, Rene Glover - AT&T
ShapeBlue112 vistas
Business Analyst Series 2023 - Week 4 Session 8 por DianaGray10
Business Analyst Series 2023 -  Week 4 Session 8Business Analyst Series 2023 -  Week 4 Session 8
Business Analyst Series 2023 - Week 4 Session 8
DianaGray1086 vistas
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R... por ShapeBlue
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
Setting Up Your First CloudStack Environment with Beginners Challenges - MD R...
ShapeBlue132 vistas
State of the Union - Rohit Yadav - Apache CloudStack por ShapeBlue
State of the Union - Rohit Yadav - Apache CloudStackState of the Union - Rohit Yadav - Apache CloudStack
State of the Union - Rohit Yadav - Apache CloudStack
ShapeBlue253 vistas

Database Transactions and SQL Server Concurrency

  • 1. Database Transactions Transaction Management and Concurrency Control SoftUni Team Technical Trainers Software University http://softuni.bg
  • 2.  Transactions  The magical “ACID” word  Locks and SQL Server Concurrency  Troubleshooting locking problems  Transaction Isolation Levels Agenda
  • 3. What is a Transaction?
  • 4.  Transactions is a sequence of actions (database operations) executed as a whole:  Either all of them complete successfully  Or none of the them  Example of transaction:  A bank transfer from one account into another (withdrawal + deposit)  If either the withdrawal or the deposit fails the whole operation is cancelled Transactions 4
  • 6.  Transactions guarantee the consistency and the integrity of the database  All changes in a transaction are temporary  Changes are persisted when COMMIT is executed  At any time all changes can be canceled by ROLLBACK  All of the operations are executed as a whole  Either all of them or none of them Transactions Behavior 6
  • 7. Transactions: Example Withdraw $100 1. Read savings 2. New savings = current - $100 3. Read checking 4. New checking = current + $100 5. Write savings 6. Write checking 1. Read current balance 2. New balance = current - $100 3. Write new balance 4. Dispense cash Transfer $100 7
  • 8.  Some actions fail to complete  For example, the application software or database server crashes  Interference from another transaction  What will happen if several transfers run for the same account in the same time? What Can Go Wrong? 8
  • 10.  Modern DBMS servers have built-in transaction support  Implement “ACID” transactions  E.g. MS SQL Server, Oracle, MySQL, …  ACID means:  Atomicity  Consistency  Isolation  Durability Transactions Properties 10
  • 11. Atomicity  Atomicity means that  Transactions execute as a whole  DBMS to guarantee that either all of the operations are performed or none of them  Atomicity example:  Transfer funds between bank accounts  Either withdraw + deposit both execute successfully or none of them  In case of failure the DB stays unchanged 11
  • 12. Consistency  Consistency means that  The database is in a legal state when the transaction begins and when it ends  Only valid data will be written in the DB  Transaction cannot break the rules of the database, e.g. integrity constraints  Primary keys, foreign keys, alternate keys  Consistency example:  Transaction cannot end with a duplicate primary key in a table 12
  • 13.  Isolation means that  Multiple transactions running at the same time do not impact each other’s execution  Transactions don’t see other transaction’s uncommitted changes  Isolation level defines how deep transactions isolate from one another  Isolation example:  If two or more people try to buy the last copy of a product, just one of them will succeed. Isolation 13
  • 14. Durability  Durability means that  If a transaction is committed it becomes persistent  Cannot be lost or undone  Ensured by use of database transaction logs  Durability example:  After funds are transferred and committed the power supply at the DB server is lost  Transaction stays persistent (no data is lost) 14
  • 16.  Start a transaction  BEGIN TRANSACTION  Some RDBMS use implicit start, e.g. Oracle  Ending a transaction  COMMIT  Complete a successful transaction and persist all changes made  ROLLBACK  “Undo” changes from an aborted transaction  May be done automatically when failure occurs Transactions and SQL 16
  • 17.  We have a table with bank accounts:  We use a transaction to transfer money from one account into another Transactions in SQL Server: Example CREATE TABLE Accounts( Id int NOT NULL PRIMARY KEY, Balance decimal NOT NULL) CREATE PROCEDURE sp_Transfer_Funds( @from_account INT, @to_account INT, @amount MONEY) AS BEGIN BEGIN TRAN; (example continues) 17
  • 18. Transactions in SQL Server: Example (2) UPDATE Accounts SET Balance = Balance - @amount WHERE Id = @from_account; IF @@ROWCOUNT <> 1 BEGIN ROLLBACK; RAISERROR('Invalid src account!', 16, 1); RETURN; END; UPDATE Accounts SET Balance = Balance + @amount WHERE Id = @to_account; IF @@ROWCOUNT <> 1 BEGIN ROLLBACK; RAISERROR('Invalid dest account!', 16, 1); RETURN; END; COMMIT; END; 18
  • 19.  Default transaction mode  Every TSQL statement is committed or rolled back on completion  Compile errors result in entire batch not being executed  Run time errors may allow part of the batch to commit Auto Commit Transactions ---run time error - partially executed USE AdventureWorks2012; GO CREATE TABLE TestBatch (Cola INT PRIMARY KEY, Colb CHAR(3)); GO INSERT INTO TestBatch VALUES (1, 'aaa'); INSERT INTO TestBatch VALUES (2, 'bbb'); INSERT INTO TestBatch VALUES (1, 'ccc'); -- Duplicate key error. GO SELECT * FROM TestBatch; -- Returns rows 1 and 2. GO
  • 20.  SQL Server is responsible for opening the transaction  We are responsible for committing or rolling it back  Can be turned on from Connections tab in Server Properties Implicit Transactions SET IMPLICIT_TRANSACTIONS ON USE AdventureWorks2012 GO UPDATE [Person].[Address] SET AddressLine1='SoftUni, Sofia' WHERE AddressID=2 COMMIT – this will write a change to the db SET IMPLICIT_TRANSACTIONS ON USE AdventureWorks2012 GO UPDATE [Person].[Address] SET AddressLine1='SoftUni, Sofia' WHERE AddressID=2 ROLLBACK – this will not write a change to the db
  • 21. Explicit Transactions  A transaction in which start and end of transaction is explicitly declared  BEGIN TRANSACTION  COMMIT TRANSACTION OR ROLLBACK TRANSACTION  XACT_ABORT ON/OFF – control the rollback behavior SET XACT_ABORT ON – if run time error is generated everything is rolled back USE AdventureWorks2012 GO BEGIN TRANSACTION FundsTransfer GO EXEC HumanResources.DebitAccount '100', 'account1'; EXEC HumanResources.CreditAccount '100', 'account2'; COMMIT TRANSACTION;
  • 23. Locks and SQL Server Concurrency
  • 24.  Pessimistic – SQL Server uses locks, causes blocks and who said deadlocks?  Optimistic – SQL Server generates versions for everyone, but the updates… Methods of Concurrency Control
  • 25. What Are Locks and what is locking?  Lock – internal memory structure that “tells” us what we all do with the resources inside the system  Locking – mechanism to protect the resources and guarantee consistent data
  • 26. Intent Used for: Preventing incompatible locks Duration: End of the transaction Shared (S) Used for: Reading Duration: Released almost immediately (depends on the isolation level) Update (U) Used for: Preparing to modify Duration: End of the transaction or until converted to exclusive (X) Exclusive (X) Used for: Modifying Duration: End of the transaction Common Lock Types
  • 27. Not all locks are compatible with other locks. Lock Compatibility Lock Shared Update Exclusive Shared (S)   X Update (U)  X X Exclusive (X) X X X
  • 29. Let’s update a row! What do we need? Header Row Row Row Row Row USE AdventureWorks2012 GO UPDATE [Person].[Address] SET AddressLine1='SoftUni, Sofia' WHERE AddressID=2 IX S IX X
  • 30. Methods to View Locking Information Dynamic Management Views SQL Server Profiler or Extended Events Performance monitor or Activity Monitor
  • 32. Locking and blocking are often confused! Locking  The action of taking and potentially holding locks  Used to implement concurrency control Blocking is result of locking!  One process needs to wait for another process to release locked resources  In a multiuser environment, there is always, always blocking!  Only a problem if it lasts too long Locking and blocking
  • 34. Controlling Lock escalation SELECT lock_escalation_desc FROM sys.tables WHERE name = 'Person.Address' ALTER TABLE Person.Address SET (LOCK_ESCALATION = {AUTO | TABLE | DISABLE}  Switch the escalation level (per table) AUTO – Partition-level escalation if the table is partitioned TABLE – Always table-level escalation DISABLE – Do not escalate until absolutely necessary  Just disable it (that’s not Nike’s “Just do it!”)  Trace flag 1211 – disables lock escalation on server level  Trace flag 1224 – disables lock escalation if 40% of the memory used is consumed
  • 35.  Who is victim?  Cost for Rollback  Deadlock priority – SET DEADLOCK_PRIORITY What Are Deadlocks? Task A Task B Resource 1 Resource 2
  • 36. Resolve blocking a.k.a lokcking  Keep the transactions as short as possible  No user interactions required in the middle of the transaction  Use indexes (proper ones)  Consider a server to offload some of the workloads  Choose proper isolation level
  • 37. Locks and SQL Server Concurrency Demo
  • 39. SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED (NOLOCK?) Read Uncommitted Transaction 1 Transaction 2 Suggestion: Better offload the reads or go with optimistic level concurrency! Select Update eXclusive lock Dirty read
  • 40. SET TRANSACTION ISOLATION LEVEL REPEATABLE READ Repeatable Read Transaction 1 S(hared) lock select No non-repeatable reads possible (updates during Transaction 1) Phantom records still possible (inserts during Transaction 1) Update Transaction 2
  • 41. Serializable Transaction 1 S(hared) lock select Even phantom records are not possible! Highest pessimistic level of isolation, lowest level of concurrency Insert Transaction 2 SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
  • 42. Optimistic Concurrency  Based on Row versioning (stored inside tempdb’s version store area)  No dirty, non-repeatable reads or phantom records  Every single modification is versioned even if not used  Adds 14 bytes per row  Readers do not block writers and writers do not block readers  Writers can and will block writers, this can cause conflicts!
  • 43. Read Committed and Snapshot Isolation levels V1 V2 Transaction 1 Transaction 2 Select in RCSISelect Select in SI  RCSI – Read Committed Snapshot Isolation Level  Statement level versioning  Requires ALTER DATABASE SET READ_COMMITTED_SNAPSHOT ON  Snapshot Isolation Level  Transaction level versioning  Requires ALTER DATABASE SET ALLOW_SNAPSHOT_ISOLATION ON  Requires SET TRANSACTION ISOLATION LEVEL SNAPSHOT
  • 44. Concurrency Phenomenon in Isolation Levels 44 Level of Isolation Dirty Reads Repeatable Reads Phantom Reads Read uncommitted yes yes yes Read committed no yes yes Repeatable read no no yes Serializable no no No Read Committed Snapshot no no yes Snapshot no no no
  • 46.  Transactions  The magical “ACID” word  Locks and SQL Server Concurrency  Troubleshooting locking problems  Transaction Isolation Levels Summary
  • 48. Resources MCM Readiness videos on locking lecture and demo MCM Readiness video on Snapshot Isolation Level http://blogs.msdn.com/b/bartd/archive/tags/sql+locking http://www.sqlskills.com/blogs/paul/category/locking/ Lock hints - http://www.techrepublic.com/article/control-sql- server-locking-with-hints/5181472
  • 49. License  This course (slides, examples, demos, videos, homework, etc.) is licensed under the "Creative Commons Attribution- NonCommercial-ShareAlike 4.0 International" license 49  Attribution: this work may contain portions from  "Databases" course by Telerik Academy under CC-BY-NC-SA license
  • 50. Free Trainings @ Software University  Software University Foundation – softuni.org  Software University – High-Quality Education, Profession and Job for Software Developers  softuni.bg  Software University @ Facebook  facebook.com/SoftwareUniversity  Software University @ YouTube  youtube.com/SoftwareUniversity  Software University Forums – forum.softuni.bg