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

Database configuration needed even when it's not used #999

Open
josecelano opened this issue Aug 7, 2024 · 1 comment
Open

Database configuration needed even when it's not used #999

josecelano opened this issue Aug 7, 2024 · 1 comment
Labels
- Admin - Enjoyable to Install and Setup our Software Enhancement / Feature Request Something New
Milestone

Comments

@josecelano
Copy link
Member

Usually, when you run the tracker for benchmarking, you disable persistency completely.

[metadata]
schema_version = "2.0.0"

[logging]
threshold = "error"

[core]
listed = false
private = false
tracker_usage_statistics = false

[core.database]
driver = "sqlite3"
path = "./sqlite3.db"

[core.tracker_policy]
persistent_torrent_completed_stat = false
remove_peerless_torrents = false

[[udp_trackers]]
bind_address = "0.0.0.0:6969"

Even if you don't use the database at all, you need to add either the database configuration:

[core.database]
driver = "sqlite3"
path = "./sqlite3.db"

Or to create the default location for the database:

./storage/tracker/lib/database/

Otherwise, you get this error:

TORRUST_TRACKER_CONFIG_TOML_PATH=./share/default/config/tracker.udp.benchmarking.toml torrust-tracker
Loading extra configuration from file: `./share/default/config/tracker.udp.benchmarking.toml` ...
2024-08-07T14:37:42.754632Z ERROR r2d2: unable to open database file: ./storage/tracker/lib/database/sqlite3.db

Besides, the database is created and tables too.

I think the app should not:

  • Require any DB configuration or storage folder.
  • Or create any DB file or tables.

If none of the features requiring persistency is enabled.

cc @da2ce7

@josecelano josecelano added Enhancement / Feature Request Something New - Admin - Enjoyable to Install and Setup our Software labels Aug 7, 2024
@josecelano josecelano added this to the v3.1.0 milestone Aug 7, 2024
@josecelano
Copy link
Member Author

I think the problem is we create the tables when we instantiate the DB driver:

pub fn build(driver: &Driver, db_path: &str) -> Result<Box<dyn Database>, Error> {
    let database = match driver {
        Driver::Sqlite3 => Builder::<Sqlite>::build(db_path),
        Driver::MySQL => Builder::<Mysql>::build(db_path),
    }?;

    database.create_database_tables().expect("Could not create database tables.");

    Ok(database)
}

I think we should move that logic out of the driver constructor and use an internal flag to call create_database_tables only once (the first time the driver is used).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- Admin - Enjoyable to Install and Setup our Software Enhancement / Feature Request Something New
Projects
None yet
Development

No branches or pull requests

1 participant