iyear / tdl

๐Ÿ“ฅ A Telegram tookit written in Golang

Home Page:https://docs.iyear.me/tdl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Bug] Multiple instances

1368129224 opened this issue ยท comments

Describe the bug

Run the tdl command in two terminals at the same time, one of them returns an error
Current database is used by another process, please terminate it first

To Reproduce

  1. run tdl dl -d /mnt/xxx/ -u https://t.me/xxxxxx in terminal 1
  2. run tdl dl -d /mnt/xxx/ -u https://t.me/yyyyyy in terminal 2 at the same time

Expected behavior

Downloading files in two terminals at the same time

Version

Version: 0.16.1
Commit: bb2c69b
Date: 2024-03-01T13:21:31Z

go1.21.7 linux/amd64

Which OS are you running tdl on?

Linux

Additional context

No response

Noted that a similar issue already exists, but it is still not possible to use multiple instances at the same time.
#424

Describe the bug

Run the tdl command in two terminals at the same time, one of them returns an error Current database is used by another process, please terminate it first

To Reproduce

  1. run tdl dl -d /mnt/xxx/ -u https://t.me/xxxxxx in terminal 1
  2. run tdl dl -d /mnt/xxx/ -u https://t.me/yyyyyy in terminal 2 at the same time

Expected behavior

Downloading files in two terminals at the same time

Version

Version: 0.16.1 Commit: bb2c69b Date: 2024-03-01T13:21:31Z

go1.21.7 linux/amd64

Which OS are you running tdl on?

Linux

Additional context

No response

Use a ubuntu docker container and install tdl in that and login account again so that you get 2 or more isolated logins
Thats what I have been doing ๐Ÿ˜‚

If you want I can share my setup

Or spin up vm/lxc

In my view, this is a feature not a bug.

Author define and deal with this expected error in main.go

tdl/main.go

Lines 20 to 23 in 0174e6d

humanizeErrors := map[error]string{
bbolt.ErrTimeout: "Current database is used by another process, please terminate it first",
surveyterm.InterruptErr: "Interrupted",
}


Go deeper, tdl use bblot behind to save and provide necessary data.

In bblot's doc, it says

Please note that Bolt obtains a file lock on the data file so multiple processes cannot open the same database at the same time.

In bblot's doc we can know that only bblot only support one writable access at the same time.

So in conclusion, it is almost impossible to enable two or more download at the same time in the same namespace.

Describe the bug

Run the tdl command in two terminals at the same time, one of them returns an error Current database is used by another process, please terminate it first

To Reproduce

  1. run tdl dl -d /mnt/xxx/ -u https://t.me/xxxxxx in terminal 1
  2. run tdl dl -d /mnt/xxx/ -u https://t.me/yyyyyy in terminal 2 at the same time

Expected behavior

Downloading files in two terminals at the same time

Version

Version: 0.16.1 Commit: bb2c69b Date: 2024-03-01T13:21:31Z
go1.21.7 linux/amd64

Which OS are you running tdl on?

Linux

Additional context

No response

Use a ubuntu docker container and install tdl in that and login account again so that you get 2 or more isolated logins Thats what I have been doing ๐Ÿ˜‚

If you want I can share my setup

Or spin up vm/lxc

Is it possible to use the same account in multiple tdl and download file at the same time this way?
If so, I would appreciate you sharing your setup steps. ๐Ÿ˜„

In my view, this is a feature not a bug.

Author define and deal with this expected error in main.go

tdl/main.go

Lines 20 to 23 in 0174e6d

humanizeErrors := map[error]string{
bbolt.ErrTimeout: "Current database is used by another process, please terminate it first",
surveyterm.InterruptErr: "Interrupted",
}

Go deeper, tdl use bblot behind to save and provide necessary data.

In bblot's doc, it says

Please note that Bolt obtains a file lock on the data file so multiple processes cannot open the same database at the same time.

In bblot's doc we can know that only bblot only support one writable access at the same time.

So in conclusion, it is almost impossible to enable two or more download at the same time in the same namespace.

Thanks for the explanation from a technical point of view.
I found a similar issue #424 where the author said it was fixed in v0.14.0, but it looks like it's still not possible to use multiple instances at the same time because of bblot?

@1368129224

First question:

I found a similar issue #424 where the author said it was fixed in v0.14.0, but it looks like it's still not possible to use multiple instances at the same time because of bblot?

In v0.14.0 release note we can see:

296d928: feat(main): humanize some errors (@iyear)
6843418: feat(storage): switch default storage to bolt (@iyear)

So I believe, the fix in #424 means switch to bblot and humanize the multiply instance error.


Second question:

Is it possible to use the same account in multiple tdl and download file at the same time this way?

Of course you can. There is no limit on it.

This should be considered as a feature and not a bug, close this issue.