databaseManager.refreshRecordFromDatabase() changes foundset

Hi,

Very strange situation. The databaseManager.refreshRecordFromDatabase() is changing my foundset

application.output('Before refresh ' + forms[_form].webshop_id + ' Selected=' + forms[_form].controller.getSelectedIndex() + ' Size=' + forms[_form].controller.getMaxRecordIndex())
databaseManager.refreshRecordFromDatabase(forms[_form].foundset, forms[_form].controller.getSelectedIndex())
application.output('After refresh ' + forms[_form].webshop_id + ' Selected=' + forms[_form].controller.getSelectedIndex()+ ' Size=' + forms[_form].controller.getMaxRecordIndex())

And the result:

Before refresh 130346a7-e9ee-4f5c-b841-19b027102b89 Selected=1 Size=10
After refresh 5ebe0f5e-083f-48d9-835e-9216edf20e89 Selected=1 Size=9

It doesn’t happen on every foundset. But on the foundset in the example it happens always.

Any explanation for this behavior?

Martin

By the way,

Also databaseManager.refreshRecordFromDatabase(forms[_form].foundset, 0) gives the same problem

Hi Martin,

this sounds simular to a bug I discovered some time ago in 4.x (it’s solved some time ago…already :D )

When selecting records by query in a multi-tenant solution, we forgot to specify the tenant_id in the where clause.
This caused the dataset to contain more records than servoy would show taking the table filters into account.

When loading this faulty dataset onto the form, the form showed te correct number of records, but foundset.getSize() returned the number that was found based on the dataset.
After an application.updateUI(); the foundset was refreshed and the nr. of records on the form were in sync with the number returned by foundset.getSize() again…

Any link here?

Hi Marc,

I don’t think I have the same problem. In this situation I don’t use datasets.
And also on other forms I noticed strange situations where my foundset is reduced, on the same table.

Can it be some corruption in the repository that can cause this?

Servoy guys can you see an explanation in the Servoy source for what reason a foundset changes on databaseManager.refreshRecordFromDatabase()
Maybe you can see if it is repository related

Martin

It looks like this is really a bug. The databaseManager.acquireLock() shows also this behavior:

	application.output('BEFORE LOCK')
	application.output('GetSelectedIndex()=' + _foundset.getSelectedIndex())
	application.output('Foundset=' + _foundset)	
	application.output('PK=' + _foundset.webshop_id)		
	application.output('Lock index=' + _recordnumber)
	
	var _success = databaseManager.acquireLock(_foundset, _recordnumber)

	application.output('AFTER LOCK')
	application.output('Lock result=' + _success)	
	application.output('GetSelectedIndex()=' + _foundset.getSelectedIndex())
	application.output('Foundset=' + _foundset)	
	application.output('PK=' + _foundset.webshop_id)

And this is the result:

BEFORE LOCK
GetSelectedIndex()=4
Foundset=36.130346a7-e9ee-4f5c-b841-19b027102b89;
36.5ebe0f5e-083f-48d9-835e-9216edf20e89;
36.95ad0cf4-6bcc-4784-9b2f-a6f1b3d9438c;
36.967157f0-85ee-44a9-8088-32126491619b;
36.b53c66db-7f52-4337-93f3-1934de05c538;
36.d1855f99-91df-4dbd-8ecc-f00e6f48c286;
36.db3ca094-fd33-4be4-95eb-3c19fcc37361;
36.f0706693-3ea0-40bd-b32d-e195d70ec24d;
36.f4143c66-315a-4d7a-8434-82719f76e9f7;
36.f7fb71a2-b8fb-4b97-9a17-087042dd642b;

PK=967157f0-85ee-44a9-8088-32126491619b
Lock index=4
AFTER LOCK
Lock result=true
GetSelectedIndex()=4
Foundset=36.130346a7-e9ee-4f5c-b841-19b027102b89;
36.5ebe0f5e-083f-48d9-835e-9216edf20e89;
36.95ad0cf4-6bcc-4784-9b2f-a6f1b3d9438c;
36.b53c66db-7f52-4337-93f3-1934de05c538;
36.d1855f99-91df-4dbd-8ecc-f00e6f48c286;
36.db3ca094-fd33-4be4-95eb-3c19fcc37361;
36.f0706693-3ea0-40bd-b32d-e195d70ec24d;
36.f4143c66-315a-4d7a-8434-82719f76e9f7;
36.f7fb71a2-b8fb-4b97-9a17-087042dd642b;

PK=b53c66db-7f52-4337-93f3-1934de05c538

As you can see the foundset is reduced from 10 to 9 records and it is my selected record which is gone.

There are no locks at the moment when output was printed.
And autoSave() is OFF

The lock was indeed placed. I can see it in the adminpages, but that is not a reason to remove it from the foundset :cry:

Martin

is it a related foundset that you target that?

maybe somehow the refresh of the record that happens on lock gets some new data that are the dataproviders of the relation keys so they fall out of the relation.

No there can not be a change in the foundset.
The example contains static data which is only changed when adding a new record (adding a new webshop in my case)
So the data on disk must still be the same as in the foundset.

I realized also that in the past I talked with you about performance issue on locking records.
You explained to me that this issue is caused because a refresh is done.

So that probably explains why I see the same problem on acquireLock() and that confirms that the problem is really in the refreshRecordsFromDatabase()

Hi Martin,

I suggest that you upload a small solution that reproduces this issue,
so others can have a look at it.

Regards,

Hans

you didnt answer the question
is it a related foundset?
what if you do this (for testing)

foundset = foundset.unrelate()
and then do your lock stuff

I’ll try to do this.

But … Just of of my customers was calling and he noticed a problem that is exactly the same. So it looks like a general problem since I upgraded to 4.1.3
He had to change an account of a person and when editing this person, the application shows suddenly another person and if the user didn’t pay attention the wrong account was changed

I’ll have to disable all refreshRecordsFromDatabase and aquireLock() calls :-(

jcompagner:
foundset = foundset.unrelate()
and then do your lock stuff

This doesn’t change anything. Still same problem.

Hans Nieuwenhuis:
Hi Martin,

I suggest that you upload a small solution that reproduces this issue,
so others can have a look at it.

Regards,

Hans

I wish I could, but when I make a small solution, the problem doesn’t appear,
So it must be a combination of reasons.

Since in my framework there are foundsets which are duplicated, I think that is a factor as well

But my foundset is never reduced because of filters or something like that.
I have tablefilters placed on load of my application, but in my sample application I did the same and that didn’t cause the problem

why do you have to do refreshRecordsFromDatabase that often by the way?

also is by any change that record really deleted from the database then?
Because then if we see that we fire a delete and then the foundset will remove it.

Only related foudsets can remove records a normal unrelated foundset doesnt remove rows from its set, except if a isdelete event is coming true.

The reason that I do a refresh is because the databroadcasting is not working (don’t ask me why, but it doesn’t)
So when a user wants to edit a record, he presses the Edit button and I do a refresh so that he sees always the latest record.
I also do a acquireLock() when a users presses ‘Edit’ so that no other user can edit this record.
You told me that the current acquireLock() is also doing a refresh for the same reason.

There is no delete in my case. Only edit.
And when I quit my application and restart it again, the record is still there.

I just noticed when showing the form (and not pressing ‘Edit’ button yet) I see the following message in the log of my localhost:
I don’t see why this happens , but do you see a relation with it?

2009-07-03 11:58 	AWT-EventQueue-0 	ERROR 	com.servoy.j2db.util.Debug 	Throwable
java.lang.IllegalArgumentException: Illegal pattern character 'Y'
     at java.text.SimpleDateFormat.compile(Unknown Source)
     at java.text.SimpleDateFormat.initialize(Unknown Source)
     at java.text.SimpleDateFormat.<init>(Unknown Source)
     at com.servoy.j2db.util.StateFullSimpleDateFormat.<init>(StateFullSimpleDateFormat.java:9)
     at com.servoy.j2db.util.StateFullSimpleDateFormat.<init>(StateFullSimpleDateFormat.java:3)
     at com.servoy.j2db.dataui.DataField.setFormat(DataField.java:86)
     at com.servoy.j2db.dataui.ComponentFactory.createField(ComponentFactory.java:70)
     at com.servoy.j2db.dataui.ComponentFactory.createComponentEx(ComponentFactory.java:869)
     at com.servoy.j2db.dataui.ComponentFactory.createComponent(ComponentFactory.java:681)
     at com.servoy.j2db.TableView.<init>(TableView.java:98)
     at com.servoy.j2db.SwingForm.initView(SwingForm.java:239)
     at com.servoy.j2db.FormController.setView(FormController.java:1062)
     at com.servoy.j2db.scripting.CreationalPrototype.get(CreationalPrototype.java:84)
     at org.mozilla.javascript.ScriptableObject.getProperty(ScriptableObject.java:1641)
     at org.mozilla.javascript.ScriptRuntime.getObjectElem(ScriptRuntime.java:1400)
     at org.mozilla.javascript.ScriptRuntime.getObjectElem(ScriptRuntime.java:1379)
     at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3379)
     at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2680)
     at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:166)
     at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:387)
     at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3125)
     at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:165)
     at com.servoy.j2db.scripting.ScriptEngine.executeFunction(ScriptEngine.java:37)
     at com.servoy.j2db.scripting.RemoteDebugScriptEngine.executeFunction(RemoteDebugScriptEngine.java:18)
     at com.servoy.j2db.scripting.ScriptEngine.executeFunction(ScriptEngine.java:64)
     at com.servoy.j2db.FormController.Za(FormController.java:68)
     at com.servoy.j2db.FormController.executeFunction(FormController.java:309)
     at com.servoy.j2db.FormController.actionPerformed(FormController.java:688)
     at com.servoy.j2db.Zhb.actionPerformed(Zhb.java:7)
     at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
     at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
     at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
     at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
     at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
     at java.awt.Component.processMouseEvent(Unknown Source)
     at javax.swing.JComponent.processMouseEvent(Unknown Source)
     at java.awt.Component.processEvent(Unknown Source)
     at java.awt.Container.processEvent(Unknown Source)
     at java.awt.Component.dispatchEventImpl(Unknown Source)
     at java.awt.Container.dispatchEventImpl(Unknown Source)
     at java.awt.Component.dispatchEvent(Unknown Source)
     at javax.swing.plaf.basic.BasicTableUI$Handler.repostEvent(Unknown Source)
     at javax.swing.plaf.basic.BasicTableUI$Handler.mouseReleased(Unknown Source)
     at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
     at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
     at java.awt.Component.processMouseEvent(Unknown Source)
     at javax.swing.JComponent.processMouseEvent(Unknown Source)
     at java.awt.Component.processEvent(Unknown Source)
     at java.awt.Container.processEvent(Unknown Source)
     at java.awt.Component.dispatchEventImpl(Unknown Source)
     at java.awt.Container.dispatchEventImpl(Unknown Source)
     at java.awt.Component.dispatchEvent(Unknown Source)
     at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
     at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
     at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
     at java.awt.Container.dispatchEventImpl(Unknown Source)
     at java.awt.Window.dispatchEventImpl(Unknown Source)
     at java.awt.Component.dispatchEvent(Unknown Source)
     at java.awt.EventQueue.dispatchEvent(Unknown Source)
     at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
     at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
     at java.awt.EventDispatchThread.run(Unknown Source)
2009-07-03 11:58 	AWT-EventQueue-0 	ERROR 	com.servoy.j2db.util.Debug 	Throwable
java.lang.IllegalArgumentException: Illegal pattern character 'Y'
     at java.text.SimpleDateFormat.compile(Unknown Source)
     at java.text.SimpleDateFormat.initialize(Unknown Source)
     at java.text.SimpleDateFormat.<init>(Unknown Source)
     at com.servoy.j2db.util.StateFullSimpleDateFormat.<init>(StateFullSimpleDateFormat.java:9)
     at com.servoy.j2db.util.StateFullSimpleDateFormat.<init>(StateFullSimpleDateFormat.java:3)
     at com.servoy.j2db.dataui.DataField.setFormat(DataField.java:86)
     at com.servoy.j2db.dataui.ComponentFactory.createField(ComponentFactory.java:70)
     at com.servoy.j2db.dataui.ComponentFactory.createComponentEx(ComponentFactory.java:869)
     at com.servoy.j2db.dataui.ComponentFactory.createComponent(ComponentFactory.java:681)
     at com.servoy.j2db.TableView.<init>(TableView.java:278)
     at com.servoy.j2db.SwingForm.initView(SwingForm.java:239)
     at com.servoy.j2db.FormController.setView(FormController.java:1062)
     at com.servoy.j2db.scripting.CreationalPrototype.get(CreationalPrototype.java:84)
     at org.mozilla.javascript.ScriptableObject.getProperty(ScriptableObject.java:1641)
     at org.mozilla.javascript.ScriptRuntime.getObjectElem(ScriptRuntime.java:1400)
     at org.mozilla.javascript.ScriptRuntime.getObjectElem(ScriptRuntime.java:1379)
     at org.mozilla.javascript.Interpreter.interpretLoop(Interpreter.java:3379)
     at org.mozilla.javascript.Interpreter.interpret(Interpreter.java:2680)
     at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:166)
     at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:387)
     at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3125)
     at org.mozilla.javascript.InterpretedFunction.call(InterpretedFunction.java:165)
     at com.servoy.j2db.scripting.ScriptEngine.executeFunction(ScriptEngine.java:37)
     at com.servoy.j2db.scripting.RemoteDebugScriptEngine.executeFunction(RemoteDebugScriptEngine.java:18)
     at com.servoy.j2db.scripting.ScriptEngine.executeFunction(ScriptEngine.java:64)
     at com.servoy.j2db.FormController.Za(FormController.java:68)
     at com.servoy.j2db.FormController.executeFunction(FormController.java:309)
     at com.servoy.j2db.FormController.actionPerformed(FormController.java:688)
     at com.servoy.j2db.Zhb.actionPerformed(Zhb.java:7)
     at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
     at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
     at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
     at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
     at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
     at java.awt.Component.processMouseEvent(Unknown Source)
     at javax.swing.JComponent.processMouseEvent(Unknown Source)
     at java.awt.Component.processEvent(Unknown Source)
     at java.awt.Container.processEvent(Unknown Source)
     at java.awt.Component.dispatchEventImpl(Unknown Source)
     at java.awt.Container.dispatchEventImpl(Unknown Source)
     at java.awt.Component.dispatchEvent(Unknown Source)
     at javax.swing.plaf.basic.BasicTableUI$Handler.repostEvent(Unknown Source)
     at javax.swing.plaf.basic.BasicTableUI$Handler.mouseReleased(Unknown Source)
     at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
     at java.awt.AWTEventMulticaster.mouseReleased(Unknown Source)
     at java.awt.Component.processMouseEvent(Unknown Source)
     at javax.swing.JComponent.processMouseEvent(Unknown Source)
     at java.awt.Component.processEvent(Unknown Source)
     at java.awt.Container.processEvent(Unknown Source)
     at java.awt.Component.dispatchEventImpl(Unknown Source)
     at java.awt.Container.dispatchEventImpl(Unknown Source)
     at java.awt.Component.dispatchEvent(Unknown Source)
     at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
     at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
     at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
     at java.awt.Container.dispatchEventImpl(Unknown Source)
     at java.awt.Window.dispatchEventImpl(Unknown Source)
     at java.awt.Component.dispatchEvent(Unknown Source)
     at java.awt.EventQueue.dispatchEvent(Unknown Source)
     at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
     at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
     at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
     at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
     at java.awt.EventDispatchThread.run(Unknown Source)

martinh:
Illegal pattern character ‘Y’

looks like your trying to format an element with an illegal character in the format property…

That is indeed what it looks like, but so far no indication about that

in the tableview that is created at that time, there is a DateField that has i think a format with only a Y or something (i think those must always be 2 YY or 4 YYYY)

The format can come from the designer or from the column properties of the column itself.

Dont think this is really related.
Also that databroadcast are not working is also very strange. Are you sure all the clients connect to the same servoy server?
Doenst it work at all? or only sometimes?

From my experience I can say that such a date (or number) format exception really does “hurt” a solution up to a point where it is not usable anymore. I have seen very strange things happen, noticed and fixed that problem and all was fine. It does not seem related at all, but again, I have seen very strange things happen after such an error.

The only datefield on the form didn’t have any format. I changed it to a format, and no error anymore. Maybe some problem 3.5 → 4.1 upgrade

But it didn’t fix my refresh problem