Skip to content

race condition #82

@kak2z7702

Description

@kak2z7702

Hi) i error race condition))
i have this code

        $walletRefill = $user->getWalletRefill();
        $walletHold = $user->getWalletHold();

        try {
            $walletRefill->transfer(
                $walletHold,
                $type,
                [
                    'description' => 'Перевод средств для покупки очереди: ' . $type . '$'
                ]);

        } catch (Exception $e) {
            
            info(__CLASS__ . '(' . __LINE__ . ') ' . $e->getMessage());
            return redirect(route('queue.buy.index', [
                'user' => $user->id
            ]))->with('error', __($e->getMessage()));

        }

when many users run this code, then I see such an error

App\Http\Controllers\Front\Queue\BuyController(69) SQLSTATE[40001]: Serialization failure: 1213 Deadlock found when trying to get lock; try restarting transaction (SQL: update `wallets` set `balance` = 3820, `wallets`.`updated_at` = 2019-08-05 00:18:53 where `id` = 12)
--

Do you have any idea how to fix this?)))
tnx)

Metadata

Metadata

Assignees

Labels

enhancementNew feature or requestquestionFurther information is requested

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions