Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transaction.get/.getAll hangs forever with Firestore emulator #1440

Closed
sgammon opened this issue Jun 26, 2019 · 9 comments
Closed

Transaction.get/.getAll hangs forever with Firestore emulator #1440

sgammon opened this issue Jun 26, 2019 · 9 comments

Comments

@sgammon
Copy link

sgammon commented Jun 26, 2019

[REQUIRED] Environment info

firebase-tools: 6.10.0

Platform: macOS 10.14.5

[REQUIRED] Test case

On it!

[REQUIRED] Steps to reproduce

  1. Spin up a Firestore emulator instance
  2. Start up a transaction using the Java Firestore client
  3. In that transaction, before any writes, perform a Transaction.get or Transaction.getAll against one or more known-missing document references
  4. Observe that it hangs forever

[REQUIRED] Expected behavior

It should just return null, or do whatever the normal failure behavior is, when you try to get(DocumentReference), or getAll(DocumentReference) during a Transaction.

[REQUIRED] Actual behavior

It seems to hang forever, although our tests timeout at 3 minutes.

@ryanpbrewster
Copy link
Contributor

I'll try to reproduce this, thanks for the report

@ryanpbrewster ryanpbrewster self-assigned this Jun 26, 2019
@sgammon
Copy link
Author

sgammon commented Jun 26, 2019

@ryanpbrewster thank you for the quick response, as usual! i do not expect to hear back when reporting bugs after midnight usually :)

sorry for filing two on you, but this one is the more critical one, because we are unable to use transactions when developing locally and doing get or getAll operations. OTOH this might be related to the fact that the documents don't exist - we're doing a username availability check here, essentially, so, we are wanting and expecting it not to be found, but it's just hanging.

thank you again and great work on the emulator, we have been throwing quite a bit of testing at it and it works great for 99.99% of cases.

@sgammon
Copy link
Author

sgammon commented Jun 26, 2019

it is also worth mentioning that identical operations work with the emulator when not executed in a transaction.

@ryanpbrewster
Copy link
Contributor

ryanpbrewster commented Jun 26, 2019

Huh, having trouble reproducing this. I'm using "com.google.cloud" % "google-cloud-firestore" % "1.9.0" and also v1.6.0. Same result in both cases.

Here's the code I'm using:

import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider
import com.google.cloud.firestore.FirestoreOptions
import io.grpc.ManagedChannelBuilder

object FirestoreEmulatorExample {
  def main(args: Array[String]): Unit = {
    val db = FirestoreOptions.newBuilder()
      .setProjectId("foo")
      .setChannelProvider(
        InstantiatingGrpcChannelProvider.newBuilder()
          .setEndpoint("localhost:8080")
          .setChannelConfigurator(input => input.usePlaintext())
          .build())
      .build()
      .getService

    val (ref, data) = db.runTransaction { txn =>
      val doc = txn.get(db.document("missing/unknown")).get();
      (doc.getReference, doc.getData)
    }.get()
    println(ref, data)
  }
}

which prints out

(DocumentReference{path=projects/foo/databases/(default)/documents/missing/unknown},null)

Do you see anything obvious that I'm doing differently?

@sgammon
Copy link
Author

sgammon commented Jun 26, 2019

I don't see anything obvious that you're doing differently, no. I suppose I am calling the future .get() after wrapping it in an ApiFutureToListenableFuture, since we're using Guava? That's all that comes to mind at the moment but I'll dig into this.

@ryanpbrewster
Copy link
Contributor

Bumping this: it would be super helpful to have a repro of this issue.

@sgammon
Copy link
Author

sgammon commented Jul 22, 2019

@ryanpbrewster I've tried to reproduce this, but I just haven't been able to catch it, and we're no longer seeing it in production. Would it be best to re-open once I can isolate it?

@google-oss-bot google-oss-bot added Needs: Attention and removed Needs: Author Feedback Issues awaiting author feedback labels Jul 22, 2019
@ryanpbrewster
Copy link
Contributor

Sounds like a plan. Feel free to re-open with more info even if you can't fully isolate or reproduce it.

@wneild
Copy link

wneild commented Apr 27, 2021

Hey, I just ran into this issue on the latest version libraries "firebase-tools": "^9.10.0" and "firebase-admin": "^9.6.0". It seems to occur when you only provide the ReadOptions argument without any proceeding document references.

I've personally run into this a couple of times because I am working with a set of document refs that could be length zero to many and it's necessary to spread the array of references to use this particular function. The work around is obviously to check you won't be spreading an empty array of document references into the function before you do.

It's worth noting the function correctly throws an error when you provide no arguments at all (without a ReadOptions). It's only when there's a ReadOptions argument and no references it seems to hang indefinitely.

This should reproduce the problem for anyone:

import { firestore } from 'firebase-admin';
firestore().getAll({
	fieldMask: ['someField'],
});

Probably worth adding another assertion to prevent this weirdness happening to anyone else. I hope this helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants