Skip to content

TypeError: Object [object Object] has no method 'release' #109

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
elhoyos opened this issue Sep 24, 2015 · 11 comments · Fixed by #197
Closed

TypeError: Object [object Object] has no method 'release' #109

elhoyos opened this issue Sep 24, 2015 · 11 comments · Fixed by #197
Assignees
Labels

Comments

@elhoyos
Copy link

elhoyos commented Sep 24, 2015

I'm having this error when issuing a SELECT and then doing a #rollback to close the transaction without actually doing other operation.

2015-09-24T18:31:11.750Z pid:2371 worker:36 Thu, 24 Sep 2015 18:31:11 GMT loopback:connector:postgresql SQL: SELECT "field","id" FROM "schema"."table" WHERE "field"=$1 ORDER BY "id"
2015-09-24T18:31:11.750Z pid:2371 worker:36 Parameters: ["foo"]
2015-09-24T18:31:11.750Z pid:2371 worker:36 Thu, 24 Sep 2015 18:31:11 GMT loopback:connector:postgresql Execute SQL within a transaction
2015-09-24T18:31:11.752Z pid:2371 worker:36 events.js:72
2015-09-24T18:31:11.752Z pid:2371 worker:36         throw er; // Unhandled 'error' event
2015-09-24T18:31:11.752Z pid:2371 worker:36               ^
2015-09-24T18:31:11.754Z pid:2371 worker:36 TypeError: Object [object Object] has no method 'release'
2015-09-24T18:31:11.754Z pid:2371 worker:36     at PostgreSQL.releaseConnection (/home/myapp/node_modules/loopback-connector-postgresql/lib/transaction.js:70:14)
2015-09-24T18:31:11.754Z pid:2371 worker:36     at null.<anonymous> (/home/myapp/node_modules/loopback-connector-postgresql/lib/transaction.js:56:12)
2015-09-24T18:31:11.755Z pid:2371 worker:36     at Object.forward (/home/ubuntu/.nvm/v0.10.38/lib/node_modules/strongloop/node_modules/strong-agent/lib/proxy.js:79:23)
2015-09-24T18:31:11.755Z pid:2371 worker:36     at eval (eval at wrap (/home/ubuntu/.nvm/v0.10.38/lib/node_modules/strongloop/node_modules/strong-agent/lib/proxy.js:193:20), <anonymous>:3:21)
2015-09-24T18:31:11.755Z pid:2371 worker:36     at null.<anonymous> (/home/myapp/node_modules/loopback/node_modules/continuation-local-storage/context.js:74:17)
2015-09-24T18:31:11.755Z pid:2371 worker:36     at b [as callback] (domain.js:183:18)
2015-09-24T18:31:11.755Z pid:2371 worker:36     at Query.handleReadyForQuery (/home/myapp/node_modules/loopback-connector-postgresql/node_modules/pg/lib/query.js:89:10)
2015-09-24T18:31:11.755Z pid:2371 worker:36     at null.<anonymous> (/home/myapp/node_modules/loopback-connector-postgresql/node_modules/pg/lib/client.js:163:19)
2015-09-24T18:31:11.755Z pid:2371 worker:36     at emit (events.js:117:20)
2015-09-24T18:31:11.755Z pid:2371 worker:36     at Socket.<anonymous> (/home/myapp/node_modules/loopback-connector-postgresql/node_modules/pg/lib/connection.js:109:12)

Please notice this is only happening in production having the same modules version as in development:

npm list loopback loopback-datasource-juggler loopback-connector-postgresql
├── [email protected]
├── [email protected]
└── [email protected]
@raymondfeng
Copy link
Contributor

Which version of pg do you have? Can you check if loopback-connector-postgresql/node_modules/pg/lib/pool.js has the release method?

@elhoyos
Copy link
Author

elhoyos commented Sep 24, 2015

Running on [email protected]

Here's a strange output:

$ npm list pg
└─┬ [email protected] invalid
  └── [email protected]

And nope, pool.js does not have the mentioned method.

@elhoyos
Copy link
Author

elhoyos commented Sep 24, 2015

The package.json of [email protected] says "pg": "^4.2.0" and [email protected] looks valid for me.

@elhoyos
Copy link
Author

elhoyos commented Sep 24, 2015

Please ignore the strange "invalid" output. I was doing it from a different project. The one having the TypeError issue looks the same but without the "invalid" string.

@bajtos
Copy link
Member

bajtos commented Oct 22, 2015

@elhoyos could you please create a sample project that we can use to reproduce the problem locally on our machine? See wiki instructions.

@bajtos bajtos added triaging and removed #tob labels Oct 22, 2015
@timneedham
Copy link

Hi,

I think this may be a major issue with the latest loopback-connector-postgres?

loopback-connector:            2.3.0
loopback-connector-postgresql: 2.3.0
loopback-datasource-juggler:   2.45.2
pg:                            4.5.2
generic-pool:                  2.1.1

For me: running >8 concurrent transactions via loopback-connector-postgresql throws TypeError: pool.release is not a function.

As requested, @bajtos: I've created a sample project here with steps to reproduce locally.

  • @raymondfeng My concern is that under heavy load (using transactions), Loopback will currently fail when using Postgres?

@Elindorath
Copy link

I can confirm, Loopback is not suitable for production use with Postgres ...

@raymondfeng
Copy link
Contributor

See #143

@Elindorath
Copy link

Elindorath commented Jun 22, 2016

Glad to hear that! I'll test it as from tomorrow. Thanks a lot for the quick solution!

@timneedham
Copy link

Great news!

robinbiondi added a commit to robinbiondi/loopback-connector-postgresql that referenced this issue Jun 24, 2016
When running more than 9 transactions at the same time, we get an error: "pool.release is not a function". at line 74 inlib/transaction.js.
I found out that this.pg is returning an EvenEmitter, containing a pool which contains the function release.
Finally, when I call pool.pool.release instead of pool.release, everything works fine and the connection are released on my pg database.
This modification fixes the issue loopbackio#109.
@robinbiondi
Copy link

robinbiondi commented Jun 24, 2016

Hello, It seems that the upgrade of pg was not fixing this issue. Still have the pool.release is not a function.
I made a PR that fixes my issue. PR #146

robinbiondi added a commit to robinbiondi/loopback-connector-postgresql that referenced this issue Jun 27, 2016
peterliapin pushed a commit to wavepointcode/loopback-connector-postgresql that referenced this issue Jul 21, 2016
rkmax added a commit to bixlabs/loopback-connector-postgresql that referenced this issue Aug 19, 2016
rkmax added a commit to bixlabs/loopback-connector-postgresql that referenced this issue Aug 19, 2016
rkmax added a commit to bixlabs/loopback-connector-postgresql that referenced this issue Aug 19, 2016
Revert "Fix loopbackio#109 bug transaction concurrency."
@deepakrkris deepakrkris self-assigned this Oct 10, 2016
zbarbuto added a commit to NextFaze/loopback-connector-postgresql that referenced this issue Jan 10, 2017
@zbarbuto zbarbuto mentioned this issue Jan 10, 2017
1 task
zbarbuto added a commit to zbarbuto/loopback-connector-postgresql that referenced this issue Jan 10, 2017
zbarbuto added a commit to zbarbuto/loopback-connector-postgresql that referenced this issue Jan 10, 2017
@zbarbuto zbarbuto mentioned this issue Jan 10, 2017
2 tasks
cadesalaberry pushed a commit to robinbiondi/loopback-connector-postgresql that referenced this issue Jan 18, 2017
zbarbuto added a commit to zbarbuto/loopback-connector-postgresql that referenced this issue Feb 16, 2017
zbarbuto added a commit to zbarbuto/loopback-connector-postgresql that referenced this issue Feb 16, 2017
zbarbuto added a commit to zbarbuto/loopback-connector-postgresql that referenced this issue Feb 17, 2017
zbarbuto added a commit to zbarbuto/loopback-connector-postgresql that referenced this issue Feb 17, 2017
zbarbuto added a commit to zbarbuto/loopback-connector-postgresql that referenced this issue Feb 21, 2017
zbarbuto added a commit to zbarbuto/loopback-connector-postgresql that referenced this issue Feb 21, 2017
jannyHou pushed a commit that referenced this issue Feb 21, 2017
rmg pushed a commit that referenced this issue Feb 24, 2017
 * Add test for bulk transactions (Zak Barbuto)
 * Use pg callback over connection.release (#109) (Zak Barbuto)
 * Use pool.pool.release over pool.release (#109) (Zak Barbuto)
 * Add test env information to README (Zak Barbuto)
 * update README for local postgres setup (Diana Lau)
 * Update postgresql.js (tmclouisluk)
 * Fix bug when using postgresql 8.x (tmclouisluk)
 * Use unique param for affectedRows (Loay)
 * Move info from docs into README (#199) (Rand McKinney)
 * Update paid support URL (Siddhi Pai)
 * Revert loopback 2.x (siddhipai)
 * Revert dev-dependency on loopback to 2.x (Siddhi Pai)
 * Set publish tag to "lts" (Siddhi Pai)
 * Update README with correct doc links, etc (Amir Jafarian)
kjdelisle pushed a commit that referenced this issue Mar 31, 2017
 * Remove console.log (Raymond Feng)
 * Monkey patch generic-pool to work through errors (Russ Tyndall)
 * Fix the escape char (Raymond Feng)
 * Upgrade to [email protected] (Loay)
 * Add checkFieldAndIndex for table status (#228) (Sakib Hasan)
 * Refactor migration methods (ssh24)
 * Fix code style inconsistencies in ilike tests (Alireza Ahmadi)
 * Improve tests for better code style consistency (Alireza Ahmadi)
 * Add tests for pattern matching operators (Alireza Ahmadi)
 * Add ILIKE functionality (Alireza Ahmadi)
 * Refactor discovery models (Loay Gewily)
 * merge in #216 (gregdingle)
 * Fix unit tests (ssh24)
 * Fix linting errors and unnesssary changes. (Diana Lau)
 * remove done() calls in test (gregdingle)
 * Added test. Ran run-tests. (gregdingle)
 * Fix bug where settings for pg-pool were dropped (Greg Dingle)
 * Update README with correct doc links, etc (Amir Jafarian)
 * Add test for bulk transactions (Zak Barbuto)
 * Use pg callback over connection.release (#109) (Zak Barbuto)
 * Use pool.pool.release over pool.release (#109) (Zak Barbuto)
 * Add test env information to README (Zak Barbuto)
 * update README for local postgres setup (Diana Lau)
 * Update postgresql.js (tmclouisluk)
 * Fix bug when using postgresql 8.x (tmclouisluk)
 * Replicate new issue_template from loopback (Siddhi Pai)
 * Replicate issue_template from loopback repo (Siddhi Pai)
 * Update LB connector version (Loay)
 * Use unique param for affectedRows (Loay)
 * Move info from docs into README (#199) (Rand McKinney)
 * Update paid support URL (Siddhi Pai)
 * Start 3.x + drop support for Node v0.10/v0.12 (siddhipai)
 * Drop support for Node v0.10 and v0.12 (Siddhi Pai)
 * Start the development of the next major version (Siddhi Pai)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

10 participants