0

I have a MongoDB server running on an 64-bit Amazon EC2 instance (journaling enabled). Yesterday I updated some documents and refreshed the webpage to make sure it reflects the changes. It did. But today I see that not only yesterday's changes are gone. I lost a week of updates! Why could this be and is it possible to recover the lost data?

Maybe there's something wrong in the way I make the changes?

public function edit_app()
{
    $query = array('_id' => $_POST['id']);
    $apps = $this->mongo->db->apps;
    if ($app = $apps->findOne($query)) {
        $app['title'] = $_POST['title'];
        $app['version'] = $_POST['version'];
        $app['author'] = $_POST['author'];
        ...
        $apps->save($app);
    }
}
tshepang
  • 12,111
  • 21
  • 91
  • 136
Vitaly
  • 4,358
  • 7
  • 47
  • 59

2 Answers2

1

There is not much that can be definitively said based on the information you have provided. I can however provide some hints to take you in the right direction:

  1. Think about whether there is a possibility that an application process could have been holding some documents in memory (loaded before your update) and and re-saved after your update?
  2. Is the server part of a replica set? If so, were all members of the replica set healthy with primary server up and elected correctly?
Zaid Masud
  • 13,225
  • 9
  • 67
  • 88
  • 1
    To add to the reply, also check the logs. Logs are a good starting point to diagnose what might have gone wrong. – Sid Mar 09 '12 at 16:23
  • @Siddharth Singh Thanks. I checked the logs, but there's nothing special there :( - just lots of records like "[clientcursormon] mem (MB) res:16 virt:820 mapped:80" and me connecting through a SSH tunnel. – Vitaly Mar 09 '12 at 20:37
  • @zooone9243 It's not a replica set. And I made changes via a website's admin panel (both written in PHP). It could be that I was connected to the database in MongoVue and after making changes in the admin panel, I switched to MongoVue and it made some changes thereafter. But that doesn't explain why I lost a week of changes, not just the latest one. It's really weird. – Vitaly Mar 09 '12 at 20:45
  • I see that you have edited the question but it is still vague for me to help you at this point of time. Any number of things could have gone wrong and its hard to definitely say anything with the information you've provided. – Sid Mar 09 '12 at 20:56
0

I apologize, I must have been blind. There was an error in the edit_app() function:

$app['visible'] = $_POST['visible'];        // was
$app['visible'] = isset($_POST['visible']); // fixed
Vitaly
  • 4,358
  • 7
  • 47
  • 59