Skip to content

[Bug] In multi-threaded parallel execution, a large number of read only operations waste a lot of unnecessary time because the combination of "read and write" operations requires "serialization". #15665

@frozenNoob

Description

@frozenNoob

Pre-check

  • I am sure that all the content I provide is in English.

Search before asking

  • I had searched in the issues and found no similar feature requirement.

Apache Dubbo Component

Java SDK (apache/dubbo)

Descriptions

The issues with the first approach (c8a8946) are as follows:

  1. If a large number of read-only operations flood in, it is not appropriate for the first approach to wrap the read-write combination into an atomic operation. This will cause those read-only operations to be executed serially, which is very time-consuming (imagine 10K threads executing the compute method’s write operation serially due to the lock imposed by synchronized).
  2. I believe that in this load balancing algorithm, although the first approach can guarantee consistency, it cannot fundamentally prevent errors. For example: in the time window between the execution of the compute method and the return of the doSelect function, if another thread modifies the service list and rebuilds the corresponding values on the hash ring, then the result returned by the select method may be a stale node, which will still trigger subsequent fault-tolerance and retry mechanisms. Of course, since the average time complexity of a TreeMap query is O(log n), this time window is short but still exists.

Related issues

No response

Are you willing to submit a pull request to fix on your own?

  • Yes I am willing to submit a pull request on my own!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedEverything needs help from contributorstype/enhancementEverything related with code enhancement or performance

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions