etrepat / baum

Baum is an implementation of the Nested Set pattern for Laravel's Eloquent ORM.
http://etrepat.com/baum
MIT License
2.24k stars 461 forks source link

Lock in share mode not yet supported - Oracle #202

Open ghost opened 8 years ago

ghost commented 8 years ago

Hi, I am using yajra/laravel-oci8 as db driver for oracle.

And I create Model Menu that extends Baum/Node. But when I execute this action:

Menu::create([
            'name'      => 'Dashboard',
            'active'    => true,
            'position'  => 0
        ]);

That code give me error:

[yajra\Pdo\Oci8\Exceptions\Oci8Exception]
  Lock in share mode not yet supported!

Can you give a solution for this. Thank you.

ChaosPower commented 8 years ago

@4kun9 https://docs.oracle.com/cd/E17952_01/refman-5.0-en/innodb-locking-reads.html

First Impressions: Looks like you have conflicting session transactions. The solution would probably be to figure out sequencing changes / commits. At Oracle SqlDeveloper, if someone is editing the same table and has committed earlier than you, it will popup an error (says something like "another session has committed").

I have encountered this issue in sqlalchemy (python). What I did is to make sure each connection and each commits are on different sessions. Each time it issues a commit, it closes the previous session and opens a new one when the process is done. Or we can just wait for the editing session to get done.

From the ref: "Here, LOCK IN SHARE MODE is not a good solution because if two users read the counter at the same time, at least one of them ends up in deadlock when it attempts to update the counter."

In your case, you probably are editing something and some / someone in another session has edited and committed.

Will try to implement this when I find time.

PS: The ref is for MySQL.

ChaosPower commented 8 years ago

I think we should change this title to relate "Oracle Deadlock"