April 23, 2011 at 2:46 am
Hi there,
Im confuse with transaction and Tables locking.
When a user perform a transaction on a table A,
can other user access table A?
If can then what is Two phase locking?
since i got the example:
Tran T Tran U
Begin;
read(a) Begin;
read(b) Wait..
Commit; read(a)
Commit;
why transaction U have to wait for transaction T?
April 23, 2011 at 1:57 pm
Duplicate post, double click...
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
April 23, 2011 at 1:58 pm
Hi,
You may want to slightly rephrase your question.
Listed below is an article that describes two phase locking:
http://www.ianywhere.com/developer/product_manuals/sqlanywhere/0901/en/html/dbugen9/00000159.htm
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
April 23, 2011 at 2:17 pm
pluck9909 (4/23/2011)
When a user perform a transaction on a table A,can other user access table A?
Depends what is done in the transaction and what locks are taken.
If can then what is Two phase locking?
I've heard of 2-phase commit, never of 2-phase locking before.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 23, 2011 at 2:48 pm
Thank you for your point.
As far as I know two Phase locking does not exist in SQL Server but it does exist in Oracle.
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
April 23, 2011 at 3:21 pm
Please remove post.
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
April 23, 2011 at 5:09 pm
Welsh Corgi (4/23/2011)
As far as I know two Phase locking does not exist in SQL Server but it does exist in Oracle.
2PL is actually just a conceptual description of the locking process that divides it into two phases:
1- locks are acquired and no locks are released.
2- locks are released and no locks are acquired.
Two Phase Commit refers - at least in the Oracle world - to distributed transactions where one datatabase is an Oracle one while the second one is a non-Oracle one.
_____________________________________
Pablo (Paul) Berzukov
Author of Understanding Database Administration available at Amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.April 25, 2011 at 6:36 am
I guess the other user can not able to access Table A until second commit get executed.
April 25, 2011 at 6:41 am
Ajay.Kedar (4/25/2011)
I guess the other user can not able to access Table A until second commit get executed.
Depends what is done in the transaction and what locks are taken.
It's not as simple as they can or they can't access the table.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 30, 2011 at 3:16 am
eh? sry maybe i missed out my points guys..
i just want to know:
if user A perform a transaction T, before the transaction T end.
can other user access the tables?
Transaction T maybe jus a simple transaction like:
Begin;
Update table Z
Commit;
will the transaction lock the table Z before commit?
April 30, 2011 at 4:28 am
As I said earlier
GilaMonster (4/25/2011)
Depends what is done in the transaction and what locks are taken.It's not as simple as they can or they can't access the table.
Locks from insert, update, delete are held until the end of the transaction, select as well if you're in repeatable read isolation or higher. Anything that's locked exclusively is unavailable until the end of the transaction.
Locks can be at row, page or table level, so it really does depend on what you're doing how much gets locked and with what mode (shared or exclusive) whether other sessions can access the objects or not.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
April 30, 2011 at 10:48 am
Excellent interpretation and explanation Gila Monster.
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
May 3, 2011 at 1:02 pm
We can read that data if we done with the below settings:
Set transaction isolation level read uncommitted
When this option is set, it is possible to read uncommitted or dirty data; values in the data can be changed and rows can appear or disappear in the data set before the end of the transaction.
May 3, 2011 at 1:35 pm
Are you sure you want dirty reads?
For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
May 3, 2011 at 1:45 pm
Am I wrong? I am newbie so I have just share what I know. If I am wrong than please correct me.
Viewing 15 posts - 1 through 15 (of 16 total)
You must be logged in to reply to this topic. Login to reply