GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — PubSub runs into `java.lang.RuntimeException: ManagedChannel allocation site` when a new publisher is created · Issue #3648 · googleapis/google-cloud-java

PubSub runs into java.lang.RuntimeException: ManagedChannel allocation site when a new publisher is created #3648

New issue
Copy link
New issue
Copy link
Closed
Closed
PubSub runs into java.lang.RuntimeException: ManagedChannel allocation site when a new publisher is created#3648
Copy link
Assignees
pongad
Labels
api: pubsubIssues related to the Pub/Sub API.type: questionRequest for information or clarification. Not an issue.

Description

@yuri-sergiichuk
yuri-sergiichuk
opened on Sep 6, 2018
Issue body actions

Hi!

We've currently received around 100-200 PubSub related issues when a PubSub publisher is created with the following stacktrace:

io.grpc.internal.ManagedChannelOrphanWrapper$ManagedChannelReference cleanQueue: *~*~*~ Channel ManagedChannelImpl{logId=4613, target=pubsub.googleapis.com:443} was not shutdown properly!!! ~*~*~* (ManagedChannelOrphanWrapper.java:163)
    Make sure to call shutdown()/shutdownNow() and wait until awaitTermination() returns true.
java.lang.RuntimeException: ManagedChannel allocation site
	at io.grpc.internal.ManagedChannelOrphanWrapper$ManagedChannelReference.<init>(ManagedChannelOrphanWrapper.java:103)
	at io.grpc.internal.ManagedChannelOrphanWrapper.<init>(ManagedChannelOrphanWrapper.java:53)
	at io.grpc.internal.ManagedChannelOrphanWrapper.<init>(ManagedChannelOrphanWrapper.java:44)
	at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:410)
	at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createSingleChannel(InstantiatingGrpcChannelProvider.java:206)
	at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createChannel(InstantiatingGrpcChannelProvider.java:162)
	at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.getTransportChannel(InstantiatingGrpcChannelProvider.java:149)
	at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:151)
	at com.google.cloud.pubsub.v1.stub.GrpcPublisherStub.create(GrpcPublisherStub.java:161)
	at com.google.cloud.pubsub.v1.Publisher.<init>(Publisher.java:154)
	at com.google.cloud.pubsub.v1.Publisher.<init>(Publisher.java:83)
	at com.google.cloud.pubsub.v1.Publisher$Builder.build(Publisher.java:607)

We are using PubSub library v 1.40.0. And here is how we create publishers:

Publisher createPublisher(ProjectTopicName topicName) {
        try {
            Publisher publisher = Publisher.newBuilder(topicName)
                                           .build();
            return publisher;
        } catch (IOException e) {
            String errorMessage = format("Cannot create a publisher for topic %s", topicName);
            throw new IllegalStateException(errorMessage, e);
        }
    }

Any thoughts or suggestions? By the way, we are running on AppEngine Standard with Java 8.

Reacted by Yuri Sergiichuk

Activity

Next
  1. pongad
    added
    type: questionRequest for information or clarification. Not an issue.
    api: pubsubIssues related to the Pub/Sub API.
    on Sep 6, 2018
  2. pongad commented on Sep 6, 2018

    @pongad
    pongad
    on Sep 6, 2018
    Contributor
    More actions

    I don't think this is actually related to creating new Publisher, though gRPC uses that as an opportunity to tell us that we're leaking channels.

    Is it possible that you're not calling Publisher.shutdown to clean up properly somewhere?

  3. yuri-sergiichuk commented on Sep 11, 2018

    @yuri-sergiichuk
    yuri-sergiichuk
    on Sep 11, 2018
    Author
    More actions

    Hello @pongad. Thank you for your reply.

    No, we are cleaning everything up every time:

    private static void cleanupPublisher(Publisher publisher) {
            try {
                publisher.shutdown();
            } catch (Exception e) {
                log().error("Unable to cleanup publisher for topic: {}", publisher.getTopicNameString(), e);
            }
        }
    
  4. JustinBeckwith
    assigned
    JesseLovelace
    on Sep 13, 2018
  5. pongad commented on Sep 15, 2018

    @pongad
    pongad
    on Sep 15, 2018
    Contributor
    More actions

    You're right. gRPC wants us to call awaitTermination. I sent a PR for fixing this. Unfortunately, I think this requires users to add awaitTermination to their programs.

  6. pongad
    closed this as completedin #3688on Sep 17, 2018
  7. pongad
    added a commit that references this issue on Sep 17, 2018

    pubsub: add Publisher.awaitTermination (#3688)

    This issue will close once commit ae614b3 is merged into the 'main' branch.
    ae614b3
  8. snehashah16
    added a commit that references this issue on Sep 18, 2018

    Sync to master head (#3698)

    This issue will close once commit d9d7adc is merged into the 'main' branch.
    d9d7adc
  9. borissnd commented on Sep 28, 2018

    @borissnd
    borissnd
    on Sep 28, 2018
    More actions

    I updated the library and added publisher.awaitTermination(1, TimeUnit.MINUTES); after publisher.shutdown(); in the close() method of my Closeable class but I keep getting the above error on publisher build.
    @yuri-sergiichuk, has this patch resolved your issue?

  10. yuri-sergiichuk commented on Sep 28, 2018

    @yuri-sergiichuk
    yuri-sergiichuk
    on Sep 28, 2018
    Author
    More actions

    @borissnd we are testing the new cloud libraries version now. I'll post an update here in case I'll notice the problem again.

  11. theacodes
    unassigned
    JesseLovelace
    on Sep 28, 2018
  12. janneh commented on Oct 12, 2018

    @janneh
    janneh
    on Oct 12, 2018
    More actions

    @yuri-sergiichuk @borissnd are you still experiencing this issue? I'm seeing the same problem

    doing something in the lines of:

    val publisher = Publisher.newBuilder(topicName).build()
    
    try {
        messages.forEach { message -> publisher.publish(message) }
    } finally {
        publisher.shutdown()
        publisher.awaitTermination(1, TimeUnit.MINUTES)
    }

    edit: Using version 1.48.0

  13. yuri-sergiichuk commented on Oct 12, 2018

    @yuri-sergiichuk
    yuri-sergiichuk
    on Oct 12, 2018
    Author
    More actions

    Yeah, we do still experience problems.

    We are also using 1.48.0 now.

    Reacted by Janne Lönn, jojo921 and Hesham Hussen
  14. borissnd commented on Oct 12, 2018

    @borissnd
    borissnd
    on Oct 12, 2018
    More actions

    Same here. The error still persists. I'm using version 1.45.0.
    @pongad @snehashah16 , could you please reopen this issue?

    Reacted by Amit Sahu
  15. 1 remaining item

  16. janneh commented on Oct 12, 2018

    @janneh
    janneh
    on Oct 12, 2018
    More actions

    Some more info on my problem: it might have been caused by repeatedly creating and shutting down publishers. Which seemed to be the suggested approach from what I found (like github doc and sample code here and here as examples) Could that somehow cause the problem?

    Here's a question on that topic: #2342 and there it's suggested to keep a more long lived publisher in a case like that instead. I'm trying that approach now instead.

  17. yuri-sergiichuk commented on Oct 12, 2018

    @yuri-sergiichuk
    yuri-sergiichuk
    on Oct 12, 2018
    Author
    More actions

    @janneh we were trying to cache our publishers, but that had even worse results for us on AppEngine. It's why we are creating and shutting down the subscribers now after usage.
    I'd be grateful if you could share the results of your experiments.

  18. yuri-sergiichuk commented on Oct 18, 2018

    @yuri-sergiichuk
    yuri-sergiichuk
    on Oct 18, 2018
    Author
    More actions

    @snehashah16, @pongad, any updates on this issue?

  19. janneh commented on Oct 18, 2018

    @janneh
    janneh
    on Oct 18, 2018
    More actions

    For me changing according to #2342 eliminated the problem. Not a single error of any kind since switching to a lon lived publisher for the service.

  20. ajaaym commented on Jan 11, 2019

    @ajaaym
    ajaaym
    on Jan 11, 2019
    Contributor
    More actions

    This is fixed in 628. Will be available after new version of gax-java is released

  21. ajaaym
    closed this as completedon Jan 11, 2019
  22. cperez1000 commented on Mar 15, 2019

    @cperez1000
    cperez1000
    on Mar 15, 2019
    More actions

    Does anybody know when this will be available?

  23. menulis commented on Aug 1, 2019

    @menulis
    menulis
    on Aug 1, 2019
    More actions

    Exactly the same issue persists for the subscriber channels that do not get shut down properly, since there is no direct or indirect call to GrpcTransportChannel.java#close() from within com.google.cloud.pubsub.v1.Subscriber. Therefore even with google-cloud-pubsub 1.84.0 we keep getting the same error message with slightly different stack trace:

    *~*~*~ Channel ManagedChannelImpl{logId=42, target=pubsub.googleapis.com:443} was not shutdown properly!!! ~*~*~*
        Make sure to call shutdown()/shutdownNow() and wait until awaitTermination() returns true.
    java.lang.RuntimeException: ManagedChannel allocation site
        at io.grpc.internal.ManagedChannelOrphanWrapper$ManagedChannelReference.<init>(ManagedChannelOrphanWrapper.java:94)
        at io.grpc.internal.ManagedChannelOrphanWrapper.<init>(ManagedChannelOrphanWrapper.java:52)
        at io.grpc.internal.ManagedChannelOrphanWrapper.<init>(ManagedChannelOrphanWrapper.java:43)
        at io.grpc.internal.AbstractManagedChannelImplBuilder.build(AbstractManagedChannelImplBuilder.java:514)
        at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createSingleChannel(InstantiatingGrpcChannelProvider.java:268)
        at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.createChannel(InstantiatingGrpcChannelProvider.java:185)
        at com.google.api.gax.grpc.InstantiatingGrpcChannelProvider.getTransportChannel(InstantiatingGrpcChannelProvider.java:177)
        at com.google.api.gax.rpc.ClientContext.create(ClientContext.java:160)
        at com.google.cloud.pubsub.v1.stub.GrpcSubscriberStub.create(GrpcSubscriberStub.java:263)
        at com.google.cloud.pubsub.v1.Subscriber.doStart(Subscriber.java:261)
        at com.google.api.core.AbstractApiService$InnerService.doStart(AbstractApiService.java:148)
        at com.google.common.util.concurrent.AbstractService.startAsync(AbstractService.java:248)
        at com.google.api.core.AbstractApiService.startAsync(AbstractApiService.java:120)
        at com.google.cloud.pubsub.v1.Subscriber.startAsync(Subscriber.java:253)
       // ...
    

    Is it possible to reopen this issue and fix the problem for the subscriber case?

  24. lucius-pl commented on Oct 31, 2019

    @lucius-pl
    lucius-pl
    on Oct 31, 2019
    More actions

    I've been experiencing the same exception in 1.98.0. A new issue for the subscriber should be opened to expect a fix?

  25. JustinBeckwith
    assigned
    pongad
    on Feb 1, 2021
  26. elmodeer commented on Aug 16, 2021

    @elmodeer
    elmodeer
    on Aug 16, 2021
    More actions

    Iam still experiencing this issue. Why is this closed?

  27. velkrish89 commented on Oct 30, 2023

    @velkrish89
    velkrish89
    on Oct 30, 2023
    More actions

    I am still facing this issue with the gcp publisher and raised a fresh ticket for the same.

    https://github.com/googleapis/java-pubsub/issues/1803

    Dependencies:
    GCP Pub/Sub Library Version: 4.7.1
    Java Version: 17.0.6
    GRPC Version: 1.56.1

  28. mpwoerner commented on Nov 27, 2024

    @mpwoerner
    mpwoerner
    on Nov 27, 2024
    More actions

    Still an issue...

  29. meltsufin
    added 2 commits that reference this issue on Apr 29, 2026

    pubsub: add Publisher.awaitTermination (#3688)

    This issue will close once commit d717121 is merged into the 'main' branch.
    d717121

    pubsub: add Publisher.awaitTermination (#3688)

    This issue will close once commit 1a6056c is merged into the 'main' branch.
    1a6056c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @pongad
    pongad

Labels

api: pubsubIssues related to the Pub/Sub API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.