Parse-server: _PushStatus issue after upgrade to 3.1.x

Created on 1 Nov 2018  Â·  60Comments  Â·  Source: parse-community/parse-server

error: Uncaught internal server error. TypeError: Cannot redefine property: _PushStatus
at Function.defineProperty ()
at SchemaData.volatileClasses.forEach.className (/app/node_modules/parse-server/lib/Controllers/SchemaController.js:530:14)
at Array.forEach ()
at new SchemaData (/app/node_modules/parse-server/lib/Controllers/SchemaController.js:529:21)
at getAllClasses.then.allSchemas (/app/node_modules/parse-server/lib/Controllers/SchemaController.js:654:27)
at process.internalTickCallback (internal/process/next_tick.js:77:7) TypeError: Cannot redefine property: _PushStatus
at Function.defineProperty ()
at SchemaData.volatileClasses.forEach.className (/app/node_modules/parse-server/lib/Controllers/SchemaController.js:530:14)
at Array.forEach ()
at new SchemaData (/app/node_modules/parse-server/lib/Controllers/SchemaController.js:529:21)
at getAllClasses.then.allSchemas (/app/node_modules/parse-server/lib/Controllers/SchemaController.js:654:27)
at process.internalTickCallback (internal/process/next_tick.js:77:7)
TypeError: Cannot redefine property: _PushStatus
at Function.defineProperty ()
at SchemaData.volatileClasses.forEach.className (/app/node_modules/parse-server/lib/Controllers/SchemaController.js:530:14)
at Array.forEach ()
at new SchemaData (/app/node_modules/parse-server/lib/Controllers/SchemaController.js:529:21)
at getAllClasses.then.allSchemas (/app/node_modules/parse-server/lib/Controllers/SchemaController.js:654:27)
at process.internalTickCallback (internal/process/next_tick.js:77:7)

stale

Most helpful comment

Might have a solution to this. We got the same error: Unable to ensure uniqueness for role name: MongoError: Index with name: name_1 already exists with different options when trying to start with our old DB from parse.com with parse-server 3.1.1.

The issue was that we had an index { "name": 1 } on _Role, but with sparse set to false. So we just deleted the index and parse-server created a new one (the same index, but with sparse set to true on start up.

All 60 comments

Do you happen to have by any chance an _PushStatus object in your _SCHEMA table?

Do you happen to have by any chance an _PushStatus object in your _SCHEMA table?

Yes I do. Parse Server automatically generated this object in version 3.0

Should I delete it instead?

Do you happen to have by any chance an _PushStatus object in your _SCHEMA table?

I tried to delete this object and got another error instead.

warn: Unable to ensure uniqueness for user email addresses: MongoError: Index with name: email_1 already exists with different options
at /app/node_modules/mongodb-core/lib/connection/pool.js:581:63
at authenticateStragglers (/app/node_modules/mongodb-core/lib/connection/pool.js:504:16)
at Connection.messageHandler (/app/node_modules/mongodb-core/lib/connection/pool.js:540:5)
at emitMessageHandler (/app/node_modules/mongodb-core/lib/connection/connection.js:310:10)
at Socket. (/app/node_modules/mongodb-core/lib/connection/connection.js:489:15)
at Socket.emit (events.js:182:13)
at Socket.EventEmitter.emit (domain.js:441:20)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
at Socket.Readable.push (_stream_readable.js:219:10)

What version were you running before upgrading to 3.1? The alert you’re seeing is regarding the _User table.

What version were you running before upgrading to 3.1? The alert you’re seeing is regarding the _User table.

From 3.0.0

Everything works fine in version 3.0.0

I am running parse-server 3.1.0 and also see similar warning when I start up parse-server (npm start).

Warnings on 3 index:
1) email_1
2) username_1
3) name_1

Is there any need to re-create the index on _User table when upgrading to 3.1.0?

warn: Unable to ensure uniqueness for user email addresses: MongoError: Index with name: email_1 already exists with different options
at /Users/Nebi/Documents/heroku/xxx/node_modules/mongodb-core/lib/connection/pool.js:581:63
at authenticateStragglers (/Users/Nebi/Documents/heroku/xxx/node_modules/mongodb-core/lib/connection/pool.js:504:16)
at Connection.messageHandler (/Users/Nebi/Documents/heroku/xxx/node_modules/mongodb-core/lib/connection/pool.js:540:5)
at emitMessageHandler (/Users/Nebi/Documents/heroku/xxx/node_modules/mongodb-core/lib/connection/connection.js:310:10)
at Socket. (/Users/Nebi/Documents/heroku/xxx/node_modules/mongodb-core/lib/connection/connection.js:453:17)
at Socket.emit (events.js:182:13)
at Socket.EventEmitter.emit (domain.js:442:20)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
at Socket.Readable.push (_stream_readable.js:219:10)
(node:86452) UnhandledPromiseRejectionWarning: MongoError: Index with name: email_1 already exists with different options
at /Users/Nebi/Documents/heroku/xxx/node_modules/mongodb-core/lib/connection/pool.js:581:63
at authenticateStragglers (/Users/Nebi/Documents/heroku/xxx/node_modules/mongodb-core/lib/connection/pool.js:504:16)
at Connection.messageHandler (/Users/Nebi/Documents/heroku/xxx/node_modules/mongodb-core/lib/connection/pool.js:540:5)
at emitMessageHandler (/Users/Nebi/Documents/heroku/xxx/node_modules/mongodb-core/lib/connection/connection.js:310:10)
at Socket. (/Users/Nebi/Documents/heroku/xxx/node_modules/mongodb-core/lib/connection/connection.js:453:17)
at Socket.emit (events.js:182:13)
at Socket.EventEmitter.emit (domain.js:442:20)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
at Socket.Readable.push (_stream_readable.js:219:10)
(node:86452) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:86452) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
warn: Unable to ensure uniqueness for usernames: MongoError: Index with name: username_1 already exists with different options
at /Users/Nebi/Documents/heroku/xxx/node_modules/mongodb-core/lib/connection/pool.js:581:63
at authenticateStragglers (/Users/Nebi/Documents/heroku/xxx/node_modules/mongodb-core/lib/connection/pool.js:504:16)
at Connection.messageHandler (/Users/Nebi/Documents/heroku/xxx/node_modules/mongodb-core/lib/connection/pool.js:540:5)
at emitMessageHandler (/Users/Nebi/Documents/heroku/xxx/node_modules/mongodb-core/lib/connection/connection.js:310:10)
at Socket. (/Users/Nebi/Documents/heroku/xxx/node_modules/mongodb-core/lib/connection/connection.js:489:15)
at Socket.emit (events.js:182:13)
at Socket.EventEmitter.emit (domain.js:442:20)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
at Socket.Readable.push (_stream_readable.js:219:10)
warn: Unable to ensure uniqueness for role name: MongoError: Index with name: name_1 already exists with different options
at /Users/Nebi/Documents/heroku/xxx/node_modules/mongodb-core/lib/connection/pool.js:581:63
at authenticateStragglers (/Users/Nebi/Documents/heroku/xxx/node_modules/mongodb-core/lib/connection/pool.js:504:16)
at Connection.messageHandler (/Users/Nebi/Documents/heroku/xxx/node_modules/mongodb-core/lib/connection/pool.js:540:5)
at emitMessageHandler (/Users/Nebi/Documents/heroku/xxx/node_modules/mongodb-core/lib/connection/connection.js:310:10)
at Socket. (/Users/Nebi/Documents/heroku/xxx/node_modules/mongodb-core/lib/connection/connection.js:489:15)
at Socket.emit (events.js:182:13)
at Socket.EventEmitter.emit (domain.js:442:20)
at addChunk (_stream_readable.js:283:12)
at readableAddChunk (_stream_readable.js:264:11)
at Socket.Readable.push (_stream_readable.js:219:10)

Are you able to provide the indexes from mongo perspective? We may have inadvertently mis implemented a feature in 3.1

@flovilmart, I believe these are the 3 indices. First two on _User and the last one on _Role.

{
"v": 1,
"key": {
"email": 1
},
"name": "email_1",
"ns": "xxx._User",
"background": true
}

{
"v": 1,
"key": {
"username": 1
},
"name": "username_1",
"ns": "xxx._User",
"background": true
}

{
"v": 1,
"unique": true,
"key": {
"name": 1
},
"name": "name_1",
"ns": "xxx._Role"
}

Would you be able to start a parse-server on a clean DB, and tell me what what do the indexes look like?

I have migrated my DB from parse.com since 2 years ago. I didn't know how to start from a clean DB. Could you point me to some documentation on this? I will try again about 12 hours from now. :-)

Just start a local mongo database. Look into the starting guides on the http://docs.parseplatform.org website

Might have a solution to this. We got the same error: Unable to ensure uniqueness for role name: MongoError: Index with name: name_1 already exists with different options when trying to start with our old DB from parse.com with parse-server 3.1.1.

The issue was that we had an index { "name": 1 } on _Role, but with sparse set to false. So we just deleted the index and parse-server created a new one (the same index, but with sparse set to true on start up.

I created a blank local database and started parse server connecting to the local database. It automatically creates the _User, _SCHEMA, _Role with indexes. This is the mongod log with schema and indexes details.

2018-11-09T06:35:53.161+0800 I COMMAND  [conn3327] command parse._SCHEMA command: insert { insert: "_SCHEMA", documents: [ { _id: "_User", objectId: "string", updatedAt: "date", createdAt: "date", username: "string", email: "string", emailVerified: "boolean", authData: "object" } ], ordered: true } ninserted:1 keyUpdates:0 writeConflicts:0 numYields:0 reslen:40 locks:{ Global: { acquireCount: { r: 2, w: 2 } }, Database: { acquireCount: { w: 1, W: 1 } }, Collection: { acquireCount: { W: 1 } } } protocol:op_query 124ms
2018-11-09T06:35:53.166+0800 I COMMAND  [conn3329] command parse._Hooks command: find { find: "_Hooks", filter: {}, sort: {}, projection: {}, returnKey: false, showRecordId: false } planSummary: EOF keysExamined:0 docsExamined:0 cursorExhausted:1 keyUpdates:0 writeConflicts:0 numYields:0 nreturned:0 reslen:118 locks:{ Global: { acquireCount: { r: 2 } }, Database: { acquireCount: { r: 1 }, acquireWaitCount: { r: 1 }, timeAcquiringMicros: { r: 109172 } }, Collection: { acquireCount: { r: 1 } } } protocol:op_query 109ms
2018-11-09T06:35:53.209+0800 I COMMAND  [conn3328] command parse._SCHEMA command: insert { insert: "_SCHEMA", documents: [ { _id: "_Role", objectId: "string", updatedAt: "date", createdAt: "date", name: "string", users: "relation<_User>", roles: "relation<_Role>" } ], ordered: true } ninserted:1 keyUpdates:0 writeConflicts:0 numYields:0 reslen:40 locks:{ Global: { acquireCount: { r: 1, w: 1 } }, Database: { acquireCount: { w: 1 }, acquireWaitCount: { w: 1 }, timeAcquiringMicros: { w: 121407 } }, Collection: { acquireCount: { w: 1 } } } protocol:op_query 173ms
2018-11-09T06:35:53.339+0800 I INDEX    [conn3329] build index on: parse._User properties: { v: 1, unique: true, key: { username: 1 }, name: "username_1", ns: "parse._User", background: true, sparse: true }
2018-11-09T06:35:53.389+0800 I INDEX    [conn3327] build index on: parse._User properties: { v: 1, unique: true, key: { email: 1 }, name: "email_1", ns: "parse._User", background: true, sparse: true }
2018-11-09T06:35:53.389+0800 I INDEX    [conn3329] build index done.  scanned 0 total records. 0 secs
2018-11-09T06:35:53.389+0800 I INDEX    [conn3327] build index done.  scanned 0 total records. 0 secs
2018-11-09T06:35:53.401+0800 I COMMAND  [conn3328] command parse._SCHEMA command: find { find: "_SCHEMA", filter: {}, returnKey: false, showRecordId: false } planSummary: COLLSCAN keysExamined:0 docsExamined:2 cursorExhausted:1 keyUpdates:0 writeConflicts:0 numYields:0 nreturned:2 reslen:445 locks:{ Global: { acquireCount: { r: 2 } }, Database: { acquireCount: { r: 1 }, acquireWaitCount: { r: 1 }, timeAcquiringMicros: { r: 176282 } }, Collection: { acquireCount: { r: 1 } } } protocol:op_query 188ms
2018-11-09T06:35:53.403+0800 I COMMAND  [conn3329] command parse.$cmd command: createIndexes { createIndexes: "_User", indexes: [ { name: "username_1", key: { username: 1 }, unique: true, background: true, sparse: true } ] } keyUpdates:0 writeConflicts:0 numYields:0 reslen:113 locks:{ Global: { acquireCount: { r: 1, w: 1 } }, Database: { acquireCount: { w: 1, W: 2 }, acquireWaitCount: { w: 1, W: 2 }, timeAcquiringMicros: { w: 48296, W: 48466 } }, Collection: { acquireCount: { w: 1 } } } protocol:op_query 231ms
2018-11-09T06:35:53.406+0800 I COMMAND  [conn3327] command parse.$cmd command: createIndexes { createIndexes: "_User", indexes: [ { name: "email_1", key: { email: 1 }, unique: true, background: true, sparse: true } ] } keyUpdates:0 writeConflicts:0 numYields:0 reslen:113 locks:{ Global: { acquireCount: { r: 1, w: 1 } }, Database: { acquireCount: { w: 1, W: 2 }, acquireWaitCount: { W: 2 }, timeAcquiringMicros: { W: 182237 } }, Collection: { acquireCount: { w: 1 } } } protocol:op_query 235ms
2018-11-09T06:35:53.584+0800 I INDEX    [conn3328] build index on: parse._Role properties: { v: 1, unique: true, key: { name: 1 }, name: "name_1", ns: "parse._Role", background: true, sparse: true }
2018-11-09T06:35:53.584+0800 I INDEX    [conn3328] build index done.  scanned 0 total records. 0 secs
2018-11-09T06:35:53.587+0800 I COMMAND  [conn3328] command parse.$cmd command: createIndexes { createIndexes: "_Role", indexes: [ { name: "name_1", key: { name: 1 }, unique: true, background: true, sparse: true } ] } keyUpdates:0 writeConflicts:0 numYields:0 reslen:113 locks:{ Global: { acquireCount: { r: 1, w: 1 } }, Database: { acquireCount: { w: 1, W: 2 }, acquireWaitCount: { W: 1 }, timeAcquiringMicros: { W: 1817 } }, Collection: { acquireCount: { w: 1 } } } protocol:op_query 179ms

Ok so the main issue is that now we create the indexes as unique + sparse, as you initially envisioned. Now I am not sure of the best resolution:

  • ignore the warning
  • delete and replace the index
  • create the new index under a different name (and then perhaps delete the existing one)

What do you think?

Is "sparse" is used when a field could be left as "undefined". Are these 3 fields optional?

If the "sparse" is required, I suggest to delete and replace the index upon parse-server start up. Does parse-server has sufficient right to drop index? We should not leave unused Index because indices took up precious disk space and cpu time.

Yeah, they do, temporarily, we could create the new one and replace the old one.

Is it something you’d like to implement?

The best way to give back when you receive a favour is to contribute code :-) However, I am not so sure at the moment. Let's me explore a bit further on parse-server codebase.

There is a workaround, and the setup is not completely broken. You could destroy your indexes and restart the server this would ‘just work’. But not as clean as doing a migration.

And as a long time user (as you said), it’s always good to have his hand dirty :)

It works.

I have dropped these indices and then new indices automatically created in next parse-server restart.

_User.email_1
_User.username_1
_Role.name_1

Recreated index on _User
{
"v": 2,
"unique": true,
"key": {
"email": 1
},
"name": "email_1",
"ns": "xxx._User",
"background": true,
"sparse": true
}

{
"v": 2,
"unique": true,
"key": {
"username": 1
},
"name": "username_1",
"ns": "xxx._User",
"background": true,
"sparse": true
}

Recreated index on _Role
{
"v": 2,
"unique": true,
"key": {
"name": 1
},
"name": "name_1",
"ns": "xxx._Role",
"background": true,
"sparse": true
}

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

I am a little late to this party and have just started upgrading from 3.0.0 to 3.1.x and have this issue. How do I go about fixing this issue?

@jc73300 did you try what @nebitrams suggested?

Sent with GitHawk

I am unsure how to do what he suggested.

@jc73300 did you try asking google how to drop an index on MongoDB?

Sent with GitHawk

You just need to delete the existing index, and restart the server, the new indexes will be created automatically. Alternatively, one could open a PR so we name the index so it lifts the conflict

Sent with GitHawk

Maybe the issue is something else. I have verified the indices are what they should be according to nebitrams. Every time I try to deploy 3.1.0 I get the following in my logs.

2019-02-03T20:36:28.475Z - Uncaught internal server error. TypeError: Cannot redefine property: _PushStatus
at Function.defineProperty ()
at SchemaData.volatileClasses.forEach.className (/var/app/current/node_modules/parse-server/lib/Controllers/SchemaController.js:530:14)
at Array.forEach ()
at new SchemaData (/var/app/current/node_modules/parse-server/lib/Controllers/SchemaController.js:529:21)
at getAllClasses.then.allSchemas (/var/app/current/node_modules/parse-server/lib/Controllers/SchemaController.js:654:27)
at
at process._tickDomainCallback (internal/process/next_tick.js:229:7) TypeError: Cannot redefine property: _PushStatus
at Function.defineProperty ()
at SchemaData.volatileClasses.forEach.className (/var/app/current/node_modules/parse-server/lib/Controllers/SchemaController.js:530:14)
at Array.forEach ()
at new SchemaData (/var/app/current/node_modules/parse-server/lib/Controllers/SchemaController.js:529:21)
at getAllClasses.then.allSchemas (/var/app/current/node_modules/parse-server/lib/Controllers/SchemaController.js:654:27)
at
at process._tickDomainCallback (internal/process/next_tick.js:229:7)
2019-02-03T20:36:03.702Z - Unable to ensure uniqueness for role name:
2019-02-03T20:36:03.700Z - Unable to ensure uniqueness for usernames:

That’s the same error, unable to ensure uniqueness for role and username, which means that you have an exiting index which is not correct, and that the server attempts to create new ones. What are the indices for _Role and _User?

Sent with GitHawk

This is from _User
{
"v": 2,
"key": {
"_id": 1
},
"name": "_id_",
"ns": "xxx._User"
}

{
"v": 2,
"unique": true,
"key": {
"email": 1
},
"name": "email_1",
"ns": "xxx._User",
"background": true,
"sparse": true
}

{
"v": 2,
"unique": true,
"key": {
"username": 1
},
"name": "username_1",
"ns": "xxx._User",
"background": true,
"sparse": true
}

This is from _Role

{
"v": 2,
"key": {
"_id": 1
},
"name": "_id_",
"ns": "xxx._Role"
}

{
"v": 2,
"unique": true,
"key": {
"name": 1
},
"name": "name_1",
"ns": "xxx._Role",
"background": true,
"sparse": true
}

Did you try dropping those indexes? Role name and User username and User email, then start a server with 3.1 on your local machine connected to the said DB?

Sent with GitHawk

I have only tried dropping them when running 3.0.0. Should I upgrade to 3.1.x first and then drop them?

Tried both ways and it just fails no matter what.

what bugs me is that the version 3.0.0 is also creating sparse indexes and your indices look right in the DB.

Would you have access to the mongodb logs, or runinng VERBOSE=1 with the version 3.1.0 and provide the full logs?

I turned on verbose, what do you need?

The logs on startup

Sent with GitHawk

Does this help?

2019-02-04T01:46:16.823Z - RESPONSE from [GET] /parse/serverInfo: {
"response": {
"features": {
"globalConfig": {
"create": true,
"read": true,
"update": true,
"delete": true
},
"hooks": {
"create": true,
"read": true,
"update": true,
"delete": true
},
"cloudCode": {
"jobs": true
},
"logs": {
"level": true,
"size": true,
"order": true,
"until": true,
"from": true
},
"push": {
"immediatePush": true,
"scheduledPush": false,
"storedPushData": true,
"pushAudiences": true,
"localization": true
},
"schemas": {
"addField": true,
"removeField": true,
"addClass": true,
"removeClass": true,
"clearAllDataFromClass": true,
"exportClass": false,
"editClassLevelPermissions": true,
"editPointerPermissions": true
}
},
"parseServerVersion": "3.1.0"
}
}
2019-02-04T01:46:16.812Z - REQUEST for [GET] /parse/serverInfo: {}
2019-02-04T01:45:55.501Z - Unable to ensure uniqueness for role name:
2019-02-04T01:45:55.498Z - Unable to ensure uniqueness for usernames:

Stupid question, can I just copy _Installations and any of my own tables to a new clean db or will it break everything?

What I am looking for is the actual error. As for why the index creation failed. Can you check the MongoDB logs?

Sent with GitHawk

I don't have access to them.

Well, that’s problematic. I’m not sure I can be of further help. Without the exact error, I am not sure what can be done

Sent with GitHawk

Ok no worries. I will just live on 3.0.0 until it dies.

There should be additional info when you start your server locally with 3.1.0

For example:

warn: Unable to ensure uniqueness for usernames:  MongoError: Index with name: username_1 already exists with different options
    at /Users/florent/src/Parse/parse-server/node_modules/mongodb-core/lib/connection/pool.js:581:63
    at authenticateStragglers (/Users/florent/src/Parse/parse-server/node_modules/mongodb-core/lib/connection/pool.js:504:16)
    at Connection.messageHandler (/Users/florent/src/Parse/parse-server/node_modules/mongodb-core/lib/connection/pool.js:540:5)
    at emitMessageHandler (/Users/florent/src/Parse/parse-server/node_modules/mongodb-core/lib/connection/connection.js:310:10)
    at Socket.<anonymous> (/Users/florent/src/Parse/parse-server/node_modules/mongodb-core/lib/connection/connection.js:453:17)
    at Socket.emit (events.js:182:13)
    at Socket.EventEmitter.emit (domain.js:441:20)
    at addChunk (_stream_readable.js:283:12)
    at readableAddChunk (_stream_readable.js:264:11)
    at Socket.Readable.push (_stream_readable.js:219:10)
(node:28426) UnhandledPromiseRejectionWarning: MongoError: Index with name: username_1 already exists with different options
    at /Users/florent/src/Parse/parse-server/node_modules/mongodb-core/lib/connection/pool.js:581:63
    at authenticateStragglers (/Users/florent/src/Parse/parse-server/node_modules/mongodb-core/lib/connection/pool.js:504:16)
    at Connection.messageHandler (/Users/florent/src/Parse/parse-server/node_modules/mongodb-core/lib/connection/pool.js:540:5)
    at emitMessageHandler (/Users/florent/src/Parse/parse-server/node_modules/mongodb-core/lib/connection/connection.js:310:10)
    at Socket.<anonymous> (/Users/florent/src/Parse/parse-server/node_modules/mongodb-core/lib/connection/connection.js:453:17)
    at Socket.emit (events.js:182:13)
    at Socket.EventEmitter.emit (domain.js:441:20)
    at addChunk (_stream_readable.js:283:12)
    at readableAddChunk (_stream_readable.js:264:11)
    at Socket.Readable.push (_stream_readable.js:219:10)

don't you have those?

Ok no worries. I will just live on 3.0.0 until it dies.

I'm not sure why I spent a good amount of my sunday evening trying to help you then.

I definitely appreciate the help you gave me I just don't know what else to do and since I cannot give you the logs you requested there isn't much else that can be done.

But for one, what is the error that goes after unable to ensure uniqueness for usernames:

Sent with GitHawk

Just wanted to let you know @flovilmart . I ended up exporting the relevant tables with data into a new clean db and all is working great now. I updated all the way to the current 3.1.3. Thanks again for all your help.

@flovilmart I believe I had a similar problem to @jc73300. I tested all parse-server versions greater than 3.0.0 and consistently ran into this problem. I do not experience this problem with 3.0.0. I am using Postgres, for what it's worth.

2019-02-09T18:33:48.106800+00:00 app[web.1]: TypeError: Cannot redefine property: _Installation
2019-02-09T18:33:48.106803+00:00 app[web.1]: at Function.defineProperty ()
2019-02-09T18:33:48.106805+00:00 app[web.1]: at SchemaData.allSchemas.forEach.schema (/app/node_modules/parse-server/lib/Controllers/SchemaController.js:514:14)
2019-02-09T18:33:48.106806+00:00 app[web.1]: at Array.forEach ()
2019-02-09T18:33:48.106808+00:00 app[web.1]: at new SchemaData (/app/node_modules/parse-server/lib/Controllers/SchemaController.js:513:16)
2019-02-09T18:33:48.106810+00:00 app[web.1]: at getAllClasses.then.allSchemas (/app/node_modules/parse-server/lib/Controllers/SchemaController.js:654:27)
2019-02-09T18:33:48.106811+00:00 app[web.1]: at processTicksAndRejections (internal/process/next_tick.js:81:5)

Can you share your schema please?

Sent with GitHawk

It’s not what I meant, I meant the contents of the _SCHEMA table

Sent with GitHawk

create table "_SCHEMA"
(
"className" varchar(120) default NULL::character varying not null,
schema jsonb,
"isParseClass" boolean
);

INSERT INTO public."_SCHEMA" ("className", schema) VALUES ('_Installation', '{"fields": {"id": {"type": "String"}, "user": {"type": "Pointer", "targetClass": "_User"}, "badge": {"type": "Number"}, "_rperm": {"type": "Array", "contents": {"type": "String"}}, "_wperm": {"type": "Array", "contents": {"type": "String"}}, "appName": {"type": "String"}, "channels": {"type": "Array"}, "objectId": {"type": "String"}, "pushType": {"type": "String"}, "timeZone": {"type": "String"}, "createdAt": {"type": "Date"}, "updatedAt": {"type": "Date"}, "appVersion": {"type": "String"}, "deviceType": {"type": "String"}, "GCMSenderId": {"type": "String"}, "deviceToken": {"type": "String"}, "parseVersion": {"type": "String"}, "appIdentifier": {"type": "String"}, "installationId": {"type": "String"}, "localeIdentifier": {"type": "String"}}, "className": "_Installation"}');

Ok. I believe I know what’s going on, but I am not sure how the _Installation schema is appearing twice. Would you be able to insert a console.log to print the contents of the allClasses array?

Sent with GitHawk

Might have a solution to this. We got the same error: Unable to ensure uniqueness for role name: MongoError: Index with name: name_1 already exists with different options when trying to start with our old DB from parse.com with parse-server 3.1.1.

The issue was that we had an index { "name": 1 } on _Role, but with sparse set to false. So we just deleted the index and parse-server created a new one (the same index, but with sparse set to true on start up.

@johanarnor Does dropping the index delete the contents in that column? I need the usernames & emails of _User

@acegreen Nope, the data stays safe, we just deleted the index in mongodb. We're using mLab, so it was just a few clicks in the GUI. I guess they run dropIndex.

I was able to dropIndexes for _Role name and _User username but dropping _User email doesn't resolve the last warning I have

@acegreen
What is the last warning that you mentioned?

For me, 3 warnings of these nature were gone.

warn: Unable to ensure uniqueness for usernames: MongoError: Index with name: username_1 already exists with different options

exactly those, the last one was the email which i dropped as well but the warning won't go away. For some reason my warning is truncated so I don't actually see the index name

@acegreen I have the same issue, did you solve it?

I have had the same issue.
Thanks to @johanarnor advice, it was finally fixed after I manually drop indices "email_1" and "username_1" on the _User table and "name_1" on the _Role table. Check the log and identify those indices that threw errors and then drop them. I did it from MongoDB Atlas web console.
I am with a couple of MongoDB database recently migrated from mLab to MongoDB Atlas due to mandatory migration requirement. Those indices were created during the migration process but they failed deployment of Parse-server on version 3.9.0 (latest as of today). It was fine with 2.8.4 before migrating.

exactly those, the last one was the email which i dropped as well but the warning won't go away. For some reason my warning is truncated so I don't actually see the index name

@acegreen I did dropIndex on those ones that threw errors from the log. Then re-deployed Parse-server the warnings were gone. I am with MongoDB 4.0.0 on MongoDB Atlas and Parse-server 3.9.0.

run into the same issues:

Resolve this with Mongo Shell

db.getCollection("_User").dropIndex("email_1")
db.getCollection("_User").dropIndex("username_1")
db.getCollection("_Role").dropIndex("name_1")
Was this page helpful?
0 / 5 - 0 ratings