Coder Social home page Coder Social logo

Comments (5)

DarkMatterV avatar DarkMatterV commented on September 25, 2024

because I am not familiar with java, I asked chatgpt about RedisShardBackplane getStorageWorkers,and i want to know if it's right,this is it‘s answer:

Based on the error log, it seems that there is a thread blocking issue occurring within the synchronized block of the getStorageWorkers() method. Specifically, the thread "grpc-default-executor-7603" is being blocked while waiting to acquire the lock on the RedisShardBackplane object.

To address this issue, you can consider the following:

Reduce the execution time of the synchronized block: Ensure that operations within the synchronized block are completed quickly. Avoid performing time-consuming operations within the synchronized block, especially avoid calling methods that may cause blocking.

Avoid calling potentially blocking methods within the synchronized block: The call to client.call(this::fetchAndExpireStorageWorkers) within the synchronized block may cause blocking. You may consider moving this call outside the synchronized block or executing it asynchronously to prevent blocking other threads.

Optimize synchronization of data structures: While the storageWorkerSet is being operated on within the synchronized block to prevent concurrent modifications, there may still be issues with concurrent modification. You can use thread-safe data structures or implement finer-grained synchronization when modifying the collection.

Based on these suggestions, you can try modifying the code as follows:

@SuppressWarnings("ConstantConditions")
@Override
public synchronized Set<String> getStorageWorkers() throws IOException {
    if (storageWorkersDeadline == null || storageWorkersDeadline.isExpired()) {
        Set<String> newWorkerSet = client.call(this::fetchAndExpireStorageWorkers);
        synchronized (storageWorkerSet) {
            storageWorkerSet.clear();
            storageWorkerSet.addAll(newWorkerSet);
        }
        storageWorkersDeadline = Deadline.after(workerSetMaxAge, SECONDS);
    }
    synchronized (storageWorkerSet) {
        return new HashSet<>(storageWorkerSet);
    }
}

In this modification, the call to client.call(this::fetchAndExpireStorageWorkers) has been moved outside the synchronized block to avoid potential blocking issues within the synchronized block. Additionally, synchronization has been added when returning the storageWorkerSet to ensure that there are no concurrent modification issues when returning the collection.

from bazel-buildfarm.

DarkMatterV avatar DarkMatterV commented on September 25, 2024

It's similar to issue 1426: #1426

from bazel-buildfarm.

werkt avatar werkt commented on September 25, 2024

You're running at least 6 month old code, as ShardInstance.java no longer exists. Please update and see if this hang reproduces.

There are no longer any synchronizations in getStorageWorkers that could cause this.

from bazel-buildfarm.

DarkMatterV avatar DarkMatterV commented on September 25, 2024

You're running at least 6 month old code, as ShardInstance.java no longer exists. Please update and see if this hang reproduces.您正在运行至少 6 个月前的代码,因为 ShardInstance.java 已不存在。请更新并查看此挂起是否会重现。

There are no longer any synchronizations in getStorageWorkers that could cause this.getStorageWorkers 中不再有任何可能导致此问题的同步。

Okay, thanks. I'll upgrade and see how it goes.

from bazel-buildfarm.

werkt avatar werkt commented on September 25, 2024

Going to assume this has been corrected. Closing for now, feel free to reopen if there's anything to add here.

from bazel-buildfarm.

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.