Giter VIP home page Giter VIP logo

Comments (10)

nihohit avatar nihohit commented on June 12, 2024

I'm sorry, I don't understand what you're asking / requesting. Can you please expand on what you expected to see and what you've received?

from redis-rs.

zemelLeong avatar zemelLeong commented on June 12, 2024

The program is fetching data from Redis, and after running for a certain period, it consistently gets stuck at the execution of the rpop command. You can refer to the timestamps in the attached log screenshot, where there is a prolonged duration without any output. Prior to this, the log entries were consistently appearing in a cyclic pattern during the program's execution.

from redis-rs.

nihohit avatar nihohit commented on June 12, 2024

try replacing get_async_connection with get_multiplexed_async_connection. aio::Connection is deprecated.

from redis-rs.

zemelLeong avatar zemelLeong commented on June 12, 2024

Tested once, although it can run for a long time, it seems that there is still a similar problem. I am currently conducting a second test.

from redis-rs.

zemelLeong avatar zemelLeong commented on June 12, 2024

try replacing get_async_connection with get_multiplexed_async_connection. aio::Connection is deprecated.

The problem still exists, it took over an hour to run this time.
image

from redis-rs.

zemelLeong avatar zemelLeong commented on June 12, 2024

network change get_multiplexed_async_connection will get stuck too.
image

from redis-rs.

nihohit avatar nihohit commented on June 12, 2024

If you could write me a minimal, locally reproducible test, preferably using only redis-rs' test infrastructure, I could try to debug it. As it is, I don't have enough info to find the source of the issue.

from redis-rs.

zemelLeong avatar zemelLeong commented on June 12, 2024

I wrote a example. The operating system I'm using for testing is Windows 11, with the Redis service provided by a cloud server. If the CPU usage reaches or exceeds 90 percent, the issue can be reproduced quickly.
image

use redis::AsyncCommands;
use tracing::level_filters::LevelFilter;
use tracing_subscriber::layer::SubscriberExt;
use tracing_subscriber::util::SubscriberInitExt;

struct Sender {
    redis_client: redis::Client,
    queue: String,
}

impl Sender {
    fn init(redis_addr: &str) -> anyhow::Result<Self> {
        let redis_client = redis::Client::open(redis_addr)?;
        Ok(Sender {
            redis_client,
            queue: "test-queue".to_owned(),
        })
    }

    fn get_redis_client(&self) -> redis::Client {
        self.redis_client.clone()
    }

    async fn save_to_redis(&self, data: String) -> anyhow::Result<()> {
        let client = self.get_redis_client();
        tracing::info!("Get redis connection");
        let mut conn = client.get_multiplexed_async_connection().await?;
        tracing::info!("Execute save command");
        conn.lpush(&self.queue, data).await?;
        tracing::info!("Save to redis succeed");

        Ok(())
    }

    async fn run(self) -> anyhow::Result<()> {
        self.save_to_redis("Test Data".to_owned()).await?;
        let client = self.get_redis_client();
        let mut conn = client.get_multiplexed_async_connection().await?;
        loop {
            tracing::info!("Fetching redis data");
            let data: String = conn.rpop(&self.queue, None).await?;
            if data.is_empty() {
                tracing::error!("Data exception");
                break;
            }
            tracing::info!("Data fetch succeed");
            tokio::time::sleep(tokio::time::Duration::from_secs(1)).await;
            self.save_to_redis(data).await?;
            tracing::info!("Finished once data submit");
        }
        Ok(())
    }
}

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    tracing_subscriber::registry()
        .with(LevelFilter::INFO)
        .with(tracing_subscriber::fmt::layer())
        .init();
    let redis_url = "redis://remote-server/";
    let sender = Sender::init(redis_url)?;
    tokio::spawn(sender.run());
    tracing::info!("Thread started");
    loop {
        tokio::time::sleep(tokio::time::Duration::from_secs(10)).await;
    }
}

If modify main method like this. will be able to see a specific error message Error: Password authentication failed- AuthenticationFailed.If the same error occurred during blocking, I don't quite understand why this error message isn't being clearly displayed.
image

#[tokio::main]
async fn main() -> anyhow::Result<()> {
    tracing_subscriber::registry()
        .with(LevelFilter::INFO)
        .with(tracing_subscriber::fmt::layer())
        .init();
    let redis_url = "redis://remote-server";
    let sender = Sender::init(redis_url)?;
    sender.run().await?;
    Ok(())
}

from redis-rs.

nihohit avatar nihohit commented on June 12, 2024

sorry, this doesn't reproduce the issue when I run it locally against a local redis server.

from redis-rs.

zemelLeong avatar zemelLeong commented on June 12, 2024

I believe I've found the underlying issue. The high CPU usage, coupled with the unstable network conditions of the remote server, could easily give rise to the Password authentication failed- AuthenticationFailed error. It appears that I didn't handle this error properly, which in turn led to the termination of the thread's execution. To address this, I have now implemented additional recovery mechanisms. Thank you.

from redis-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.