2

Something strange is happening with my app, I am using SailsJs with official PostgreSQL driver and my data gets deleted. I don't have any pattern or list of specific events which deletes the data but I have following observations.

  • Few days back i was writing a function to destroy data and when I executed that function it gave me an error I fixed the error and ran my web app again and whoa data from one of my table was all gone.
  • Yesterday i wrote a function and I tried to get the HTTP call to that function but it was giving me 500 server error, I started debugging it and after executing my program 3 to 4 times with this error partial data was deleted from one of my database table. Later the error was i had a typo in URL.

If any of you guys had any experience with what is happening to me please let me know how to fix it? or at least help me on how to reproduce this issue ?

EDIT

I activated the logs and was waiting for it to happen again and it happened again and here is the log from sailsjs

enter image description here

enter image description here

In the logs I saw that its talking about alter.js sync strategy but i have selected it to be the safe strategy

enter image description here

Naveed Ahmad
  • 314
  • 6
  • 18

1 Answers1

0

It has happened to me quite a few times, when lifting the app and it is in the process of making changes to the db and it fails, sometimes due to ORM timeout.

What sails do when its lifting and needs to update the data structure is controlled in config/models.js migrate: 'alter', usually commented out, you get a prompt for what to do 1... 2... 3... (writing from the top of my head, i dont remember the actual messages) and a warning about using alter on a production system.

Changing config/orm.js to have this

    // config/orm.js
module.exports.orm = {
    _hookTimeout: 60000 // I used 60 seconds as my new timeout
};

And for reasons I don't know changing config/pubsub.js

// config/pubsub.js
module.exports.pubsub = {
    _hookTimeout: 60000 // I used 60 seconds as my new timeout
};

has helped me, avoid data loss.

ngeosone
  • 26
  • 3