• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1821
  • Last Modified:

Sybase ASE Isolation levels and Locking


ASE 12.5.4 Linux 64 Bit

I am confused about the behaviour of the following:

If my T-SQL session's transaction Isolation level is 1 - Read Committed and I start a transaction and update a table. I should be able to Select data from the same table with out being blocked.

However my select statement waits until I commit or rollback,
sp_lock show Ex_Page and Ex_intent Locks on the datatable (select * from sysobjects)

It seems to be operating at Isolation Level 3 regardless.
2 Solutions
Jan FranekCommented:
Isolation level 1 doesn't mean, that you will ignore exclusive locks. It only guarantees, that you will not see uncommited data.

If you don't want to be blocked by exclusive locks of other processes, you may try to use READPAST (see http://manuals.sybase.com/onlinebooks/group-as/asg1250e/sqlug/@Generic__BookTextView/55452). However, this way you may not see complete data (as locked pages or rows will be skipped).

Joe WoodhousePrincipal ConsultantCommented:
Building on Jan's answer, the behaviour you describe is correct and expected. By setting your isolation level to 1, you are saying you only want to see data that is committed. Making you wait for a commit or rollback before you see data updated in a transaction is providing you with exactly what you asked for - you are only ever getting results returned from committed data, exactly as isolation level 1 requires.

Since you mentioned isolation level 3, I'll explain that a bit more: isolation level 3 says all read locks should be held for the duration of the transaction they are in, which guarantees no other processes can write to those pages, which in turn guarantees each time you re-read those pages (in the same transaction) you will always see the same results. That's a repeatable read, which is what isolation level 3 is all about. Your scenario is actually unrelated - with repeatable reads, reads block writes, whereas your situation is a writer blocking a read, which they do in every isolation level except 0.
kyleitvssAuthor Commented:
Thank you both for you quick response

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now