'Unexpected state:' calculation error

Discuss all problems you have with Servoy here. It might help to mention the Servoy version and Operating System version you are using

'Unexpected state:' calculation error

Postby Peter de Groot » Fri Apr 29, 2011 8:29 am

After updating from 5.2.6 to 5.2.7 last week we are seeing the following error in the server log,

Unexpected state: calculation depends on field 'qty_qc' from record without pk: Record[DATA:null] COLUMS: exp_po_add2_id,po_line,po_num,po_cnn,certificate_complete,qty_qc,is_release_item,um_qc,qty_difference,rollbackChanges,save,getPKs,setFoundset,deleteRecord,getChangedData,setException,getFoundset,getException,isEditing,
java.lang.IllegalStateException

and calculations are not updated on the form, this happens after adding a record to the table below, when I look in the table the primary key is not empty. The database we use is ms-sql 2008 and the sequence type is db identity.

calc.png
result after error
calc.png (7.7 KiB) Viewed 2649 times


when the smartclient is restarted the calculations are executed correctly. This only happens with version 5.2.7, developer and smartclient.
Servoy 7.3.x || 7.4.x

NEM ENERGY BV
Peter de Groot
 
Posts: 207
Joined: Thu Jan 10, 2008 8:38 pm
Location: Has been compromised :-/

Re: 'Unexpected state:' calculation error

Postby Peter de Groot » Fri Apr 29, 2011 8:44 am

Another one,

No DbIdent for this row: Row(db:/servoy/tp_file_entity)[DATA:tp_file_entity_id=DbIdentValue29465650,entity_type=29,entity_id=432,file_id=3898,enclose=null, CALCULATIONS: {[email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], toggle_image=media:///icon_pdf.gif}]

table.png
table.png (11.88 KiB) Viewed 2645 times


After adding a row to a small table....
Servoy 7.3.x || 7.4.x

NEM ENERGY BV
Peter de Groot
 
Posts: 207
Joined: Thu Jan 10, 2008 8:38 pm
Location: Has been compromised :-/

Re: 'Unexpected state:' calculation error

Postby jcompagner » Fri Apr 29, 2011 11:31 am

dont you have a full stacktrace for this in the log?
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 7974
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: 'Unexpected state:' calculation error

Postby Peter de Groot » Fri Apr 29, 2011 1:46 pm

I discovered that the problem does not occur with version 5.2.7 i1 also version prior to 5.2.7 do not have this problem.
Servoy 7.3.x || 7.4.x

NEM ENERGY BV
Peter de Groot
 
Posts: 207
Joined: Thu Jan 10, 2008 8:38 pm
Location: Has been compromised :-/

Re: 'Unexpected state:' calculation error

Postby msedita » Fri Jun 10, 2011 1:29 pm

Has this been resolved? I seem to be getting the same error using 5.2.7 with Sybase. It is intermittent, and I'm seeing it on the server, not developer. The table has dbident PK. All the keys seem be OK.

Here's the error:
Code: Select all
ERROR - Debug                      - Unexpected state: calculation depends on field 'shortlist_memo' from record without pk: Record[DATA:null]  COLUMS: c6pkey,user_uid,table_name,table_counter,pkey_value,shortlist_memo,rollbackChanges,save,getPKs,setFoundset,deleteRecord,getChangedData,setException,getFoundset,getException,isEditing,
java.lang.IllegalStateException
   at com.servoy.j2db.scripting.UsedDataProviderTracker.usedFromRecord(UsedDataProviderTracker.java:170)
   at com.servoy.j2db.scripting.UsedDataProviderTracker.usedName(UsedDataProviderTracker.java:89)
   at com.servoy.j2db.scripting.RecordingScriptable.get(RecordingScriptable.java:123)
   at org.mozilla.javascript.ScriptableObject.getProperty(ScriptableObject.java:1641)
   at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1429)
   at org.mozilla.javascript.ScriptRuntime.getObjectProp(ScriptRuntime.java:1418)
   at org.mozilla.javascript.gen.c221._c0(c6shortmemo:14)
   at org.mozilla.javascript.gen.c221.call(c6shortmemo)
   at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:387)
   at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3135)
   at org.mozilla.javascript.gen.c221.call(c6shortmemo)
   at com.servoy.j2db.scripting.ScriptEngine.executeFunction(ScriptEngine.java:476)
   at com.servoy.j2db.scripting.TableScope.getCalculationValue(TableScope.java:191)
   at com.servoy.j2db.scripting.TableScope.getCalculationValue(TableScope.java:214)
   at com.servoy.j2db.dataprocessing.FoundSet.getCalculationValue(FoundSet.java:2567)
   at com.servoy.j2db.dataprocessing.Record.getValue(Record.java:181)
   at com.servoy.j2db.smart.dataui.CellAdapter$5.run(CellAdapter.java:758)
   at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
   at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
   at java.lang.Thread.run(Unknown Source)



Here's the code:
Code: Select all
function c6shortmemo()
{
   var lofsrecent = databaseManager.getFoundSet(globals.gcservername,'c6userrecent');
   lofsrecent.addFoundSetFilterParam('user_uid','=',globals.gcuser_uid);
   lofsrecent.addFoundSetFilterParam('table_name','=','C6CLIENT');
   lofsrecent.addFoundSetFilterParam('pkey_value','=',c6pkey,'pkey_filter');
   lofsrecent.loadAllRecords()
   var lorecentrec = lofsrecent.getSelectedRecord()
   if (lorecentrec)
   {   
      return lorecentrec.shortlist_memo
   }
   else
   {   
      return null
   }
}
Michael Sedita
MS Health Software Corp.
Developers of software solutions for behavioral healthcare and social service providers.
www.mshealth.com
User avatar
msedita
 
Posts: 224
Joined: Thu Dec 13, 2007 8:01 pm

Re: 'Unexpected state:' calculation error

Postby rgansevles » Fri Jun 10, 2011 3:55 pm

Michael,

Can you reproduce this consistently?

Rob
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1838
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

Re: 'Unexpected state:' calculation error

Postby msedita » Fri Jun 10, 2011 4:17 pm

Unfortunatley no - it is intermittent. Using the same records, sometimes it happens, and sometimes not. I can find no pattern. BTW - there is nothing in the server log regarding it.

M.S.
Michael Sedita
MS Health Software Corp.
Developers of software solutions for behavioral healthcare and social service providers.
www.mshealth.com
User avatar
msedita
 
Posts: 224
Joined: Thu Dec 13, 2007 8:01 pm

Re: 'Unexpected state:' calculation error

Postby rgansevles » Fri Jun 10, 2011 4:36 pm

Michael,

This exception is just logging an unexpected situation, it is not bailing out some code.
I made a change for 5.2.9 that will probably get rid of it.

Rob
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1838
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

Re: 'Unexpected state:' calculation error

Postby msedita » Fri Jun 10, 2011 5:08 pm

Problem is the calculation doesn't return a value. In this case, the calc field is the data provider for a tableview field. After the calc is run, it should refresh the display. Sometimes it does and sometimes it does not.
Michael Sedita
MS Health Software Corp.
Developers of software solutions for behavioral healthcare and social service providers.
www.mshealth.com
User avatar
msedita
 
Posts: 224
Joined: Thu Dec 13, 2007 8:01 pm

Re: 'Unexpected state:' calculation error

Postby rgansevles » Mon Jun 20, 2011 12:24 pm

Michael,

This could be caused by a race condition in the calculation.
Servoy always first gets the pks from the db and when the data is requested, a new query is done.

Could it be that the record is being deleted when the calc is running?
The first pk load query may still see the record in the db, but the load-data query does not see the record anymore.
In that case this issue could occur.

Can you add a debug statement to your calculation so we can conform this?

Code: Select all
function c6shortmemo()
{
   var lofsrecent = databaseManager.getFoundSet(globals.gcservername,'c6userrecent');
   lofsrecent.addFoundSetFilterParam('user_uid','=',globals.gcuser_uid);
   lofsrecent.addFoundSetFilterParam('table_name','=','C6CLIENT');
   lofsrecent.addFoundSetFilterParam('pkey_value','=',c6pkey,'pkey_filter');
   lofsrecent.loadAllRecords()
   var sizeBefore = lofsrecent.getSize() // DEBUG
   var lorecentrec = lofsrecent.getSelectedRecord()
   if (lorecentrec)
   {
      var sizeAfter = lofsrecent.getSize() // DEBUG
      if (sizeBefore != sizeAfter) // DEBUG
     { // DEBUG
          application.output("DEBUG: foudset size changed from "+sizeBefore+" to "+sizeAfter+" rec="+lorecentrec+" fs="+lofsrecent); // DEBUG
     } // DEBUG
      return lorecentrec.shortlist_memo
   }
   else
   {   
      return null
   }
}


Rob

PS, this is rather an expensive calculation.
A relation with variable arguments could be a better solution, a feature request for that in a future version may help.

Rob
Rob Gansevles
Servoy
User avatar
rgansevles
 
Posts: 1838
Joined: Wed Nov 15, 2006 6:17 pm
Location: Amersfoort, NL

Re: 'Unexpected state:' calculation error

Postby msedita » Sat Jun 25, 2011 7:17 pm

I added the debug code, but nothing appears in the server log when the error occurs in the java console.
Michael Sedita
MS Health Software Corp.
Developers of software solutions for behavioral healthcare and social service providers.
www.mshealth.com
User avatar
msedita
 
Posts: 224
Joined: Thu Dec 13, 2007 8:01 pm

Re: 'Unexpected state:' calculation error

Postby jcompagner » Mon Jun 27, 2011 10:35 am

you could try:

application.output('my very important msg',LOGGINGLEVEL.ERROR);

so that it really is reported as an error, but if still nothing is reported then it isn't want we think happens maybe an extra line in there that test the variable shortlist_memo for null or something could be done.
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 7974
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet

Re: 'Unexpected state:' calculation error

Postby lwjwillemsen » Wed Dec 17, 2014 10:43 am

We are getting these in 5.2.17 :

ERROR - Debug - Unexpected state: calculation 'glb_output_detail_to_crm_department_output' depends on column 'glb_output_detail_to_crm_department_output' from record without pk: FindRecord[COLUMS: {owner_id,log_creation_user,log_creation_dt,log_modification_user,log_modification_dt,quantity,unit_price,unit_price_incl_vat,price,price_incl_vat,description,fin_vat_code_id,glb_output_detail_id,crm_department_output_id,output_detail_type,sequence_number,excluded_from_total_amount,percentage,percentage_base,currency_unit_price,currency_price,currency_unit_price_incl_vat,currency_price_incl_vat,sequence_number_detail_type,glb_unit_id,origin_type,origin_id,due_date,start_date,cost_unit_price,percentage_currency_base,total_quantity,} DATA:{origin_id=13052}, RELATED: {glb_output_detail_to_crm_department_output=FoundSet[Table:crm_department_output,Size: 1,Relation: glb_output_detail_to_crm_department_output,CachedRecords: 1,SELECTED INDEX: 0]}]

What to do ?

Regards,
Lambert Willemsen
Vision Development BV
lwjwillemsen
 
Posts: 566
Joined: Sat Mar 14, 2009 5:39 pm
Location: The Netherlands

Re: 'Unexpected state:' calculation error

Postby jcompagner » Wed Dec 17, 2014 11:35 am

that somehow a calculation that is triggered when you are in find mode.
So the calculation wants to generate a value but it can't because where it wants to get data from is a findstate
This shouldn't be really a problem, not sure how this can really happen. Is there somewhere a parent record that is not in find mode that has a calculation and that one has a relation (related foundset) that is somehow in find mode?
and that calculation uses that relation to show something?
Johan Compagner
Servoy
User avatar
jcompagner
 
Posts: 7974
Joined: Tue May 27, 2003 7:26 pm
Location: The Internet


Return to Discuss possible Issues and Bugs

Who is online

Users browsing this forum: Bing [Bot] and 2 guests