Skip to content

fix(postgres/conectionmanager): Don't leak OIDs between instances - #9025

Merged
janmeier merged 1 commit into
sequelize:v3from
janmeier:v3
Feb 9, 2018
Merged

janmeier merged 1 commit into
sequelize:v3from
janmeier:v3

Conversation

@janmeier

@janmeier janmeier commented Feb 9, 2018

Copy link
Copy Markdown
Member

This problem happens under the following circumstances:

  • Several sequelize instances, connecting to different databases.
  • Each database contains some custom enum types, with overlapping OIDs (so databaseB has typeA with oid X, while databaseB has typeB, also with oid X)

Since the two sequelize instances share the same copy of the pg lib, they will overwrite each others' type parsers. This is especially appearent when the datatype in one db is an array, and the other is not - So suddenly what you expect to be a string is now an array.

I've fixed this by keeping a local copy of the oids on the connection manager and setting the type parser on the pg client instance, instead of mutating the pg-types object.

Tested on snaplytics, where it fixed the bug that suddenly an enum type became an array.

@sushantdhiman sushantdhiman left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oid for these dynamic objects can be different for different database instances so this was always a possibility

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 this pull request may close these issues.

3 participants