title: Firebase - Strange behavior on App Engine
body: <p>Currently using Firebase 3.0.2 on Java App Engine.  I'm deploying to a basic scaling module.  My goal is to export some data from the datastore to firebase.  I'm using a taskqueue to process one entity from the datastore at a time.   I am attempting to add Car objects from the datastore into Firebase.  After completion of the transaction (I want to keep the same Ids and be able to update this data, thus the transaction) I want to add data to the autosuggest/cars/  path and update a counter (also using a transaction).</p>
  
  <p>So the structure I am building is this:</p>
  
  <pre><code>{
   "autosuggest": { 
      "cars" {
          "bu": {
               "123": {
                    "name": "buick"
                }
         }
  },
  "cars": {
      "123": {
           "name" : "buick",
           "desc": "Big car"
        }
  },
  "stats": {
       "carCt": 1
     }
  }
  </code></pre>
  
  <p>However, I am getting strange results, such as transactions not completing.  I am also getting data in /autosuggest/cars/, with carIds as the key.  CarIds are used for keys in /cars only in the code.<br>
        FirebaseDatabase.getInstance().getReference().child("cars").child(String.valueOf(cars.getId())).runTransaction(new Handler() {
              @Override
              public Result doTransaction(MutableData mutableData) {
                  mutableData.setValue(department);
                  return Transaction.success(mutableData);
              }</p>
  
  <pre><code>        @Override
          public void onComplete(DatabaseError databaseError, boolean b, DataSnapshot dataSnapshot) {
              if (databaseError != null) {
  
              } else {
                  addToAutoSuggestForString(car, String.valueOf(car.getId()));
                  incrementCarCounter();
              }
          }
      });
  
   private void incrementCarCounter() {
       FirebaseDatabase.getInstance().getReference().child("stats").child("carCt").runTransaction(new Handler() {
          @Override
          public Result doTransaction(MutableData mutableData) {
              Integer currentData = mutableData.getValue(Integer.class);
              if (currentData == null) {
                  mutableData.setValue(1);
              } else {
                  mutableData.setValue(currentData + 1);
              }
              return com.google.firebase.database.Transaction.success(mutableData);
          }
  
          @Override
          public void onComplete(DatabaseError databaseError, boolean b, DataSnapshot dataSnapshot) {
              if (databaseError != null) {
                  log.info("error");
              } else {
                  log.info("Firebase counter increment succeeded.");
              }
          }
      });
  }
   private void addAutoSuggestForString(final AutoCompleteResult result, String name) {
    FirebaseDatabase.getInstance().getReference().child("autosuggest/cars").child(searchStr + "/" + result.getKey()).setValue(result);
      }
  }
  </code></pre>
  
  <p>Is there anything in the code above that would cause strange behavior and/or transactions to fail?  Is running this is a taskqueue of with max rate 10/s an issue?  The internals of Firebase sdk are a bit of a mystery.  Is calling Firebase.getInstance().getReference() over and over OK, or is this opening a seperate websocket each time?</p>