Skip to content

Getting Cannot roll back trans2. No transaction or savepoint of that name was found on SQL server after #48637 #49514

Closed
@crissi

Description

@crissi

Laravel Version

From v10.29.0
Tested in v10.29.0 and v10.39.0, both fail

PHP Version

8.1.2

Database Driver & Version

Microsoft SQL Server 2022

Description

From Laravel/framework, v10.29.0 I am getting error Cannot roll back trans2. No transaction or savepoint of that name was found. when running code:

 DB::transaction(function () use ($partner, $globalLogin, &$apiToken) {
            $apiToken = ApiToken::firstOrCreate([
                'agreement_number' => $globalLogin->agreement_number,
                'api_user_id' => $partner->id
            ], [
                'token' => '111111'
            ]);
        });

Laravel/framework v10.28.0 works fine.

The error only happens if no row exist in the database for the query.

If I remove the transaction, my code generates no errors.

It is after the revival of this one:
#48637
Also failed last time this was in the code base

Steps To Reproduce

 DB::transaction(function () use ($partner, $globalLogin, &$apiToken) {
            $apiToken = ApiToken::firstOrCreate([
                'agreement_number' => $globalLogin->agreement_number,
                'api_user_id' => $partner->id
            ], [
                'token' => '111111'
            ]);
        });

Run code similar to this, with no rows that match.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions