Skip to content

Error when creating postgres databases in parallel #1283

Closed

Description

@li-kai

I am using sqlx::Postgres::create_database in my test code, which runs in parallel, and I get the following error:

Database(PgDatabaseError { severity: Error, code: "55006", message: "source database \"template1\" is being accessed by other users", detail: Some("There are 2 other sessions using the database."), hint: None, position: None, where: None, schema: None, table: None, column: None, data_type: None, constraint: None, file: Some("dbcommands.c"), line: Some(528), routine: Some("createdb") })'

This is caused by this line of code. I am not familiar with postgres internals, but reading code from the createdb: /* No point in trying to use postgres db when creating postgres db. */
, it seems like we only need to switch to template1 when the database name is postgres, not when the user is postgres.

Activity

  1. added a commit that references this issue on Jul 23, 2021
    9ecfd5b
  2. added 2 commits that reference this issue on Nov 19, 2021
    6cdb35d
    b5a95c4
  3. added a commit that references this issue on Feb 29, 2024
    f0d0dce
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions