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

SSH sessions not closed when running in systemd.service for list,upload,download command #578

Closed
No0key opened this issue Dec 6, 2022 · 13 comments
Assignees
Milestone

Comments

@No0key
Copy link

No0key commented Dec 6, 2022

Hello!
I created an issue that SSH sessions were not closed after the list command, you closed it with status fixed. I updated version of clickhouse-backup tool.

Command clickhouse-backup -c /path/to/config list now close SSH sessions, but when running in systemd service SSH session still remain open.

Logs from remote sftp storage

NOT CORRECT
Command: curl localhost:7171/backup/list/remote

Dec  6 09:16:53 sftp_server sshd[10231]: Accepted publickey for backup_user from backup_host_ip port 43472 ssh2: RSA...
Dec  6 09:16:53 sftp_server sshd[10231]: pam_unix(sshd:session): session opened for user backup_user by (uid=0)
Dec  6 09:16:53 sftp_server systemd-logind[1078]: New session 2079 of user backup_user.
....

CORRECT
Command: clickhouse-backup -c /path/to/config list

Dec  6 09:17:07 sftp_server sshd[10268]: Accepted publickey for backup_user from backup_host_ip port 43522 ssh2: RSA...
Dec  6 09:17:07 sftp_server sshd[10268]: pam_unix(sshd:session): session opened for user backup_user by (uid=0)
Dec  6 09:17:07 sftp_server systemd-logind[1078]: New session 2082 of user backup_user.
Dec  6 09:17:07 sftp_server sshd[10268]: pam_unix(sshd:session): session closed for user backup_user
Dec  6 09:17:07 sftp_server systemd-logind[1078]: Removed session 2082.

Systemd service file

[Unit]
Description=clickhouse-backup rest server
Documentation=https://github.com/AlexAkulov/clickhouse-backup
After=network-online.target systemd-resolved.service clickhouse-server.service
Wants=network-online.target systemd-resolved.service clickhouse-server.service

[Service]
Type=simple
User=root
Group=root
ExecStart=/usr/bin/clickhouse-backup -c /opt/conf/clickhouse-backup/config.yml server
Restart=always
RestartSec=3

SyslogIdentifier=clickhouse-backup
StartLimitInterval=0

OOMScoreAdjust=0
MemoryHigh=20%

CPUSchedulingPolicy=other
CPUSchedulingPriority=0
CPUQuota=40%
Nice=0

LimitNOFILE=65536

[Install]
WantedBy=multi-user.target

@Slach
Copy link
Collaborator

Slach commented Dec 6, 2022

which clickhouse-backup version do you use?

@No0key
Copy link
Author

No0key commented Dec 6, 2022

[ubuntu-20] root : ~ clickhouse-backup --version                                     
Version:	 2.1.1
Git Commit:	 233bed562ab2ebe6def3d55ade81007633aefeab
Build Date:	 2022-10-20

@Slach
Copy link
Collaborator

Slach commented Dec 6, 2022

Do you use remote_storage: sftp?

@No0key
Copy link
Author

No0key commented Dec 6, 2022

Yes, my config is below

general:
  remote_storage: sftp
  max_file_size: 1073741824
  disable_progress_bar: true
  backups_to_keep_local: 12 # tables amount
  backups_to_keep_remote: 192 # tables amount
  log_level: info
  allow_empty_backups: false
  download_concurrency: 40
  upload_concurrency: 8
  restore_schema_on_cluster: ""
  upload_by_part: true
  download_by_part: true

sftp:
  address: my_remote_storage
  username: backup_user
  password: ""
  key: "/root/.ssh/id_rsa"
  path: /remote_path
  concurrency: 8
  compression_format: tar
  compression_level: 3
  debug: true

@Slach Slach changed the title SSH sessions not closed when running in systemd.service SSH sessions not closed when running in systemd.service for list command Dec 6, 2022
@No0key
Copy link
Author

No0key commented Dec 6, 2022

Problem is not only with list command, it is appear with download, upload operations too.

@No0key No0key changed the title SSH sessions not closed when running in systemd.service for list command SSH sessions not closed when running in systemd.service for list,upload,download command Dec 6, 2022
@Slach
Copy link
Collaborator

Slach commented Dec 6, 2022

what happens if you change
concurrency: 8 to concurrency: 1 in sftp section? is connection closed in this case?

@Slach Slach added this to the 2.2.0 milestone Dec 6, 2022
@Slach Slach self-assigned this Dec 6, 2022
@No0key
Copy link
Author

No0key commented Dec 7, 2022

No, still open

@Slach
Copy link
Collaborator

Slach commented Jan 2, 2023

could you check altinity/clickhiuse-backup:2.1.3
i tried multiple times with stantard openssh server
and got

sshd                  | debug1: session_close_by_channel: channel 0 child 0
sshd                  | Close session: user root from 172.26.0.9 port 43200 id 0

for every command which run from API server

@Slach
Copy link
Collaborator

Slach commented Jan 3, 2023

Which sftp server do you use?

@Slach Slach closed this as completed in 4873fd6 Jan 4, 2023
@No0key
Copy link
Author

No0key commented Jan 5, 2023

Using standard sftp subsystem in openssh server, here is config for ssh server which enables sftp

# override default of no subsystems
Subsystem sftp /usr/lib/sftp-server -f local5 -l DEBUG3

Its not closing connection only when running API server.

@No0key
Copy link
Author

No0key commented Jan 5, 2023

Tried version 2.1.3, still connections remain open

Jan  5 07:27:57 backup-host sshd[7977]: Accepted publickey for backup_user from BACKUP_HOST_IP port 12470 ssh2: RSA SHA256.....REDACTED
Jan  5 07:27:57 backup-host sshd[7977]: pam_unix(sshd:session): session opened for user backup_user by (uid=0)
Jan  5 07:27:57 backup-host systemd-logind[1078]: New session 63458 of user backup_user

@Slach Slach reopened this Jan 10, 2023
@No0key
Copy link
Author

No0key commented Feb 16, 2023

Any update on this issue?

@Slach
Copy link
Collaborator

Slach commented Mar 15, 2023

reproduced on my side
will released on 2.2.0 in couple of days

@Slach Slach closed this as completed in 1eaeeca Mar 17, 2023
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

No branches or pull requests

2 participants