Google Pub/Sub Subscription not found error when trying to access a Google Pub/Sub subscription.

The subscription has been deleted.

Understanding Google Pub/Sub

Google Cloud Pub/Sub is a messaging service designed to provide reliable, many-to-many, asynchronous messaging between applications. It decouples senders and receivers, allowing for scalable and flexible communication. Pub/Sub is commonly used for event-driven architectures, real-time analytics, and data integration pipelines.

Identifying the Symptom

When working with Google Pub/Sub, you might encounter an error indicating that a subscription cannot be found. This typically manifests as a SUBSCRIPTION_DELETED error. The error message might look like this:

{
"error": {
"code": 404,
"message": "Subscription not found",
"status": "NOT_FOUND"
}
}

This error suggests that the subscription you are trying to access has been deleted or does not exist.

Exploring the Issue

The SUBSCRIPTION_DELETED error occurs when a client attempts to interact with a subscription that has been removed from the Google Cloud Pub/Sub service. This can happen if the subscription was manually deleted or if it was part of a cleanup process. Once a subscription is deleted, it cannot be recovered, and any messages that were not yet acknowledged are lost.

Common Causes

  • Manual deletion of the subscription by a team member.
  • Automated scripts or processes that remove unused subscriptions.
  • Misconfiguration in the application pointing to a non-existent subscription.

Steps to Resolve the Issue

To resolve the SUBSCRIPTION_DELETED error, follow these steps:

Step 1: Verify Subscription Existence

First, confirm whether the subscription exists. You can list all subscriptions in your project using the Google Cloud SDK:

gcloud pubsub subscriptions list --project=YOUR_PROJECT_ID

Replace YOUR_PROJECT_ID with your actual Google Cloud project ID. Check if the subscription name appears in the list.

Step 2: Recreate the Subscription

If the subscription is indeed deleted, you will need to recreate it. Use the following command to create a new subscription:

gcloud pubsub subscriptions create YOUR_SUBSCRIPTION_NAME --topic=YOUR_TOPIC_NAME --project=YOUR_PROJECT_ID

Ensure you replace YOUR_SUBSCRIPTION_NAME, YOUR_TOPIC_NAME, and YOUR_PROJECT_ID with the appropriate values.

Step 3: Update Client Configuration

After recreating the subscription, update your application or client configuration to use the new subscription. This might involve changing environment variables, configuration files, or code that specifies the subscription name.

Additional Resources

For more information on managing subscriptions, refer to the Google Cloud Pub/Sub documentation. If you need further assistance, consider reaching out to Google Cloud Support.

By following these steps, you should be able to resolve the SUBSCRIPTION_DELETED error and ensure your application continues to function smoothly.

Never debug

Google Pub/Sub

manually again

Let Dr. Droid create custom investigation plans for your infrastructure.

Book Demo
Automate Debugging for
Google Pub/Sub
See how Dr. Droid creates investigation plans for your infrastructure.

MORE ISSUES

Made with ❤️ in Bangalore & San Francisco 🏢

Doctor Droid