Skip to content

SchemaCache dosen't work #6473

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

Closed
JeffGuKang opened this issue Mar 6, 2020 · 6 comments
Closed

SchemaCache dosen't work #6473

JeffGuKang opened this issue Mar 6, 2020 · 6 comments

Comments

@JeffGuKang
Copy link
Contributor

JeffGuKang commented Mar 6, 2020

Issue Description

CREATE TABLE IF NOT EXISTS "_SCHEMA" ( "className" varChar(120), "schema" jsonb, "isParseClass" bool, PRIMARY KEY ("className") )

called continually. with SELECT * FROM "_SCHEMA"

image

And DB Connection increased also.

I found this query from the parse server source

I am not sure why this happens and what is wrong with my code. So I shared my issue.

Query log

...
2020-03-07 09:55:08.372 KST [40465] LOG:  duration: 0.151 ms  statement: SELECT * FROM "_SCHEMA"
2020-03-07 09:55:08.373 KST [40465] LOG:  duration: 0.184 ms  statement: SELECT * FROM "Info" WHERE "objectId" = 'Ap9l9l0enC' AND ("_rperm" IS NULL OR "_rperm" && ARRAY['*','*','xO7kxBDsZO'])   
2020-03-07 09:55:08.374 KST [40465] LOG:  duration: 0.040 ms  statement: CREATE TABLE IF NOT EXISTS "_SCHEMA" ( "className" varChar(120), "schema" jsonb, "isParseClass" bool, PRIMARY KEY ("className") )
2020-03-07 09:55:08.375 KST [40465] LOG:  duration: 0.140 ms  statement: SELECT * FROM "_SCHEMA"
2020-03-07 09:55:08.376 KST [40465] LOG:  duration: 0.092 ms  statement: SELECT * FROM "Info" WHERE "objectId" = 'Ap9l9l0enC'   
2020-03-07 09:55:08.380 KST [40465] LOG:  duration: 0.068 ms  statement: CREATE TABLE IF NOT EXISTS "_SCHEMA" ( "className" varChar(120), "schema" jsonb, "isParseClass" bool, PRIMARY KEY ("className") )
2020-03-07 09:55:08.381 KST [40465] LOG:  duration: 0.158 ms  statement: SELECT * FROM "_SCHEMA"
2020-03-07 09:55:08.382 KST [40465] LOG:  duration: 0.103 ms  statement: SELECT * FROM "Photo" WHERE "objectId" = 'eGvqdUDF7h'   
...

Steps to reproduce

PostgreSQL RDS <=> EC2 Parse Server with LiveQuery
Redis <=>

I am using Parse.Object.registerSubclass Parse Classes as below.

interface PetParams {
...
}

export class Pet extends Parse.Object<PetParams> {
  constructor(params?: PetParams) {
    super('Pet', params) 
  }

  deleteSelf = (id, options: Parse.Object.DestroyOptions) => {
    this.id = id

    return this.destroy(options)
  }
}

Expected Results

Do not call SELECT * FROM "_SCHEMA" query continually

Actual Outcome

Environment Setup

  • Server

    • parse-server version (Be specific! Don't say 'latest'.) : [4.0.1]
    • Operating System: [Node.js running on 64bit Amazon Linux/4.13.0]
    • Hardware: []
    • Localhost or remote server? (AWS, Heroku, Azure, Digital Ocean, etc): [AWS]
  • Database

    • PostgreSQL version: [11.4 ~ 11.5]
    • Storage engine: [RDS, Redis]
    • Hardware: []
    • Localhost or remote server? (AWS): [AWS]

Logs/Trace

No Parse log

@dplewis
Copy link
Member

dplewis commented Mar 6, 2020

Is burst a keyword in postgres? Can you provide a link?

@JeffGuKang JeffGuKang changed the title Burst SELECT * FROM "_SCHEMA" query Call SELECT * FROM "_SCHEMA" query continually Mar 6, 2020
@JeffGuKang
Copy link
Contributor Author

JeffGuKang commented Mar 6, 2020

Is burst a keyword in postgres? Can you provide a link?

Sorry. I changed the title and updated query log.

@JeffGuKang
Copy link
Contributor Author

JeffGuKang commented Mar 7, 2020

getAllClasses function is called again and again.

  async getAllClasses() {
    const self = this;
    return this._client.task('get-all-classes', async t => {
      await self._ensureSchemaCollectionExists(t);
      return await t.map('SELECT * FROM "_SCHEMA"', null, row => toParseSchema(_objectSpread({
        className: row.className
      }, row.schema)));
    });
  } // Return a promise for the schema with the given name, in Parse format. If
  // this adapter doesn't know about the schema, return a promise that rejects with
  // undefined as the reason.

I think caching has a problem.

@JeffGuKang JeffGuKang changed the title Call SELECT * FROM "_SCHEMA" query continually Cache dosen't work Mar 7, 2020
@JeffGuKang
Copy link
Contributor Author

enableSingleSchemaCache: true option can solve this problem. thanks @yomybaby.
But why the options' default is false? It makes a lot of useless query.

@JeffGuKang
Copy link
Contributor Author

Refer #6476

@JeffGuKang JeffGuKang changed the title Cache dosen't work SchemaCache dosen't work Mar 7, 2020
@JeromeDeLeon
Copy link
Contributor

JeromeDeLeon commented May 10, 2020

Although this was closed, if you look at the #5612 , @dplewis stated that it should be true by default but few tests failed and he will do a separate PR for it.

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

No branches or pull requests

3 participants