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

[Tools] yb-ctl fails due to pgrep illegal byte sequence #21381

Closed
1 task done
kai-franz opened this issue Mar 9, 2024 · 0 comments
Closed
1 task done

[Tools] yb-ctl fails due to pgrep illegal byte sequence #21381

kai-franz opened this issue Mar 9, 2024 · 0 comments
Assignees
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug priority/medium Medium priority issue status/awaiting-triage Issue awaiting triage

Comments

@kai-franz
Copy link
Contributor

kai-franz commented Mar 9, 2024

Jira Link: DB-10275

Description

Sometimes, yb-ctl fails due to a pgrep error:

bin/yb-ctl --data_dir /Users/kfranz/yugabyte-data start
Starting cluster with base directory /Users/kfranz/yugabyte-data
pgrep: Regular expression evaluation error (illegal byte sequence)
Traceback (most recent call last):
  File "/Users/kfranz/code/yugabyte-db-do-deletion/scripts/installation/bin/yb-ctl", line 1286, in get_pid
    pgrep_output = subprocess.check_output(
  File "/opt/homebrew/Cellar/[email protected]/3.9.17_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 424, in check_output
    return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
  File "/opt/homebrew/Cellar/[email protected]/3.9.17_1/Frameworks/Python.framework/Versions/3.9/lib/python3.9/subprocess.py", line 528, in run
    raise CalledProcessError(retcode, process.args,
subprocess.CalledProcessError: Command '['pgrep', '-l', '-f', 'yb-master .* --rpc_bind_addresses 127.0.0.1 ']' returned non-zero exit status 3.

This is due to pgrep encountering an unexpected encoding type in process names:

$ pgrep -l -f 'yb-master .* --rpc_bind_addresses 127.0.0.1'
pgrep: Regular expression evaluation error (illegal byte sequence)
$ echo $?
3

Issue Type

kind/bug

Warning: Please confirm that this issue does not contain any sensitive information

  • I confirm this issue does not contain any sensitive information.
@kai-franz kai-franz added area/ysql Yugabyte SQL (YSQL) status/awaiting-triage Issue awaiting triage labels Mar 9, 2024
@kai-franz kai-franz self-assigned this Mar 9, 2024
@yugabyte-ci yugabyte-ci added kind/bug This issue is a bug priority/medium Medium priority issue labels Mar 9, 2024
@kai-franz kai-franz added area/tools and removed area/ysql Yugabyte SQL (YSQL) labels Mar 9, 2024
@yugabyte-ci yugabyte-ci added area/ysql Yugabyte SQL (YSQL) and removed area/tools labels Mar 9, 2024
kai-franz added a commit that referenced this issue Mar 11, 2024
Summary:
When other processes have UTF-8 characters in their names, pgrep may fail
due to expecting a different encoding.

This revision fixes the issue by setting
the `LC_ALL` environment variable to `C.UTF-8` when invoking `pgrep`. Note that
the environment variable is only set for the subprocess which `pgrep` runs in;
this change does not modify it anywhere else.
Jira: DB-10275

Test Plan:
```
bin/yb-ctl create
```

Reviewers: mbautin

Reviewed By: mbautin

Differential Revision: https://phorge.dev.yugabyte.com/D33008
asrinivasanyb pushed a commit to asrinivasanyb/yugabyte-db that referenced this issue Mar 18, 2024
Summary:
When other processes have UTF-8 characters in their names, pgrep may fail
due to expecting a different encoding.

This revision fixes the issue by setting
the `LC_ALL` environment variable to `C.UTF-8` when invoking `pgrep`. Note that
the environment variable is only set for the subprocess which `pgrep` runs in;
this change does not modify it anywhere else.
Jira: DB-10275

Test Plan:
```
bin/yb-ctl create
```

Reviewers: mbautin

Reviewed By: mbautin

Differential Revision: https://phorge.dev.yugabyte.com/D33008
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/ysql Yugabyte SQL (YSQL) kind/bug This issue is a bug priority/medium Medium priority issue status/awaiting-triage Issue awaiting triage
Projects
None yet
Development

No branches or pull requests

2 participants