+
Skip to content

Conversation

MikhailBurdukov
Copy link
Contributor

@MikhailBurdukov MikhailBurdukov commented Sep 29, 2025

The prototype script that should detect dead zero copy locks. Probably will be never merged but lets keep it anyway, may be one day will be useful

Summary by Sourcery

Introduce a prototype tool to detect dead zero-copy locks in Zookeeper by adding a scanning function and exposing it via a new CLI command

New Features:

  • Add a prototype find_dead_zc_locks function to traverse zero-copy lock paths in Zookeeper and print locks missing the specified host
  • Expose the detection logic through a new find-dead-zero-copy-locks command in the CLI

Copy link
Contributor

sourcery-ai bot commented Sep 29, 2025

Reviewer's Guide

Introduces a prototype mechanism to scan Zookeeper’s zero-copy lock hierarchy and identify locks with no matching host by adding a detection function and exposing it through a new CLI command.

Sequence diagram for the new 'find-dead-zero-copy-locks' CLI command

sequenceDiagram
    actor User
    participant CLI
    participant "remove_hosts_from_table()"
    participant "find_dead_zc_locks()"
    participant "zk_client"
    participant "get_children()"
    User->>CLI: Run 'find-dead-zero-copy-locks' command
    CLI->>"remove_hosts_from_table()": Call with args (ctx, zookeeper_table_path, shard_name, fqdn)
    "remove_hosts_from_table()"->>"find_dead_zc_locks()": Call with same args
    "find_dead_zc_locks()"->>"zk_client": Open Zookeeper client
    "find_dead_zc_locks()"->>"get_children()": Get children of zc_root_path
    loop For each table
        "find_dead_zc_locks()"->>"get_children()": Get children of table_path
        loop For each part
            "find_dead_zc_locks()"->>"get_children()": Get children of part_path
            loop For each lock
                "find_dead_zc_locks()"->>"get_children()": Get children of lock_path
                alt If no host in fqdn
                    "find_dead_zc_locks()"->>CLI: Print lock_path
                end
            end
        end
    end
    "find_dead_zc_locks()"-->>"zk_client": Close Zookeeper client
Loading

Class diagram for new and modified functions in Zookeeper zero-copy lock detection

classDiagram
    class remove_hosts_from_table {
        +remove_hosts_from_table(ctx: Context, zookeeper_table_path: str, shard_name: str, fqdn: list)
    }
    class find_dead_zc_locks {
        +find_dead_zc_locks(ctx, zc_root_path, shard_name, fqdn)
    }
    remove_hosts_from_table --> find_dead_zc_locks: calls
    class zk_client {
        +__enter__()
        +__exit__()
    }
    find_dead_zc_locks --> zk_client: uses
    class get_children {
        +get_children(zk, path)
    }
    find_dead_zc_locks --> get_children: uses
Loading

File-Level Changes

Change Details Files
Prototype detection function for dead zero copy locks
  • Traverse zero-copy root path → tables → parts → lock nodes
  • Filter lock entries by shard_name and collect host children
  • Mark and print lock paths missing any fqdn hosts
ch_tools/chadmin/internal/zookeeper_clean.py
New CLI command to invoke dead lock detection
  • Add find-dead-zero-copy-locks under zookeeper_group
  • Define arguments: zookeeper-table-path, shard-name, fqdn list
  • Call find_dead_zc_locks with parsed parameters
ch_tools/chadmin/cli/zookeeper_group.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载