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

create_consumer stuck #1317

Open
glueball opened this issue Sep 15, 2024 · 1 comment
Open

create_consumer stuck #1317

glueball opened this issue Sep 15, 2024 · 1 comment
Labels
defect Suspected defect such as a bug or regression

Comments

@glueball
Copy link
Contributor

glueball commented Sep 15, 2024

Observed behavior

I was getting timeout errors when starting a service just upgraded to async-nats v0.36. I narrowed the problem to create_consumer. We are running the nats server v2.8 (had some other services using an ancient version of the [sync] nats crate, so we can't upgrade yet).

I tried upgrading the server to 2.9 and 2.10 in a test cluster and both work well. Also downgrading async-nats to 0.35.1 works just ok, so I'm only seeing the errors with the combination of async-nats v0.36.0 and server v2.8.

I tried to do a simpler version of my application code to reproduce the problem. In this simpler version, somehow I don't see a timeout error, but create_stream never returns, just gets stuck. Once again, server v2.9+ works with both versions of the crate, and crate version 0.35.1 does work with server 2.8.

// main.rs
use async_nats::jetstream::consumer::pull::Config as PullConfig;
use async_nats::jetstream::stream::{Config as StreamConfig, DiscardPolicy};
use async_nats::{connect, jetstream};
use std::time::Duration;
use tokio::time::sleep;

#[tokio::main]
async fn main() {
    let client = connect("localhost:34222").await.unwrap();
    let jetstream = jetstream::new(client);

    let _ =  jetstream.delete_stream("test").await;

    println!("Creating stream");
    let stream = jetstream
        .create_stream(StreamConfig {
            name: "test".to_string(),
            max_messages: 100_000,
            discard: DiscardPolicy::Old,
            ..Default::default()
        })
        .await
        .unwrap();

    println!("Creating consumer");
    stream
        .create_consumer(PullConfig {
            durable_name: Some("test-consumer".to_string()),
            ..PullConfig::default()
        })
        .await
        .unwrap();

    println!("Done!"); // This never prints when using async-nats v0.36 and nats v2.8
    sleep(Duration::from_secs(5)).await;
}
# Cargo.toml
[package]
name = "nats-timeout"
version = "0.1.0"
edition = "2021"

[dependencies]
async-nats = { version = "0.36", default-features = false, features = ["ring"] }
tokio = { version = "1.40.0", features = ["macros", "rt", "rt-multi-thread"] }

Expected behavior

create_consumer never hangs

Server and client version

Server: nats v2.8 (just pulled from the official nats:2.8 docker hub image)
Client: async-nats 0.36.0

Host environment

Tested in docker for windows, engine version v27.1.1.

The error also appears in our staging and production servers, which are running docker in linux.

Steps to reproduce

  1. Launch nats server v2.8 (for instance using the docker image)
  2. Run the example code
@glueball glueball added the defect Suspected defect such as a bug or regression label Sep 15, 2024
@Jarema
Copy link
Member

Jarema commented Sep 16, 2024

Hey.
Thanks for the report.

I will check it out, however keep in mind that 2.8 is out of support window for NATS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
defect Suspected defect such as a bug or regression
Projects
None yet
Development

No branches or pull requests

2 participants