Exception in saveChanges(): rowDiffsForAttributes - snapshot does not contain value
Exception in saveChanges(): rowDiffsForAttributes - snapshot does not contain value
- Subject: Exception in saveChanges(): rowDiffsForAttributes - snapshot does not contain value
- From: Chuck Hill <email@hidden>
- Date: Wed, 21 Feb 2007 15:04:02 -0800
Hi,
Some of you will recognize this extremely fun exception:
java.lang.IllegalStateException: rowDiffsForAttributes: snapshot in
com.webobjects.eoaccess.EODatabaseOperation {
_dbSnapshot = {};
...
this = "<com.foo.bar.DownloadLog a849b0 _EOIntegralKeyGlobalID
[DownloadLog (java.lang.Long)0]>"; }";
_globalID = _EOIntegralKeyGlobalID[DownloadLog (java.lang.Long)0];
_databaseOperator = "EODatabaseUpdateOperator"; }
does not contain value for attribute named downloadDate with snapshot
key: downloadDate
The stack trace is:
at com.webobjects.eoaccess.EODatabaseOperation.rowDiffsForAttributes
(EODatabaseOperation.java:338)
at
com.webobjects.eoaccess.EODatabaseContext.createAdaptorOperationsForData
baseOperationAttributes(EODatabaseContext.java:5373)
at
com.webobjects.eoaccess.EODatabaseContext.createAdaptorOperationsForData
baseOperation(EODatabaseContext.java:5548)
at com.webobjects.eoaccess.EODatabaseContext.performChanges
(EODatabaseContext.java:6365)
at
com.webobjects.eocontrol.EOObjectStoreCoordinator.saveChangesInEditingCo
ntext(EOObjectStoreCoordinator.java:415)
at com.webobjects.eocontrol.EOEditingContext.saveChanges
(EOEditingContext.java:3226)
at net.global_village.eofextensions.ForgetfulEC.saveChanges
(ForgetfulEC.java:54)
at net.global_village.eofvalidation.EOEditingContext.saveChanges
(EOEditingContext.java:126)
at
net.global_village.eofvalidation.NotifyingEditingContext.saveChanges
(NotifyingEditingContext.java:159)
The exception is correct, the snapshot _dbSnapshot = {}; does not
contain any values, let alone the one it is looking for. I am not
completely sure of how this happens. It is not consistent so I
believe it to be caused by concurrent threads sending EOF
notifications interacting with the locked / unlocked state of editing
contexts.
The situation that I have that causes this exception is this: I have
a page that starts an import process. It spins off a thread that
handles the actual import. This thread has its own EC. The first
thing it does is to create a new DownloadLog to record the start /
status of the import process. While it is processing, it
periodically unlocks and re-locks the EC and does a refreshing fetch
on the download log so that it can see changes made in other editing
contexts.
Once this thread is started, and concurrent with its processing, the
app goes to a page that monitors all the download logs. This was
built using the AjaxGrid and refreshes every 30 seconds. At each
refresh it does a refreshing fetch. Of course, its EC is unlocked
between requests. It has a link to abort the import by writing to
the download log, though that is not being used when this exception
occurs.
Periodically the download processing thread will throw the above
exception while saving an update to the download log. My guess is
that the refreshing fetch is invalidating the snapshot that the EC
was referring to and it gets a null / empty dictionary for it as it
is still locked.
I fixed this (or at least I can't reproduce it anymore) by doing
ec.unlock(); ec.lock(); immediately before ec.saveChanges();. My
guess is that this allows the snapshot to get updated. I suspect
there is still a race condition in there where the a refreshing fetch
is done on the download load while saveChanges() is in progress.
Does anyone know anything more about this or can you shed light on
what is happening and how you worked around it?
Cheers,
Chuck
--
Practical WebObjects - for developers who want to increase their
overall knowledge of WebObjects or who are trying to solve specific
problems.
http://www.global-village.net/products/practical_webobjects
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden