ofbiz-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From YaoCL <chunlin...@gmail.com>
Subject Re: Should we use some lock when update qoh of InventoryItem
Date Wed, 06 Aug 2014 07:08:57 GMT
Did you mean storeByCondition method. With it I must check the updated row count, if equals
0 retry again. SELECT FOR UPDATE will block one transaction to wait until the end of another
transaction.

On Wed, Aug 06, 2014 at 14:44, Adrian Crum <adrian.crum@sandglass-software.com> Wrote:
> 
> The entity engine supports updates that include a WHERE clause - so it would be possible
to update only when the lastUpdatedStamp matches.
> 
> Adrian Crum
> Sandglass Software
> www.sandglass-software.com
> 
> On 8/6/2014 7:31 AM, Yaocl wrote:
>> I can only consider a solution use SELECT FOR UPDATE,  lock the
>> inventory item then SELECT ... sum(...) FROM inventory_item_detail
>> GROUP BY ...., then update the inventory item. But it seems
>> EntityEngine not support FOR UPDATE.
>> --
>> YaoCL
>> 
>> On Wed, Aug 6, 2014 at 1:41 PM, Adrian Crum
>> <adrian.crum@sandglass-software.com> wrote:
>>> This has been discussed on the dev mailing list, and there are differing
>>> opinions. I agree this is a bug and should be fixed, but others believe it
>>> is highly unlikely two people will be modifying the same invoice at the same
>>> time - so it is not a problem.
>>> 
>>> Adrian Crum
>>> Sandglass Software
>>> www.sandglass-software.com
>>> 
>>> 
>>> On 8/6/2014 3:01 AM, YaoCL wrote:
>>>> 
>>>> Hi,
>>>> 
>>>> When create a new InventoryItemDetail the InventoryItem will be updated by
>>>> eeca. But If two threads create InventoryItemDetails simultaneously. Because
>>>> we use ReadCommitted Isolation level, Neither will see InventoryItemDetails
>>>> created by other threads before transaction commit.
>>>> updateInventoryItemFromDetail service will get incorrect qoh, and
>>>> InventoryItem will be updated. Two threads will all be committed
>>>> successfully.
>>>> 
>>>> I can confirm the behavior by set a breakpoint in
>>>> org.ofbiz.minilang.method.entityops.StoreValue.exec(MethodContext) to
>>>> emulate above process. The result can be checked by this SQL.
>>>> 
>>>> select * from inventory_item t1 left join (
>>>> select inventory_item_id, sum(quantity_on_hand_diff) as qoh,
>>>> sum(available_to_promise_diff) as atp from inventory_item_detail
>>>> group by inventory_item_id) t2 on t1.inventory_item_id =
>>>> t2.inventory_item_id
>>>> where t1.quantity_on_hand_total <> t2.qoh;
>>>> 
>>>> —
>>>> YaoCL
>>>> 
>>> 



Mime
View raw message