Skip to content

Occasionally Publish() blocks forever causing service disruption #12029

Answered by coryan
aks-zero asked this question in Q&A
Discussion options

You must be logged in to vote

The .then() call is non-blocking too (mostly see below), the call that is definitely blocking is .get().

    auto done = result.then(handler);
    // Waits until the shared state becomes ready, then retrieves the value stored in the shared state.
    done.get();

Do you need to call .get() here? It does not look like you need to. I would write something like:

void logResult(StatusOr<std::string> id, std::string const& topic, std:string const& eventName) {
  if (!id) {
    auto error = std::move(id).status();
    LOG_ERROR("pubsub_send_message: Failed to publish message. event: %s, error_message: %s, error_code: %s, error_info: %s\n",
        eventName.c_str(), error.message().c_str(), Stat…

Replies: 2 comments 4 replies

Comment options

You must be logged in to vote
2 replies
@aks-zero
Comment options

@coryan
Comment options

Answer selected by coryan
Comment options

You must be logged in to vote
2 replies
@coryan
Comment options

@morwin1
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
api: pubsub Issues related to the Pub/Sub API.
3 participants