Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pubsub: subscribe/publish errors for large messages (caused by tonic update) #151

Closed
dezyh opened this issue May 23, 2023 · 0 comments
Closed

Comments

@dezyh
Copy link
Contributor

dezyh commented May 23, 2023

Currently pulling from a PubSub subscription with large messages (>4MB) will cause the stream to terminate. I have not tried but I believe publishing large messages (>4MB) to a topic will trigger the same stream termination.

The cause is a change in tonic 0.9.0, specifically this PR which adds a maximum encode/decode message size, which defaults to 4MB.

PubSub supports up to 10MB, so we should try update google-cloud-rust to specify a larger size when sending the stream request.

Basic Reproduction Case

Putting together something simple together and running with RUST_LOG=error cargo run

use futures_util::StreamExt;
use google_cloud_default::WithAuthExt;
use google_cloud_pubsub::client::{Client, ClientConfig};
use tracing_subscriber::{fmt, prelude::*, EnvFilter};

#[tokio::main]
async fn main() {
    tracing_subscriber::registry()
        .with(fmt::layer())
        .with(EnvFilter::from_default_env())
        .init();
        
    let config = ClientConfig::default().with_auth().await.unwrap();
    let client = Client::new(config).await.unwrap();
    
    let mut subscription = client.subscription("my-subscription");
    let mut messages = subscription.subscribe(None).await.unwrap();
    
    while let Some(msg) = messages.next().await {
        msg.ack().await.unwrap();
    }
}

Gives the following error:

ERROR google_cloud_pubsub::subscriber: terminated subscriber streaming with error Status { code: OutOfRange, message: "Error, message length too large: found 4750628 bytes, the limit is: 4194304 bytes", source: None } : projects/my-project/subscriptions/my-subscription

Which I've traced to this addition in the above PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants