# LockNotAvailable: could not obtain lock on row in relation "stock\_move"

**URL:** https://discuss.tryton.org/t/locknotavailable-could-not-obtain-lock-on-row-in-relation-stock-move/8995
**Category:** Developer
**Created:** [December 2, 2025, 8:58am UTC](https://discuss.tryton.org/t/locknotavailable-could-not-obtain-lock-on-row-in-relation-stock-move/8995 "2025-12-02T08:58:22Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Xavi](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/x/8e8cbc/32.png) [@Xavi](https://discuss.tryton.org/u/Xavi)
#### Post date: [December 2, 2025, 8:58am UTC](https://discuss.tryton.org/t/locknotavailable-could-not-obtain-lock-on-row-in-relation-stock-move/8995/1 "2025-12-02T08:58:22Z")

</div>

Hi,  
This error is becoming very common in our server:

```auto
 File "trytond/modules/stock/shipment.py", line 2994, in transition_start
    self.record.assign_try()
  File "trytond/modules/stock_lot/stock.py", line 476, in assign_try
    success = super().assign_try(moves, with_childs, grouping)
  File "trytond/modules/stock/move.py", line 986, in assign_try
    cls._assign_try_lock(
  File "trytond/modules/stock/move.py", line 1169, in _assign_try_lock
    cursor.execute(*query)
  File "trytond/backend/postgresql/database.py", line 68, in execute
    cursor.execute(self, sql, args)
LockNotAvailable: could not obtain lock on row in relation "stock_move"

```

Everytime it happens, I can see that there is a few users trying to assign moves at the same time frame, but I wonder if there is a way to manage this situations, not only to end users but also for administrators, as when It happens it is quite hard to identify what is going on in real time, and checking [pg\_locks](https://www.postgresql.org/docs/current/view-pg-locks.html) does not help at all (note that I don’t have a problem of a transaction locking a table for ever, the problem gets fixed itself in a moment as the lock ends, but it is still annoying).  
Could avoiding the `nowait=True` in `Move._assign_try_lock` be a good idea? i’d rather have users waiting for a while than constantly clicking a button which is not working.  
Thanks.

---

<div class="post-metadata">

### Author: ![pokoli](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/pokoli/32/22_2.png) [@pokoli](https://discuss.tryton.org/u/pokoli)
#### Post date: [December 2, 2025, 9:15am UTC](https://discuss.tryton.org/t/locknotavailable-could-not-obtain-lock-on-row-in-relation-stock-move/8995/2 "2025-12-02T09:15:56Z")

</div>

This is expected error which is normally solved automatically when the lock of the other user is released.

Having said that, I think it will be great if we can show to the user some more meaningfull message to let them now about the logs instead just raising the traceback which makes them think there is something wrong in the error.

---

<div class="post-metadata">

### Author: ![ced](https://discuss-cdn.tryton.org/user_avatar/discuss.tryton.org/ced/32/1237_2.png) [@ced](https://discuss.tryton.org/u/ced)
#### Post date: [December 2, 2025, 9:39am UTC](https://discuss.tryton.org/t/locknotavailable-could-not-obtain-lock-on-row-in-relation-stock-move/8995/3 "2025-12-02T09:39:25Z")

</div>

`LockNotAvailable` is a `OperationalError` error so it is retried [according to the configuration](https://docs.tryton.org/latest/server/topics/configuration.html#retry).  
On busy system, you may want to increase it.  
Also the assignation process may be slow because there are too many stock moves. In this case you should consider [using stock period](https://docs.tryton.org/latest/modules-stock/usage/index.html#using-stock-periods).

> [@Xavi](#):
>
> Could avoiding the `nowait=True` in `Move._assign_try_lock` be a good idea?

No because any way the transaction must be restarted and there is still no guarantee to have the lock and also it will consume a database connection just to wait. It is better to wait without consuming a connection as PostgreSQL has a limited number of available connection.

---

<div class="post-metadata">

### Author: ![Xavi](https://discuss-cdn.tryton.org/letter_avatar_proxy/v4/letter/x/8e8cbc/32.png) [@Xavi](https://discuss.tryton.org/u/Xavi)
#### Post date: [December 2, 2025, 9:45am UTC](https://discuss.tryton.org/t/locknotavailable-could-not-obtain-lock-on-row-in-relation-stock-move/8995/4 "2025-12-02T09:45:36Z")

</div>

> [@ced](#):
>
> it is retried [according to the configuration](https://docs.tryton.org/latest/server/topics/configuration.html#retry)

> [@ced](#):
>
> you should consider [using stock period](https://docs.tryton.org/latest/modules-stock/usage/index.html#using-stock-periods).

I will take a look at this, thanks.

---

<div class="post-metadata">

### Author: ![system](https://discuss-cdn.tryton.org/uploads/default/original/1X/c6f8ec0a40525cdcd50058c734283450a4b3d38b.png) [@system](https://discuss.tryton.org/u/system)
#### Post date: [December 3, 2025, 9:45am UTC](https://discuss.tryton.org/t/locknotavailable-could-not-obtain-lock-on-row-in-relation-stock-move/8995/5 "2025-12-03T09:45:37Z")

</div>

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.
