No way to delete error data entry

33 views
Skip to first unread message

Charlie Zhu

unread,
Jun 17, 2009, 4:15:17 AM6/17/09
to Google App Engine
Hi,

I have tried all ways I known to delete some schema changing caused
error Entities and failed.

1. Delete on Data Viewer on the console.
Data Viewer shows "No Data Yet."

2. Delete by code
Below is part of the codes:
Query q = pm.newQuery(CDKFingerprint.class);
List<CDKFingerprint> results2;
results2 = (List<CDKFingerprint>) q.execute();
pm.deletePersistentAll(results2);
But that cause server error:
java.lang.NullPointerException: Datastore entity with kind
CDKFingerprint and key CDKMol(c=cc=cc=c)/CDKFingerprint(1) has a null
property named bits_count. This property is mapped to
cdkhelper.CDKFingerprint.bits_count, which cannot accept null values.
...
at org.datanucleus.jdo.JDOPersistenceManager.deletePersistentAll
(JDOPersistenceManager.java:795)
...

3. Assign values to the NULL field then delete
The code
for(CDKFingerprint r: results2) {
r.bits_count = 0;
pm.makePersistent(r);
}
And server error again
java.lang.NullPointerException: Datastore entity with kind
CDKFingerprint and key CDKMol(c=cc=cc=c)/CDKFingerprint(1) has a null
property named bits_count. This property is mapped to
cdkhelper.CDKFingerprint.bits_count, which cannot accept null values.
...
at org.datanucleus.store.appengine.query.StreamingQueryResult
$AbstractListIterator.hasNext(StreamingQueryResult.java:205)
...

Having no idea and hoping help.

Regards,
Charlie

Nick Johnson (Google)

unread,
Jun 17, 2009, 11:58:02 AM6/17/09
to google-a...@googlegroups.com
Hi Charlie,

Your easiest option here is probably to upload an alternate major version of your app with the old schema, and use that to retrieve and fix the faulty entit(y|ies). Alternate approaches include using the low level datastore API, or uploading a Python version that uses the low level API or db.Expando.

-Nick Johnson
--
Nick Johnson, App Engine Developer Programs Engineer
Google Ireland Ltd. :: Registered in Dublin, Ireland, Registration Number: 368047

Charlie Zhu

unread,
Jun 20, 2009, 10:36:57 AM6/20/09
to Google App Engine
Thank you, Nick,

I have written code as below with low level API to delete the entry.
It runs without error but seems not totally working. And thanks god
that data suddenly appeared at Data Viewer and problem resolved.

Code pasted here and hope it useful for others

import com.google.appengine.api.datastore.DatastoreService;
import com.google.appengine.api.datastore.DatastoreServiceFactory;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.Query;

public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
String tbname = req.getParameter("tbname");
if(tbname!=null)
{
DatastoreService datastore =
DatastoreServiceFactory.getDatastoreService();

// Or perform a query
Query query = new Query(tbname);
for (Entity taskEntity : datastore.prepare(query).asIterable()) {
datastore.delete(taskEntity.getKey());
}
}
}


Regards,
Charlie

On Jun 17, 11:58 pm, "Nick Johnson (Google)" <nick.john...@google.com>
wrote:

Nick Johnson (Google)

unread,
Jun 22, 2009, 6:07:19 AM6/22/09
to google-a...@googlegroups.com
Hi Charlie,

What do you mean by "not totally working"? Also, you may have better luck asking this in the google-appengine-java group.

-Nick Johnson

Andrew

unread,
Jul 24, 2009, 10:39:36 AM7/24/09
to Google App Engine
Thanks for the code. Worked great except I got a bunch of these:
com.google.apphosting.api.DeadlineExceededException: This request
(f557629c71ca7b8d) started at 2009/07/24 13:20:12.825 UTC and was
still executing at 2009/07/24 13:20:41.505 UTC.

but just had to hit refresh a few times. It'd be nice if appengine
provided means to truncate/drop tables in the admin console.

Andrew
Reply all
Reply to author
Forward
0 new messages