googleapis / java-firestore

Apache License 2.0
100 stars 66 forks source link

Firestore client stops functioning after 10 snapshot listeners are registered - JAVA #1511

Open lucazin opened 9 months ago

lucazin commented 9 months ago

Issue related : https://github.com/googleapis/google-cloud-java/issues/3514

I have this kind of problem @schmidt-sebastian

i have 7 listeners, but always disconnecting some listeners and stop registering information in database. Im using Java.

What i have to do..to stop this behavior..?? because its intermitent situation.

I have to move to realtime database? or have some config extra to fix that? Because when i restart the server the listener back again..

image

Can someone help me?

lucazin commented 9 months ago

image

now.. 7 listeners and loss 1 and after 7 again..

the problem is stop working some principal listeners.

Im trying to do this

dbfirestore = FirestoreClient.getFirestore(); dbfirestore.getOptions().toBuilder().setChannelProvider( FirestoreOptions.getDefaultTransportChannelProviderBuilder() .setPoolSize(2).build());

lucazin commented 9 months ago

Again, we are having a strange behavior of listeners. We have 7 listeners active and some time just 6..just 5.. and back to 7 ..but with this behavior we can put our plataform in production stage.

lucazin commented 9 months ago

if we change te firestore instance to this line

dbfirestore = FirestoreClient.getFirestore(); dbfirestore.getOptions().toBuilder().setChannelProvider( FirestoreOptions.getDefaultTransportChannelProviderBuilder() .setPoolSize(2).build());

            will change something? 
lucazin commented 9 months ago

image

gregfenton commented 9 months ago

Can you describe the execution environment? Is this running in an EC2 container or something?

Are there any exceptions in the Java logs?

lucazin commented 9 months ago

Lets Go.

No exception, just stop listening..

Im running a API in SpringBoot inside a EC2 Linux ( Normal Java Application API) work like a charm no problem with the api. I have added firebase admin in dependecy gradle (like google said) I have the credentials by service account, like google explain.

The realtime database work good! firestore work too but some times the listener drop, i know because the document is not deleted from collection and not saving in database inside API.

This is NOT expected behavior because listener drop and not delete other 500 messages.. its not equals count read, write, delete..

image

This is right EXPECTED behavior, because listener is active, read, process and delete ..

image

I have 7 listeners and this is expected, not drop

image

But this behavior is not expected

image image

I will try to put this code and check if resolve something, i will set pool size 2.. but i thinks is not necessary.. we talking about 7 listeners only..

dbfirestore = FirestoreClient.getFirestore(); dbfirestore.getOptions().toBuilder().setChannelProvider( FirestoreOptions.getDefaultTransportChannelProviderBuilder() .setPoolSize(2).build());

im glad someone can help me resolve my problem with firestore.

lucazin commented 9 months ago

i did now a stress work load... i send a lot request to a specific listener and this is the behavior.

Drop a lot os listeners.. @gregfenton i have to restart the server to back the listeners again..

if i have a higher workload.. firestore drop the listener..

image

lucazin commented 9 months ago

@schmidt-sebastian @lanbochen is related with this issue? ( the difference is nodejs to java )

https://github.com/firebase/firebase-admin-node/issues/931

lucazin commented 9 months ago

image

i change my code just to check the workload.

for(int i=0;i<=50;i++) new DBFireStore().SendOrdersTransport(onFinishedListener,context,orderItens);

 my listener drop after run this..  i put for just to see ..but original code dont have..  but when users are send orders in high scale happen the same thing.. 
lucazin commented 9 months ago

image

the problem is higher workload .. i check three times the workload and if we see the listener drop when the workload if high. the clock below each graph show us.. everytime have a peak drop listener.

now..i dont know what to do.. :(

lucazin commented 9 months ago

im using this

https://firebase.google.com/docs/admin/setup#java

implementation 'com.google.firebase:firebase-admin:9.2.0'

@gregfenton