Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How many objects is "too many" for in a single transaction to Google's DataStore (High Replication)?

I have following entity (non-relevant fields/methods are removed).

public class HitsStatsTotalDO
{
    @Id
    transient private Long targetId;

    public Key<HitsStatsTotalDO> createKey()
    {
        return new Key<HitsStatsTotalDO>(HitsStatsTotalDO.class, targetId);
    }
}

So... I'm trying to do batch get for 10 objects for which I construct keys using HitsStatsTotalDO.createKey(). I'm attempting to fetch them in transaction like this:

final List<Key<HitsStatsTotalDO>> keys = ....

// This is being called in transaction..
Map<Key<HitsStatsTotalDO>, HitsStatsTotalDO> result = DAOBase.ofy().get(keys);

which throws following exception:

java.lang.IllegalArgumentException: operating on too many entity groups in a single transaction.

Could you please elaborate how many is too many and how to fix it ? I couldn't find exact number in the documentation.

Thanks!

like image 749
expert Avatar asked Nov 24 '11 02:11

expert


2 Answers

The issue is not the number of entities you're retrieving, it's the fact that they're in multiple entity groups. Either do the fetch outside a transaction, or use an XG (Cross Group) transaction.

like image 183
Nick Johnson Avatar answered Nov 15 '22 17:11

Nick Johnson


In a single transaction you can operate entities in the same entity group.

What Can Be Done In a Transaction

like image 1
88250 Avatar answered Nov 15 '22 17:11

88250