YouHusam / hanx.js

Full-stack Javascript boilerplate with NodeJS, HapiJS, PostgreSQL and AngularJS
Other
23 stars 5 forks source link

Reduce connection pool to 1 connection (fix for #5, #6) #7

Closed ihorskyi closed 8 years ago

ihorskyi commented 8 years ago

According to postgres adapter for sails https://github.com/balderdashy/sails-postgresql pollSize by default is 10 which is more then allowed by default configurations for postgres on lot of regular users laptops. Having just 1 connection is enough for hanx.js to work and that also fixes #5, #6 issues

YouHusam commented 8 years ago

Can you explain how this fixes issues #5 and #6?

YouHusam commented 8 years ago

I added the pollsize to config

ihorskyi commented 8 years ago

Can you explain how this fixes issues #5 and #6?

Of course, but first let me tell you that the way you made changes in your commit c5218b145982aacb34f373f4c826e1ff2a73bc85 won't fix anything because you copied misspelled word pollSize from my comment instead of committing PR with correct and working param poolSize that actually did fix issue :)

Another thing - there is no need in pool of connections because 1 connection is enough for whole hanx.js app. It is not Java with multithreading - it is JS with one thread per app. So you don't need config for that.

How my PR fixes #5 and #6 - I had the same issues while installing hanx.js. I have max 5 connections in PostgreSQL 9.2 (as lot of other people that would or already tried hanx.js) on local machine, so when app was bootstrapping with 10 connections it did not create whole DB structure completely and table user was not created. System did not say what was the actual problem - instead there was lot of debug text with few stack traces (same as error in #6).

So I did stop app and tried again - next time I had almost the same error but a bit less stack trace. I dropped db, recreated it again and ran hanx.js one more time. This time table user was created :) But when I tried to signup I had the same error as in #5.

After detailed review of error and postgres adapter docs I found the cause. I dropped db, recreated it, set poolSize to 1 and everything went smoothly this time from bootstrapping to signup/login/creating articles, etc... not more errors.

That's why I said my PR fixes those both issues.

YouHusam commented 8 years ago

Ah thanks, also thanks for pointing out the typo. I'll fix it in my next commit