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

Startup failure: current transaction is aborted, commands ignored until end of transaction block #7180

Open
haf opened this issue Apr 30, 2024 · 4 comments

Comments

@haf
Copy link

haf commented Apr 30, 2024

Bug report

When adding new models (in a bad manner by not making migrations for them; just declaring them) Medusa doesn't start, because for the get currency query, a previously executed query failed (and was rolled back)

info:    Connection to Redis in module 'event-bus-redis' established
✔ Modules initialized – 90ms
✔ Express intialized – 2ms
✔ Plugins intialized – 263ms
✔ Subscribers initialized – 6ms
✔ API initialized – 33ms
⠋ Initializing defaults
error:   Error starting server
 QueryFailedError: current transaction is aborted, commands ignored until end of transaction block
     at PostgresQueryRunner.query (web/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:219:19)
     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
     at async SelectQueryBuilder.loadRawResults (web/node_modules/typeorm/query-builder/SelectQueryBuilder.js:2192:25)
     at async SelectQueryBuilder.executeEntitiesAndRawResults (web/node_modules/typeorm/query-builder/SelectQueryBuilder.js:2040:26)
     at async SelectQueryBuilder.getRawAndEntities (web/node_modules/typeorm/query-builder/SelectQueryBuilder.js:684:29)
     at async SelectQueryBuilder.getOne (web/node_modules/typeorm/query-builder/SelectQueryBuilder.js:711:25) {
   query: 'SELECT "Currency"."code" AS "Currency_code", "Currency"."symbol" AS "Currency_symbol", "Currency"."symbol_native" AS                  "Currency_symbol_native", "Currency"."name" AS "Currency_name" FROM "public"."currency" "Currency" WHERE (("Currency"."code" = $1)) LIMIT 1',
   parameters: [ 'usd' ],
   driverError: error: current transaction is aborted, commands ignored until end of transaction block
       at web/node_modules/pg/lib/client.js:526:17
       at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
       at async PostgresQueryRunner.query (web/node_modules/typeorm/driver/postgres/PostgresQueryRunner.js:184:25)
       at async SelectQueryBuilder.loadRawResults (web/node_modules/typeorm/query-builder/SelectQueryBuilder.js:2192:25)
       at async SelectQueryBuilder.executeEntitiesAndRawResults (web/node_modules/typeorm/query-builder/SelectQueryBuilder.js:2040:26)
       at async SelectQueryBuilder.getRawAndEntities (web/node_modules/typeorm/query-builder/SelectQueryBuilder.js:684:29)
       at async SelectQueryBuilder.getOne (web/node_modules/typeorm/query-builder/SelectQueryBuilder.js:711:25) {
    length: 145,
    severity: 'ERROR',
    code: '25P02',
    detail: undefined,
    hint: undefined,
    position: undefined,
    internalPosition: undefined,
    internalQuery: undefined,
    where: undefined,
    schema: undefined,
    table: undefined,
    column: undefined,
    dataType: undefined,
    constraint: undefined,
    file: 'postgres.c',
    line: '1492',
    routine: 'exec_parse_message'
  },
  length: 145,
  severity: 'ERROR',
  code: '25P02',
  detail: undefined,
  hint: undefined,
  position: undefined,
  internalPosition: undefined,
  internalQuery: undefined,
  where: undefined,
  schema: undefined,
  table: undefined,
  column: undefined,
  dataType: undefined,
  constraint: undefined,
  file: 'postgres.c',
  line: '1492',
  routine: 'exec_parse_message'
}

Describe the bug

A clear and concise description of what the bug is.

System information

Medusa version (including plugins):
Node.js version:
Database:
Operating system:
Browser (if relevant):

Steps to reproduce the behavior

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

Expected behavior

Log error messages

@akramaskar
Copy link

Hi @haf , i'm having this issue as well while running the integration tests.

Did you solve it?

@haf
Copy link
Author

haf commented May 8, 2024

Yes, I solved my problem by guessing the cause correctly. Thankfully I hadn’t changed much

@akramaskar
Copy link

@haf Thank you for the quick answer! Can you show me what kind of issue that was?

@haf
Copy link
Author

haf commented May 11, 2024

Sure, I followed the multi-tenant guide and added store;

+import {
+  // alias the core entity to not cause a naming conflict
+  Product as MedusaProduct,
+  Store,
+} from "@medusajs/medusa"
+import { Entity, JoinColumn, ManyToOne } from "typeorm"
+
+@Entity()
+export class Product extends MedusaProduct {
+  @ManyToOne(() => Store)
+  @JoinColumn({ name: "store_id" })
+  store: Store
+}

then

+import {
+  Store as MedusaStore,
+} from "@medusajs/medusa"
+import { Entity, JoinColumn, ManyToOne } from "typeorm"
+import { Tenant } from "./tenant"
+
+@Entity()
+export class Store extends MedusaStore {
+  @ManyToOne(() => Tenant)
+  @JoinColumn({ name: "tenant_id" })
+  tenant: Tenant
+}

without creating the tenant table. So when Medusa started, it crashed.

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

No branches or pull requests

2 participants