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

rwlock is locked in lb #223

Closed
hubertshelley opened this issue Apr 30, 2024 · 4 comments
Closed

rwlock is locked in lb #223

hubertshelley opened this issue Apr 30, 2024 · 4 comments
Labels
question Further information is requested stale

Comments

@hubertshelley
Copy link

What is the problem your feature solves, or the need it fulfills?


Rwlock is locked in lb, and I not sure it's a bug or designed.


Describe the solution you'd like


Rwlock is free in request_filter.


Additional context



pub(crate) struct LB {
    pub(crate) service_book: Arc<RwLock<ServiceBook>>,
}

#[async_trait]
impl ProxyHttp for LB {
    type CTX = LBContext;

    fn new_ctx(&self) -> Self::CTX {
        Default::default()
    }

    ...

    async fn request_filter(
        &self,
        session: &mut Session,
        ctx: &mut Self::CTX,
    ) -> pingora::Result<bool>
    where
        Self::CTX: Send + Sync,
    {
        let path = session.req_header().uri.path().to_string();
        // self.service_book.read().await is locked
        match self.service_book.read().await.choose_service(path) {
            None => {
                println!("service not found");
                return Ok(false);
            }
            Some(service) => {
                service.url_rewrite(session.req_header_mut());
                ctx.service_addr = Some(service.get_url());
                Ok(true)
            }
        }
    }
}



@vicanso
Copy link

vicanso commented May 1, 2024

Is it really necessary to use rwlock? My project supports find a HttpPeer and rewrite the request path without lock.

https://github.com/vicanso/pingap/blob/main/src/proxy/server.rs#L375

@eaufavor eaufavor added the question Further information is requested label May 1, 2024
@eaufavor
Copy link
Member

eaufavor commented May 1, 2024

I'm not sure if this is relevant to the Pingora framework. This is a user defined lock. Only you can lock it. Where is write() called for the lock?

Copy link

github-actions bot commented May 9, 2024

This question has been stale for a week. It will be closed in an additional day if not updated.

@github-actions github-actions bot added the stale label May 9, 2024
Copy link

This issue has been closed because it has been stalled with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested stale
Projects
None yet
Development

No branches or pull requests

3 participants