Is everything all right if from one stored procedure I call another which sets lower transaction isolation level?

I have a bunch of utility procedures that check only some conditions in the database and return the flag result. These procedures are executed with a READ UNCOMMITTED isolation level equivalent to WITH WITH NOLOCK.

I also have more complex procedures that run with the SERIALIZABLE isolation level. They also have the same checks in them.

Therefore, I decided to call these verification procedures from these complex procedures instead of replicating the verification code.

It basically looks like this:

CREATE PROCEDURE [dbo].[CheckSomething]
AS
    SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED

    BEGIN TRANSACTION

    -- Do checks

    COMMIT TRANSACTION

and

CREATE PROCEDURE [dbo].[DoSomethingImportant]
AS
    SET TRANSACTION ISOLATION LEVEL SERIALIZABLE

    BEGIN TRANSACTION

    EXECUTE [dbo].[CheckSomething]

    -- Do some work

    COMMIT TRANSACTION

Would it be nice to do this? Will a temporarily activated lower isolation level somehow violate a higher level of protection or is everything safe?

EDIT: - .

+3
1

SQL Server 2005. :

, . , , . , READ SERIALIZABLE, , , .

SET TRANSACTION ISOLATION , reset , , . , , SERIALIZABLE, REPEATABLE READ .

:

  • proc
  • , DoSomethingImportant, SERIALIZABLE
  • , CheckSomething, READ UNCOMMITTED
+5

Source: https://habr.com/ru/post/1707097/


All Articles