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

PostgresDriver.enableExtensions is runned on slave connection #7691

Closed
2 of 21 tasks
madeindjs opened this issue May 28, 2021 · 0 comments · Fixed by #7693
Closed
2 of 21 tasks

PostgresDriver.enableExtensions is runned on slave connection #7691

madeindjs opened this issue May 28, 2021 · 0 comments · Fixed by #7693

Comments

@madeindjs
Copy link
Contributor

Issue Description

PostgresDriver.enableExtensions is runned on slave connection.

Expected Behavior

I expected that CREATE EXTENSION always run on a master connection.

Actual Behavior

This produces the following error:

ERROR: cannot execute CREATE EXTENSION in a read-only transaction"

Steps to Reproduce

I created a dedicated repository to reproduce error using Docker to mount a master/slave environment

git clone https://github.com/madeindjs/typeorm_bug
cd typeorm_bug
docker-compose up

You'll see and output like this

postgres-slave_1  | 2021-05-28 10:20:57.944 UTC [31] ERROR:  cannot execute CREATE EXTENSION in a read-only transaction
postgres-slave_1  | 2021-05-28 10:20:57.944 UTC [31] STATEMENT:  CREATE EXTENSION IF NOT EXISTS "uuid-ossp"

This is caused by this entity

@Entity()
class User {
  @PrimaryGeneratedColumn()
  id: number | undefined;

  @Column({type: "text"})
  name: string | undefined;

  // require uuid extension
  @Generated("uuid")
  @Column({type: "uuid"})
  uuid: string | undefined;
}

You can see the complete file here:

My Environment

Dependency Version
Operating System Linux
Node.js version v14.15.4
Typescript version v0.2.32
TypeORM version v4.3.2

Additional Context

Relevant Database Driver(s)

  • aurora-data-api
  • aurora-data-api-pg
  • better-sqlite3
  • cockroachdb
  • cordova
  • expo
  • mongodb
  • mysql
  • nativescript
  • oracle
  • postgres
  • react-native
  • sap
  • sqlite
  • sqlite-abstract
  • sqljs
  • sqlserver

Are you willing to resolve this issue by submitting a Pull Request?

  • Yes, I have the time, and I know how to start.
  • Yes, I have the time, but I don't know how to start. I would need guidance.
  • No, I don't have the time, although I believe I could do it if I had the time...
  • No, I don't have the time and I wouldn't even know how to start.
madeindjs added a commit to madeindjs/typeorm that referenced this issue May 28, 2021
madeindjs added a commit to madeindjs/typeorm that referenced this issue May 28, 2021
I just removed `PostgresDriver.enableExtension` on slave connections.

close typeorm#7691
AlexMesser pushed a commit that referenced this issue May 29, 2021
I just removed `PostgresDriver.enableExtension` on slave connections.

close #7691
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant