crawler-commons / url-frontier

API definition, resources and reference implementation of URL Frontiers
Apache License 2.0
47 stars 12 forks source link

PutURLs calls failing with java.lang.IllegalStateException #77

Closed michaeldinzinger closed 1 year ago

michaeldinzinger commented 1 year ago

This issue is related to #71. When uploading urls using e.g. the command java -jar target/urlfrontier-client-2.4-SNAPSHOT.jar PutURLs -f <some_path>/2000urls, the server throws a row of IllegalStateExceptions. Analogously to #71, I managed to fix it by putting the code line unacked.incrementAndGet(); (class DistributedFrontierService line 512) right in front of the execute call of the writeExecutorService (line 510).

Exception in thread "pool-2-thread-1" java.lang.IllegalStateException: Stream is already completed, no further calls are allowed
        at com.google.common.base.Preconditions.checkState(Preconditions.java:502)
        at io.grpc.stub.ServerCalls$ServerCallStreamObserverImpl.onNext(ServerCalls.java:375)
        at crawlercommons.urlfrontier.service.SynchronizedStreamObserver.onNext(SynchronizedStreamObserver.java:59)
        at crawlercommons.urlfrontier.service.cluster.DistributedFrontierService$6.lambda$onNext$0(DistributedFrontierService.java:524)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)
Exception in thread "pool-2-thread-2" java.lang.IllegalStateException: Stream is already completed, no further calls are allowed
        at com.google.common.base.Preconditions.checkState(Preconditions.java:502)
        at io.grpc.stub.ServerCalls$ServerCallStreamObserverImpl.onNext(ServerCalls.java:375)
        at crawlercommons.urlfrontier.service.SynchronizedStreamObserver.onNext(SynchronizedStreamObserver.java:59)
        at crawlercommons.urlfrontier.service.cluster.DistributedFrontierService$6.lambda$onNext$0(DistributedFrontierService.java:524)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)
Exception in thread "pool-2-thread-3" java.lang.IllegalStateException: Stream is already completed, no further calls are allowed
        at com.google.common.base.Preconditions.checkState(Preconditions.java:502)
        at io.grpc.stub.ServerCalls$ServerCallStreamObserverImpl.onNext(ServerCalls.java:375)
        at crawlercommons.urlfrontier.service.SynchronizedStreamObserver.onNext(SynchronizedStreamObserver.java:59)
        at crawlercommons.urlfrontier.service.cluster.DistributedFrontierService$6.lambda$onNext$0(DistributedFrontierService.java:524)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)
Exception in thread "pool-2-thread-4" java.lang.IllegalStateException: Stream is already completed, no further calls are allowed
        at com.google.common.base.Preconditions.checkState(Preconditions.java:502)
        at io.grpc.stub.ServerCalls$ServerCallStreamObserverImpl.onNext(ServerCalls.java:375)
        at crawlercommons.urlfrontier.service.SynchronizedStreamObserver.onNext(SynchronizedStreamObserver.java:59)
        at crawlercommons.urlfrontier.service.cluster.DistributedFrontierService$6.lambda$onNext$0(DistributedFrontierService.java:524)
        at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
        at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
        at java.base/java.lang.Thread.run(Thread.java:829)
michaeldinzinger commented 1 year ago

I forgot to include it in the earlier PR, so I created a separate PR #78 for this little code modification described above

jnioche commented 1 year ago

Merged, thanks @michaeldinzinger