calzoneman / sync

Node.JS Server and JavaScript/HTML Client for synchronizing online media
Other
1.46k stars 235 forks source link

Error on server first run: ER_TOO_LONG_KEY #860

Closed Xaekai closed 4 years ago

Xaekai commented 4 years ago

Fresh Ubuntu 18.04 LTS on Amazon EC2 Node package is Erbium (v12 LTS) from Nodesource repo [node v12.16.2 / npm v6.14.4] MariaDB is repo default: 10.1.44-MariaDB-0ubuntu0.18.04.1

cytube@antube:~/sync$ node index.js
No log backend bound for jsli.  Logging to stdout.
[WARN] config: Detected 127.0.0.1 or localhost in root-domain 'localhost'.  This server will not work from other computers!  Set root-domain to the domain the website will be accessed from (e.g. example.com)
[WARN] config: socket.io is bound to localhost, this server will be inaccessible from other computers!
[WARN] config: No YouTube v3 API key set.  YouTube links will not work.  See youtube-v3-key in config.template.yaml and https://developers.google.com/youtube/registering_an_application for information on registering an API key.
[WARN] config: No Twitch Client ID set.  Twitch VOD links will not work.  See twitch-client-id in config.template.yaml and https://github.com/justintv/Twitch-API/blob/master/authentication.md#developer-setupfor more information on registering a client ID
[WARN] config: No Mixer Client ID set.  Mixer.com links will not work.  See mixer-client-id in config.template.yaml for more information on registering a client ID
[INFO] config: Loaded configuration from config.yaml
[INFO] config: No camo configuration found, chat images will not be proxied.
[INFO] config: No prometheus configuration found, defaulting to disabled
[INFO] config: No email configuration found, defaulting to disabled
[INFO] server: Starting CyTube v3.70.0
[INFO] webserver: Enabled gzip compression
[INFO] main: Opening service socket
[ERROR] google2vtt: Error: ENOENT: no such file or directory, scandir '/opt/cytube/sync/google-drive-subtitles'
[INFO] torlist: File /opt/cytube/sync/tor-exit-list.json not found, downloading from https://check.torproject.org/exit-addresses
[INFO] database/tables: Creating table users
[INFO] database/tables: Creating table channels
[INFO] database/tables: Creating table channel_data
[INFO] database/tables: Creating table global_bans
[INFO] database/tables: Creating table password_reset
[INFO] database/tables: Creating table user_playlists
[INFO] database/tables: Creating table aliases
[INFO] database/tables: Creating table meta
[INFO] database/tables: Creating table channel_libraries
[INFO] torlist: Saved /opt/cytube/sync/tor-exit-list.json
[INFO] database/tables: Creating table channel_ranks
[INFO] database/tables: Creating table channel_bans
[INFO] database/tables: Creating table user_deletion_requests
[INFO] database/tables: Creating table media_metadata_cache
[ERROR] database: Error: ER_TOO_LONG_KEY: Specified key was too long; max key length is 767 bytes
    at Query.Sequence._packetToError (/opt/cytube/sync/node_modules/mysql/lib/protocol/sequences/Sequence.js:47:14)
    at Query.ErrorPacket (/opt/cytube/sync/node_modules/mysql/lib/protocol/sequences/Query.js:79:18)
    at Protocol._parsePacket (/opt/cytube/sync/node_modules/mysql/lib/protocol/Protocol.js:291:23)
    at Parser._parsePacket (/opt/cytube/sync/node_modules/mysql/lib/protocol/Parser.js:433:10)
    at Parser.write (/opt/cytube/sync/node_modules/mysql/lib/protocol/Parser.js:43:10)
    at Protocol.write (/opt/cytube/sync/node_modules/mysql/lib/protocol/Protocol.js:38:16)
    at Socket.<anonymous> (/opt/cytube/sync/node_modules/mysql/lib/Connection.js:88:28)
    at Socket.<anonymous> (/opt/cytube/sync/node_modules/mysql/lib/Connection.js:526:10)
    at Socket.emit (events.js:310:20)
    at addChunk (_stream_readable.js:286:12)
    at readableAddChunk (_stream_readable.js:268:9)
    at Socket.Readable.push (_stream_readable.js:209:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:186:23)
    --------------------
    at Protocol._enqueue (/opt/cytube/sync/node_modules/mysql/lib/protocol/Protocol.js:144:48)
    at Connection.query (/opt/cytube/sync/node_modules/mysql/lib/Connection.js:198:25)
    at /opt/cytube/sync/node_modules/knex/lib/dialects/mysql/index.js:134:18
    at new Promise (<anonymous>)
    at Client_MySQL._query (/opt/cytube/sync/node_modules/knex/lib/dialects/mysql/index.js:128:12)
    at Client_MySQL.query (/opt/cytube/sync/node_modules/knex/lib/client.js:167:17)
    at Runner.query (/opt/cytube/sync/node_modules/knex/lib/runner.js:134:36)
    at Runner.queryArray (/opt/cytube/sync/node_modules/knex/lib/runner.js:231:31)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at /opt/cytube/sync/node_modules/knex/lib/runner.js:260:18
    at ensureTable (/opt/cytube/sync/src/database/tables.js:10:13)
    at Object.initTables (/opt/cytube/sync/src/database/tables.js:146:5)

In addition to this, the server does not detect the malformed database if started again.

calzoneman commented 4 years ago

Your database probably defaulted to utf8mb4 for this column, which would require 4 bytes per character maximum.

CyTube's schema is careful to only declare utf8mb4 on columns that explicitly need it (and shorten indexes on those columns to 227 chars).

Adding t.charset('utf8'); to the top of the table generator for media_metadata_cache may fix it.

Xaekai commented 4 years ago

Affirmative. Local issue resolved. Issue should close on merger of PR.

To any who come to this later, don't forget to npm run-script build-server

calzoneman commented 4 years ago

The only open PR right now is concerning CSS selectors on the userlist; did you intend to submit another PR to fix this?

Xaekai commented 4 years ago

Sure. I shall claim the task.