plasmicapp / plasmic

Visual builder for React. Build apps, websites, and content. Integrate with your codebase.
https://www.plasmic.app
MIT License
4.69k stars 377 forks source link

CREATE INDEX CONCURRENTLY cannot run inside a transaction block #116

Closed apilloudhivedigital52 closed 2 months ago

apilloudhivedigital52 commented 2 months ago

Hello!

Since the commit 261a6d7, I can't bash tools/run.bash ./node_modules/.bin/typeorm migration:run (I guess from yarn typeorm migration:run) because it triggers an error now:

query: SELECT * FROM current_schema()
query: SHOW server_version;
query: SELECT * FROM "information_schema"."tables" WHERE "table_schema" = 'public' AND "table_name" = 'migrations'
query: SELECT * FROM "information_schema"."tables" WHERE "table_schema" = 'public' AND "table_name" = 'typeorm_metadata'
query: SELECT * FROM "migrations" "migrations" ORDER BY "id" DESC
10 migrations are already loaded in the database.
12 migrations were found in the source code.
AddUserSignUpPromotionCode1710102143652 is the last executed migration. It was executed on Sun Mar 10 2024 21:22:23 GMT+0100 (Central European Standard Time).
2 migrations are new migrations that needs to be executed.
query: START TRANSACTION
query: ALTER TABLE "partial_revision_cache" ADD "modifiedComponentIids" text array
query: INSERT INTO "migrations"("timestamp", "name") VALUES ($1, $2) -- PARAMETERS: [1710431961598,"AddModifiedComponentsIids1710431961598"]
Migration AddModifiedComponentsIids1710431961598 has been executed successfully.
query: ALTER TABLE "project_revision" ADD "dataLength" integer
query: ALTER TABLE "pkg_version" ADD "modelLength" integer
query: CREATE INDEX CONCURRENTLY "IDX_a6c699a994fb0dc07fed6bed66" ON "project_revision" ("dataLength")
query failed: CREATE INDEX CONCURRENTLY "IDX_a6c699a994fb0dc07fed6bed66" ON "project_revision" ("dataLength")
error: error: CREATE INDEX CONCURRENTLY cannot run inside a transaction block
    at Parser.parseErrorMessage (/Users/alexandrepilloud/Development/plasmic/platform/wab/node_modules/pg-protocol/src/parser.ts:357:11)
    at Parser.handlePacket (/Users/alexandrepilloud/Development/plasmic/platform/wab/node_modules/pg-protocol/src/parser.ts:186:21)
    at Parser.parse (/Users/alexandrepilloud/Development/plasmic/platform/wab/node_modules/pg-protocol/src/parser.ts:101:30)
    at Socket.<anonymous> (/Users/alexandrepilloud/Development/plasmic/platform/wab/node_modules/pg-protocol/src/index.ts:7:48)
    at Socket.emit (node:events:517:28)
    at addChunk (node:internal/streams/readable:368:12)
    at readableAddChunk (node:internal/streams/readable:341:9)
    at Readable.push (node:internal/streams/readable:278:10)
    at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
  length: 132,
  severity: 'ERROR',
  code: '25001',
  detail: undefined,
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'xact.c',
  line: '3480',
  routine: 'PreventInTransactionBlock'
}
Migration "IndexRevisionDataLength1711994066440" failed, error: CREATE INDEX CONCURRENTLY cannot run inside a transaction block
query: ROLLBACK
Error during migration run:
QueryFailedError: CREATE INDEX CONCURRENTLY cannot run inside a transaction block
    at QueryFailedError.TypeORMError (/Users/alexandrepilloud/Development/plasmic/platform/wab/node_modules/typeorm/error/src/error/TypeORMError.ts:7:9)
    at QueryFailedError (/Users/alexandrepilloud/Development/plasmic/platform/wab/node_modules/typeorm/error/src/error/QueryFailedError.ts:9:9)
    at PostgresQueryRunner.<anonymous> (/Users/alexandrepilloud/Development/plasmic/platform/wab/node_modules/typeorm/driver/src/driver/postgres/PostgresQueryRunner.ts:263:19)
    at step (/Users/alexandrepilloud/Development/plasmic/platform/wab/node_modules/tslib/tslib.js:195:27)
    at Object.throw (/Users/alexandrepilloud/Development/plasmic/platform/wab/node_modules/tslib/tslib.js:176:57)
    at rejected (/Users/alexandrepilloud/Development/plasmic/platform/wab/node_modules/tslib/tslib.js:167:69)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5) {
  query: 'CREATE INDEX CONCURRENTLY "IDX_a6c699a994fb0dc07fed6bed66" ON "project_revision" ("dataLength") ',
  parameters: undefined,
  driverError: error: CREATE INDEX CONCURRENTLY cannot run inside a transaction block
      at Parser.parseErrorMessage (/Users/alexandrepilloud/Development/plasmic/platform/wab/node_modules/pg-protocol/src/parser.ts:357:11)
      at Parser.handlePacket (/Users/alexandrepilloud/Development/plasmic/platform/wab/node_modules/pg-protocol/src/parser.ts:186:21)
      at Parser.parse (/Users/alexandrepilloud/Development/plasmic/platform/wab/node_modules/pg-protocol/src/parser.ts:101:30)
      at Socket.<anonymous> (/Users/alexandrepilloud/Development/plasmic/platform/wab/node_modules/pg-protocol/src/index.ts:7:48)
      at Socket.emit (node:events:517:28)
      at addChunk (node:internal/streams/readable:368:12)
      at readableAddChunk (node:internal/streams/readable:341:9)
      at Readable.push (node:internal/streams/readable:278:10)
      at TCP.onStreamRead (node:internal/stream_base_commons:190:23) {
    length: 132,
    severity: 'ERROR',
    code: '25001',
    detail: undefined,
    hint: undefined,
    position: undefined,
    internalPosition: undefined,
    internalQuery: undefined,
    where: undefined,
    schema: undefined,
    table: undefined,
    column: undefined,
    dataType: undefined,
    constraint: undefined,
    file: 'xact.c',
    line: '3480',
    routine: 'PreventInTransactionBlock'
  },
  length: 132,
  severity: 'ERROR',
  code: '25001',
  detail: undefined,
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'xact.c',
  line: '3480',
  routine: 'PreventInTransactionBlock'
}

I already tried to change the line 145 of DbCon.ts:

const migrations = await conn.runMigrations({ transaction: "all" });

to

const migrations = await conn.runMigrations({ transaction: "none" });

Many thanks in advance for your support.

IcaroG commented 2 months ago

Can you try running yarn typeorm migration:run --transaction none and see if it works?

apilloudhivedigital52 commented 2 months ago

Hello! This command helped. After running this command, I could run yarn bootstrap again after pulling last work from master.