jywarren / plots2

The Public Lab website!
http://publiclab.org
GNU General Public License v3.0
17 stars 2 forks source link

failed note posting validation leaves db traces and breaks the site :-( #106

Closed jywarren closed 10 years ago

jywarren commented 11 years ago

Caveat -- this is only if there is some bug in new code which causes note posting to fail... but still bad. It's unclear to me how this happens, given that the whole thing is wrapped in a transaction:

  (0.3ms)  BEGIN
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE `users`.`uid` = 1 LIMIT 1
  CACHE (0.0ms)  SELECT `url_alias`.* FROM `url_alias` WHERE `url_alias`.`dst` = 'notes/warren/04-17-2013/test-email-subscription' LIMIT 1
  SQL (6.4ms)  INSERT INTO `node` (`cached_likes`, `changed`, `comment`, `created`, `language`, `moderate`, `promote`, `status`, `sticky`, `title`, `tnid`, `translate`, `type`, `uid`, `vid`) VALUES (0, 1366226612, 2, 0, '', 0, 0, 1, 0, 'Test email subscription', 0, 0, 'note', 1, 0)
   (6.3ms)  UPDATE `node` SET `uid` = 1, `title` = 'Test email subscription', `comment` = 2, `type` = 'note', `changed` = 1366226612, `created` = 1366226612 WHERE `node`.`nid` = 6485
  DrupalUsers Load (1.4ms)  SELECT `users`.* FROM `users` WHERE `users`.`uid` = 1 LIMIT 1
  User Load (6.1ms)  SELECT `rusers`.* FROM `rusers` WHERE `rusers`.`username` = 'warren' LIMIT 1
  CACHE (0.0ms)  SELECT `users`.* FROM `users` WHERE `users`.`uid` = 1 LIMIT 1
  SQL (34.6ms)  INSERT INTO `url_alias` (`dst`, `language`, `src`) VALUES ('notes/warren/04-17-2013/test-email-subscription', '', 'node/6485')
  SQL (1.9ms)  INSERT INTO `node_counter` (`daycount`, `nid`, `timestamp`, `totalcount`) VALUES (0, 6485, 0, 0)
   (1.1ms)  ROLLBACK
Completed 500 Internal Server Error in 4508ms

NoMethodError (undefined method `find_by_drupal_node' for #<Class:0xb352158>):
  app/mailers/subscription_mailer.rb:33:in `get_node_tags'
  app/mailers/subscription_mailer.rb:42:in `get_tag_subscribers'
  app/mailers/subscription_mailer.rb:8:in `notify_node_creation'
  app/models/drupal_node.rb:83:in `setup'
  app/models/drupal_node.rb:409:in `block in new_note'
  app/models/drupal_node.rb:408:in `new_note'
  app/controllers/notes_controller.rb:25:in `create'
jywarren commented 11 years ago

I suspect .valid? is not triggering custom validations:

https://github.com/jywarren/plots2/blob/master/app/models/drupal_node.rb#L3

https://github.com/jywarren/plots2/blob/master/app/models/drupal_node.rb#L405

do research: https://duckduckgo.com/?q=.valid%3F+rails+custom+validation

jywarren commented 11 years ago

This occurred once on the production site, with a "title too long" validation failure. it had to be cleaned up manually

btbonval commented 11 years ago

Can we reproduce this problem? As in, is there a good way to simulate a failed note post? Even if we have to write one or two lines of code to make it break.

I'd like to make sure we don't get this problem with a proper InnoDB backend on node. The other tables involved (url_alias and node_counter) might also need to be InnoDB before this problem is fully resolved.

jywarren commented 10 years ago

This hasn't happened for so long that I feel we can close it. It must've been solved or bypassed!