mCaptcha icon indicating copy to clipboard operation
mCaptcha copied to clipboard

Problem with the postgress cluster

Open Alexey-Gribchenkov opened this issue 2 years ago • 1 comments

When the deployment occurs, the following error occurs: DBError(Execute(Database(PgDatabaseError { severity: Error, code: "42P05", message: "prepared statement \"sqlx_s_1\" already exists",

I believe this is being fixed "disable_statement_logging"

use crate::settings::Settings;
use db_core::prelude::*;

pub type BoxDB = Box<dyn MCDatabase>;

pub mod pg {
    use super::*;
    use db_sqlx_postgres::{ConnectionOptions, Fresh};
    use sqlx::postgres::PgPoolOptions;

    pub async fn get_data(settings: Option<Settings>) -> BoxDB {
        let settings = settings.unwrap_or_else(|| Settings::new().unwrap());
        let pool = settings.database.pool;
        let pool_options = PgPoolOptions::new().max_connections(pool);
        let connection_options = ConnectionOptions::Fresh(Fresh {
            pool_options,
            url: settings.database.url.clone(),
            disable_logging: !settings.debug,
        });
        let db = connection_options.connect().await.unwrap();
        db.migrate().await.unwrap();
        Box::new(db)
    }
}

However, I don't understand how to enable it. Judging by the source code, you need to change the debug = true setting for this. But it didn't work for me.

Alexey-Gribchenkov avatar Jul 18 '23 14:07 Alexey-Gribchenkov

I believe this is being fixed "disable_statement_logging"

Can you please explain how you arrived at this solution?

you need to change the debug = true setting for this. But it didn't work for me.

Setting debug = true in the configuration file instructs the database driver to increase verbosity while logging. I don't know if it will have any effect on the database itself.

Searching on the internet yielded results related to database drivers, which leads me to believe that this is a problem with the database driver we are using. We are not using the latest version, so I'll update it and see if it helps.

realaravinth avatar Jul 19 '23 06:07 realaravinth