eclipse-zenoh / zenoh

zenoh unifies data in motion, data in-use, data at rest and computations. It carefully blends traditional pub/sub with geo-distributed storages, queries and computations, while retaining a level of time and space efficiency that is well beyond any of the mainstream stacks.
https://zenoh.io
Other
1.4k stars 146 forks source link

``PublicationCache is not dropped #1054

Open YuanYuYuan opened 3 months ago

YuanYuYuan commented 3 months ago

Describe the bug

A new session creation hangs if a PublicationCache of another closed session is not dropped.

To reproduce

use config::ModeDependentValue;
use zenoh_ext::SessionExt;
use zenoh::prelude::r#async::*;

#[tokio::main]
async fn main() {
    {
        let mut config = config::peer();
        config
            .timestamping
            .set_enabled(Some(ModeDependentValue::Unique(true)))
            .unwrap();

        println!("Open a zenoh session.");
        let session = zenoh::open(config).res().await.unwrap();

        println!("Declare a publisher.");
        session.declare_publisher("asdfasdfas").res().await.unwrap();

        // Comment out this block can pass the test
        println!("Declare a publisher cache.");
        session
            .declare_publication_cache("asdfasdf")
            .res()
            .await
            .unwrap();

        println!("Drop the session.");
    }
    println!("Open a new zenoh session.");
    zenoh::open(config::peer()).res().await.unwrap();

    println!("Done.");
}

System info

YuanYuYuan commented 2 months ago

It seems that we need to replace the close function here with the Undeclare trait to align the undeclaration used in Queryable, Subscriber, etc.

YuanYuYuan commented 2 months ago

Possibly affect https://github.com/eclipse-zenoh/zenoh-c/blob/5a1728e09d60a093b2abee8b876925184e636067/src/publication_cache.rs?plain=1#L173