Chocobozzz / PeerTube

ActivityPub-federated video streaming platform using P2P directly in your web browser
https://joinpeertube.org/
GNU Affero General Public License v3.0
13.08k stars 1.51k forks source link

Peertube fails to start on query error #6599

Closed patit72 closed 1 month ago

patit72 commented 1 month ago

Describe the problem

when I run NODE_ENV=production NODE_CONFIG_DIR=/var/www/peertube/config node dist/server manually server fails to start with error

error: Cannot start application. { "err": { "stack": "Error\n at Query.run (/var/www/peertube/versions/peertube-v6.2.1/node_modules/sequelize/lib/dialects/postgres/query.js:50:25)\n at /var/www/peertube/versions/peertube-v6.2.1/node_modules/sequelize/lib/sequelize.js:315:28\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async migrate (file:///var/www/peertube/versions/peertube-v6.2.1/dist/core/initializers/migrator.js:23:9)", "message": "null value in column \"nodeVersion\" of relation \"application\" violates not-null constraint", "name": "SequelizeDatabaseError", "parent": { "stack": "error: null value in column \"nodeVersion\" of relation \"application\" violates not-null constraint\n at Parser.parseErrorMessage (/var/www/peertube/versions/peertube-v6.2.1/node_modules/pg-protocol/dist/parser.js:283:98)\n at Parser.handlePacket (/var/www/peertube/versions/peertube-v6.2.1/node_modules/pg-protocol/dist/parser.js:122:29)\n at Parser.parse (/var/www/peertube/versions/peertube-v6.2.1/node_modules/pg-protocol/dist/parser.js:35:38)\n at Socket.<anonymous> (/var/www/peertube/versions/peertube-v6.2.1/node_modules/pg-protocol/dist/index.js:11:42)\n at Socket.emit (node:events:520:28)\n at addChunk (node:internal/streams/readable:559:12)\n at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)\n at Readable.push (node:internal/streams/readable:390:5)\n at TCP.onStreamRead (node:internal/stream_base_commons:191:23)", "message": "null value in column \"nodeVersion\" of relation \"application\" violates not-null constraint", "length": 236, "name": "error", "severity": "ERROR", "code": "23502", "detail": "Failing row contains (510, 0, null, null, null).", "schema": "public", "table": "application", "column": "nodeVersion", "file": "execMain.c", "line": "1883", "routine": "ExecConstraints", "sql": "INSERT INTO \"application\" (\"migrationVersion\") VALUES (0)" }, "sql": "INSERT INTO \"application\" (\"migrationVersion\") VALUES (0)", "parameters": {} } }

Additional information

Chocobozzz commented 1 month ago

Please drop and re-create your database, then start peertube and paste the logs output

patit72 commented 1 month ago

I already tried that with the same result;

Chocobozzz commented 1 month ago

Please paste the entiere application output

patit72 commented 1 month ago
[peertube.redacted.it:443 uploadx] 2024-09-20 09:52:31.630 debug: DiskStorage config: {
  directory: '/var/www/peertube/storage/tmp/resumable-uploads',
  expiration: { maxAge: undefined, rolling: true },
  maxMetadataSize: '10MB',
  logger: [Function: Object],
  userIdentifier: [Function: userIdentifier],
  filename: [Function: filename]
}
[peertube.redacted.it:443 uploadx] 2024-09-20 09:52:31.646 debug: Registered handlers: DELETE, GET, OPTIONS, PATCH, POST, PUT
[peertube.redacted.it:443] 2024-09-20 09:52:32.666 debug: Checking NodeJS version v22.8.0.
[peertube.redacted.it:443] 2024-09-20 09:52:32.669 info: Using following configuration file hierarchy: /var/www/peertube/config/default.yaml -> /var/www/peertube/config/production.yaml.
[peertube.redacted.it:443] 2024-09-20 09:52:32.671 warn: SMTP is not configured so the contact form will not work.
(node:1650) [DEP0044] DeprecationWarning: The `util.isArray` API is deprecated. Please use `Array.isArray()` instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:1650) [DEP0055] DeprecationWarning: The `util.isRegExp` API is deprecated. Please use `arg instanceof RegExp` instead.
(node:1650) [DEP0047] DeprecationWarning: The `util.isDate` API is deprecated.  Please use `arg instanceof Date` instead.
[peertube.redacted.it:443] 2024-09-20 09:52:33.007 debug: Executed SQL request - Executing (default): SELECT 1+1 AS result
[peertube.redacted.it:443] 2024-09-20 09:52:33.010 debug: Executed SQL request - Executing (default): SELECT table_name FROM information_schema.tables WHERE table_schema = 'public' AND table_type LIKE '%TABLE' AND table_name != 'spatial_ref_sys';
[peertube.redacted.it:443] 2024-09-20 09:52:33.013 debug: Connection to PostgreSQL has been established successfully.
[peertube.redacted.it:443] 2024-09-20 09:52:33.024 debug: Executed SQL request - Executing (default): SELECT "migrationVersion" FROM "application"
[peertube.redacted.it:443] 2024-09-20 09:52:33.028 debug: Executed SQL request - Executing (default): INSERT INTO "application" ("migrationVersion") VALUES (0)
[peertube.redacted.it:443] 2024-09-20 09:52:33.034 error: Cannot start application. {
  "err": {
    "stack": "Error\n    at Query.run (/var/www/peertube/versions/peertube-v6.2.1/node_modules/sequelize/lib/dialects/postgres/query.js:50:25)\n    at /var/www/peertube/versions/peertube-v6.2.1/node_modules/sequelize/lib/sequelize.js:315:28\n    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n    at async migrate (file:///var/www/peertube/versions/peertube-v6.2.1/dist/core/initializers/migrator.js:23:9)",
    "message": "null value in column \"nodeVersion\" of relation \"application\" violates not-null constraint",
    "name": "SequelizeDatabaseError",
    "parent": {
      "stack": "error: null value in column \"nodeVersion\" of relation \"application\" violates not-null constraint\n    at Parser.parseErrorMessage (/var/www/peertube/versions/peertube-v6.2.1/node_modules/pg-protocol/dist/parser.js:283:98)\n    at Parser.handlePacket (/var/www/peertube/versions/peertube-v6.2.1/node_modules/pg-protocol/dist/parser.js:122:29)\n    at Parser.parse (/var/www/peertube/versions/peertube-v6.2.1/node_modules/pg-protocol/dist/parser.js:35:38)\n    at Socket.<anonymous> (/var/www/peertube/versions/peertube-v6.2.1/node_modules/pg-protocol/dist/index.js:11:42)\n    at Socket.emit (node:events:520:28)\n    at addChunk (node:internal/streams/readable:559:12)\n    at readableAddChunkPushByteMode (node:internal/streams/readable:510:3)\n    at Readable.push (node:internal/streams/readable:390:5)\n    at TCP.onStreamRead (node:internal/stream_base_commons:191:23)",
      "message": "null value in column \"nodeVersion\" of relation \"application\" violates not-null constraint",
      "length": 235,
      "name": "error",
      "severity": "ERROR",
      "code": "23502",
      "detail": "Failing row contains (15, 0, null, null, null).",
      "schema": "public",
      "table": "application",
      "column": "nodeVersion",
      "file": "execMain.c",
      "line": "1883",
      "routine": "ExecConstraints",
      "sql": "INSERT INTO \"application\" (\"migrationVersion\") VALUES (0)"
    },
    "sql": "INSERT INTO \"application\" (\"migrationVersion\") VALUES (0)",
    "parameters": {}
  }
}
MattyBoombalatty commented 1 month ago

Please see this as it might work for you too.

https://github.com/Chocobozzz/PeerTube/issues/6592#issuecomment-2358852540

patit72 commented 1 month ago

Please see this as it might work for you too.

#6592 (comment)

Thanks, mine is a brand new installation, Shail I try it as well?

MattyBoombalatty commented 1 month ago

Are you on 6.2.1 or 6.3.0 with the brand new installation?

patit72 commented 1 month ago

6.2.1

Chocobozzz commented 1 month ago

@patit72 Logs you pasted is not the first start of PeerTube on a fresh database. Can you retry to delete and recreate your database and run PeerTube?

cintek commented 1 month ago

@patit72 I also had that error but with 6.3.0. Next time I tried again it was gone. That time I used 6.3.1 and there also was an update for nodejs so it might be that one of those did fix the problem (I guess it was not the update of Peertube because of what I read in the release notes).

kontrollanten commented 1 month ago

It happened to me today when running develop branch on a pure new docker container (without any previous data). I removed the container and started again, then it worked.

Chocobozzz commented 1 month ago

Closing this issue without @patit72 answer to https://github.com/Chocobozzz/PeerTube/issues/6599#issuecomment-2367367515

Don't hesitate to comment even if the issue is closed, we can reopen it :)

@cintek & @kontrollanten In most cases, this problem occurs because the database was not created correctly the first time PeerTube was started. Subsequent starts will cause PeerTube to crash. It's the reason why pasting the first output start is important. If you notice interesting things in your logs, please create a dedicated issue so we can fix it