DWR

DWREngine.setOrdered does not work

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Blocker Blocker
  • Resolution: Fixed
  • Affects Version/s: 2.0.1
  • Fix Version/s: 2.0.3
  • Component/s: Engine
  • Description:
    Hide
    After upgrading from DWR 1.1 to DWR 2.0.1 i found that my existing code didn't work any more. I'm using DWREngine.setOrdered(true) in several places.

    Symtom is that first call to DWR works as expected but from the second action triggering DWR no requests will be send to the server any more. After taking out the DWREngine.setOrdered(true) call the app worked again.

    why it is a blocker for us:
     I need the setOrdered functionality though it is not recommended cause we integrate a server-side state-engine (in our case a XForms Processor) with DWR. Especially we must allow to maintain repeated datasets on the server and so the ordering of insert and delete calls on that set are crucial for correct operation. Imagine a user first doing an insert on a set of data and then delete this entry again - if the order is not preserved the delete on an item that does not yet exist would surely fail.
    Show
    After upgrading from DWR 1.1 to DWR 2.0.1 i found that my existing code didn't work any more. I'm using DWREngine.setOrdered(true) in several places. Symtom is that first call to DWR works as expected but from the second action triggering DWR no requests will be send to the server any more. After taking out the DWREngine.setOrdered(true) call the app worked again. why it is a blocker for us:  I need the setOrdered functionality though it is not recommended cause we integrate a server-side state-engine (in our case a XForms Processor) with DWR. Especially we must allow to maintain repeated datasets on the server and so the ordering of insert and delete calls on that set are crucial for correct operation. Imagine a user first doing an insert on a set of data and then delete this entry again - if the order is not preserved the delete on an item that does not yet exist would surely fail.

Activity

Hide
Marcus Smith added a comment - 26/Jun/07 2:32 PM

I have noticed the same symptoms while using setOrdered. It appears once setOrdered is set to true, calls are added to the _batchQueue within the _endBatch method. It appears that these are not then popped from the queue and executed, unless the _clearUp method is called, which happens whenever the call has finished, either by throwing an exception/warning or by stateChange. I'm guessing that as the call is queued and doesn't appear to execute it will just sit there indefiniately ...

Show
Marcus Smith added a comment - 26/Jun/07 2:32 PM I have noticed the same symptoms while using setOrdered. It appears once setOrdered is set to true, calls are added to the _batchQueue within the _endBatch method. It appears that these are not then popped from the queue and executed, unless the _clearUp method is called, which happens whenever the call has finished, either by throwing an exception/warning or by stateChange. I'm guessing that as the call is queued and doesn't appear to execute it will just sit there indefiniately ...
Hide
Marcus Smith added a comment - 28/Jun/07 4:19 PM

After further investigation today, the problem lies with the batch.map.batchId value which is set by taking the value of dwr.engine._nextBatchId within the _sendData method. The initial value of _nextBatchId = 0, so when we execute a call for the first time, the _batchesLength value is set to one. Once this call finishes and _clearUp is called the body of the if in the following code will not execute as the if statement will be false because batch.map.batchId==false;

// Will always be false for the first call as 0 == false
if(batch.map && batch.map.batchId)
{
delete dwr.engine._batches[batch.map.batchId];
dwr.engine._batchesLength--;
}

Which means that dwr.engine_batchesLength will never be zero. Subsequent calls where we have setOrdered to true will always add to the batchQueue and just sit there, because there is no longer a calll to return. I've modified engine.js to set the initial value of _nextBatchId = 1 as a quick fix as this was/is causing problems with our application. An alternative which might be nicer would be to change the if to;

if(batch.map && (batch.map.batchId || batch.map.batchId==0)) { .... }

Show
Marcus Smith added a comment - 28/Jun/07 4:19 PM After further investigation today, the problem lies with the batch.map.batchId value which is set by taking the value of dwr.engine._nextBatchId within the _sendData method. The initial value of _nextBatchId = 0, so when we execute a call for the first time, the _batchesLength value is set to one. Once this call finishes and _clearUp is called the body of the if in the following code will not execute as the if statement will be false because batch.map.batchId==false; // Will always be false for the first call as 0 == false if(batch.map && batch.map.batchId) { delete dwr.engine._batches[batch.map.batchId]; dwr.engine._batchesLength--; } Which means that dwr.engine_batchesLength will never be zero. Subsequent calls where we have setOrdered to true will always add to the batchQueue and just sit there, because there is no longer a calll to return. I've modified engine.js to set the initial value of _nextBatchId = 1 as a quick fix as this was/is causing problems with our application. An alternative which might be nicer would be to change the if to; if(batch.map && (batch.map.batchId || batch.map.batchId==0)) { .... }
Hide
Joe Walker added a comment - 08/Feb/08 12:53 PM

Fix should go into 2.0.3 and 3.0M1.
There should be an RC for 2.0.3 out soon, please test.
Thanks.

Show
Joe Walker added a comment - 08/Feb/08 12:53 PM Fix should go into 2.0.3 and 3.0M1. There should be an RC for 2.0.3 out soon, please test. Thanks.

People

Dates

  • Created:
    08/Jun/07 1:11 PM
    Updated:
    29/Feb/08 10:29 AM
    Resolved:
    08/Feb/08 12:53 PM