@@ -1207,29 +1207,23 @@ public QueryResult runQuery(Status status, Query query) {
12071207 String app = query .getApp ();
12081208 Profile profile = getOrCreateProfile (app );
12091209
1210- // The real datastore supports executing ancestor queries in transactions.
1211- // For now we're just going to make sure the entity group of the ancestor
1212- // is the same entity group with which the transaction is associated and
1213- // skip providing a transactionally consistent result set.
1214-
12151210 synchronized (profile ) {
1216- // Having a transaction implies we have an ancestor, but having an
1217- // ancestor does not imply we have a transaction.
1218- if (query .hasTransaction () || query .hasAncestor ()) {
1219- // Query can only have a txn if it is an ancestor query. Either way we
1220- // know we've got an ancestor.
1211+
1212+ if (query .hasTransaction ()) {
1213+ if (!app .equals (query .getTransaction ().getApp ())) {
1214+ throw newError (
1215+ ErrorCode .INTERNAL_ERROR ,
1216+ "Can't query app "
1217+ + app
1218+ + "in a transaction on app "
1219+ + query .getTransaction ().getApp ());
1220+ }
1221+ }
1222+
1223+ if (query .hasAncestor ()) {
12211224 Path groupPath = getGroup (query .getAncestor ());
12221225 Profile .EntityGroup eg = profile .getGroup (groupPath );
12231226 if (query .hasTransaction ()) {
1224- if (!app .equals (query .getTransaction ().getApp ())) {
1225- throw newError (
1226- ErrorCode .INTERNAL_ERROR ,
1227- "Can't query app "
1228- + app
1229- + "in a transaction on app "
1230- + query .getTransaction ().getApp ());
1231- }
1232-
12331227 LiveTxn liveTxn = profile .getTxn (query .getTransaction ().getHandle ());
12341228 // this will throw an exception if we attempt to read from
12351229 // the wrong entity group
@@ -1238,12 +1232,10 @@ public QueryResult runQuery(Status status, Query query) {
12381232 profile = eg .getSnapshot (liveTxn );
12391233 }
12401234
1241- if (query .hasAncestor ()) {
1242- if (query .hasTransaction () || !query .hasFailoverMs ()) {
1243- // Either we have a transaction or the user has requested strongly
1244- // consistent results. Either way, we need to apply jobs.
1245- eg .rollForwardUnappliedJobs ();
1246- }
1235+ if (query .hasTransaction () || !query .hasFailoverMs ()) {
1236+ // Either we have a transaction or the user has requested strongly
1237+ // consistent results. Either way, we need to apply jobs.
1238+ eg .rollForwardUnappliedJobs ();
12471239 }
12481240 }
12491241
0 commit comments