Skip to content

ObjectId longer than 10 characters fails for PostgreSQL #6616

Closed
@ghost

Description

Issue Description

Specifying objectIdSize for more than 10 characters makes the system unusable.

Steps to reproduce

  1. Run the parse-server with --objectIdSize 32 and a PostgreSQL database
  2. Signup a new user via ReST API

Expected Results

User gets created.

Actual Outcome

Response to the client:

{
  "code": 1,
  "message": "Internal server error."
}

Server log error entry:

error: value too long for type character(10)
    at Connection.parseE (/parse-server/node_modules/pg/lib/connection.js:600:48)
    at Connection.parseMessage (/parse-server/node_modules/pg/lib/connection.js:399:19)
    at Socket.<anonymous> (/parse-server/node_modules/pg/lib/connection.js:115:22)
    at Socket.emit (events.js:311:20)
    at Socket.EventEmitter.emit (domain.js:482:12)
    at addChunk (_stream_readable.js:294:12)
    at readableAddChunk (_stream_readable.js:275:11)
    at Socket.Readable.push (_stream_readable.js:209:10)
    at TCP.onStreamRead (internal/stream_base_commons.js:186:23)

Environment Setup

  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : 4.2.0
    • Operating System: Ubuntu 18.04 LTS
    • Hardware: Docker Container
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): AWS
  • Database

    • MongoDB version: none
    • PostgreSQL version: 12.2
    • Storage engine: ???
    • Hardware: Docker Container
    • Localhost or remote server? (AWS, mLab, ObjectRocket, Digital Ocean, etc): AWS

Logs/Trace

Error from PostgreSQL which traced it to the actual problem:

2020-04-16 10:14:49.055 GMT [244] ERROR:  value too long for type character(10)
2020-04-16 10:14:49.055 GMT [244] STATEMENT:  INSERT INTO "_Session" ("sessionToken","user","createdWith","restricted","expiresAt","updatedAt","createdAt","objectId") VALUES ('r:<redacted>','IrEAlMkPVPnrfZGroeIIsWezAE8nriEY','{"action":"signup","authProvider":"password"}',false,'2020-04-16T10:19:49.054Z','2020-04-16T10:14:49.054Z','2020-04-16T10:14:49.054Z','AYBjC5izngspqIGNTfzL2p1pGuPNNxj0')

Looking into the generated schema, the issue is an inconsistency between objectId columns created as text and the user column in the _Session table, which is set to character(10):

                                              Table "public._Session"
     Column     |           Type           | Collation | Nullable | Default | Storage  | Stats target | Description 
----------------+--------------------------+-----------+----------+---------+----------+--------------+-------------
 objectId       | text                     |           | not null |         | extended |              | 
 createdAt      | timestamp with time zone |           |          |         | plain    |              | 
 updatedAt      | timestamp with time zone |           |          |         | plain    |              | 
 restricted     | boolean                  |           |          |         | plain    |              | 
 user           | character(10)            |           |          |         | extended |              | 
 installationId | text                     |           |          |         | extended |              | 
 sessionToken   | text                     |           |          |         | extended |              | 
 expiresAt      | timestamp with time zone |           |          |         | plain    |              | 
 createdWith    | jsonb                    |           |          |         | extended |              | 
 _rperm         | text[]                   |           |          |         | extended |              | 
 _wperm         | text[]                   |           |          |         | extended |              | 
Indexes:
    "_Session_pkey" PRIMARY KEY, btree ("objectId")
Access method: heap

Workaround

Reduce --objectIdSize parameter to 10.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions