Skip to content

There are a lot of logs as CREATE TABLE IF NOT EXISTS "_SCHEMA" #7021

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
4 tasks done
JeffGuKang opened this issue Nov 24, 2020 · 4 comments · Fixed by #7255
Closed
4 tasks done

There are a lot of logs as CREATE TABLE IF NOT EXISTS "_SCHEMA" #7021

JeffGuKang opened this issue Nov 24, 2020 · 4 comments · Fixed by #7255

Comments

@JeffGuKang
Copy link
Contributor

JeffGuKang commented Nov 24, 2020

New Issue Checklist

Issue Description

There are a lot of log as CREATE TABLE IF NOT EXISTS "_SCHEMA" ( "className" varChar(120), "schema" jsonb, "isParseClass" bool, PRIMARY KEY ("className") )

And My DB connection pool is higher at the time.

I am not sure it makes some problem to the DB
or
the logs are made a lot when DB connection has a problem.

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

image

I found some related query in PostgreAdopter:

async _ensureSchemaCollectionExists(conn: any) {
conn = conn || this._client;
await conn
.none(
'CREATE TABLE IF NOT EXISTS "_SCHEMA" ( "className" varChar(120), "schema" jsonb, "isParseClass" bool, PRIMARY KEY ("className") )'
)
.catch(error => {
if (
error.code === PostgresDuplicateRelationError ||
error.code === PostgresUniqueIndexViolationError ||
error.code === PostgresDuplicateObjectError
) {
// Table already exists, must have been created by a different request. Ignore error.
} else {
throw error;
}
});
}

Steps to reproduce

  1. Checking postgreSQL logs on the RDS.

  2. The log is shown around every 30 secs

  3. But sometimes there are too many logs when backend server requests a lot.

Actual Outcome

Expected Outcome

Environment

This is my Parse config.

const parseConfig = {
  cloud: __dirname + '/src/cloud/', // location after tsc
  appId: process.env.APP_ID,
  masterKey: process.env.MASTER_KEY,
  fileKey: process.env.FILE_KEY,
  serverURL: 'http://localhost:1337/parse', 
  auth: {
    kakao: kakaoAuthAdapter,
    apple: {
      client_id: process.env.APPLE_SIGNIN_CLIENT_ID, // optional (for extra validation), use the Service ID from Apple.
    },
  },
  maxUploadSize: '5mb',
  logLevel: process.env.NODE_ENV !== 'development' ? 'warn' : undefined,
  schemaCacheTTL: 1000 * 60 * 60 * 24 * 15, // 15 days
  cacheTTL: 1000 * 60 * 60 * 24 * 15, // 15 days
  allowClientClassCreation: false,
  enableSingleSchemaCache: true,
  enableExpressErrorHandler: false,
}

  const redisOptions = {url: 'redis://' + process.env.REDIS_CACHE_URL}
  const redisCache = new RedisCacheAdapter(redisOptions)

  parseConfig.cacheAdapter = redisCache

Server

  • Parse Server version: 4.4.0
  • Operating system: FILL_THIS_OUT
  • Local or remote host : AWS scalable server (EC2)

Database

  • System (MongoDB or Postgres): Postgres
  • Database version: 11+
  • Local or remote host: AWS Aurora postgres

Client

  • SDK (iOS, Android, JavaScript, PHP, Unity, etc): iOS, Android
  • SDK version: FILL_THIS_OUT

Logs

@JeffGuKang JeffGuKang changed the title There are a lot of log as CREATE TABLE IF NOT EXISTS "_SCHEMA" There are a lot of logs as CREATE TABLE IF NOT EXISTS "_SCHEMA" Nov 24, 2020
@mtrezza
Copy link
Member

mtrezza commented Nov 24, 2020

Thanks for reporting.

This may be related to #6193 and #6743.

Can you be more specific about what causes the calls to _ensureSchemaCollectionExists? In the source code there are some references that call this method, so depending on the operations you perform, these calls may be expected.

@JeffGuKang
Copy link
Contributor Author

Postgre RDS <-------------> multiple EC2 instances
                      <--> Redis  <->

And it was caused when traffic increased. I will check the logs what is calling _ensureSchemaCollectionExists.

@dplewis
Copy link
Member

dplewis commented Dec 15, 2020

_ensureSchemaCollectionExists Is called for every request to Postgres for some reason. I’m working on schema improvements right now. I can look into this

@mtrezza
Copy link
Member

mtrezza commented Feb 16, 2021

Seems related to #6743 and #6636.

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

Successfully merging a pull request may close this issue.

3 participants