Skip to content

Instantly share code, notes, and snippets.

@ArthurN
Created December 15, 2011 04:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ArthurN/1479892 to your computer and use it in GitHub Desktop.
Save ArthurN/1479892 to your computer and use it in GitHub Desktop.
MongoDB error doing update shell/collection.js:200 (9001 socket exception?)
var startTime = (new Date()).getTime();
var total = db.items.count({_sid: { $exists: false } });
diff = ((new Date()).getTime() - startTime) / 1000.0;
print(diff + "s to count items without _sid");
print(total + " items need to be updated");
var done = 0;
db.items.find({_sid: { $exists: false } }).forEach(function (item) {
if (item.topic_ids != null && item.topic_ids.length > 0) {
item._sid = item.topic_ids[0];
} else {
item._sid = null;
}
db.items.save(item);
done++;
if (done % 100 == 0) {
percent = done / total * 100;
print("Done " + done + " of " + total + " (" + percent + "%)");
}
});
diff = ((new Date()).getTime() - startTime) / 1000.0;
print(diff + "s to complete script");
Thu Dec 15 04:40:07 [initandlisten] connection accepted from 127.0.0.1:54928 #13
Thu Dec 15 04:40:07 [conn13] runQuery called admin.$cmd { whatsmyuri: 1 }
Thu Dec 15 04:40:07 [conn13] run command admin.$cmd { whatsmyuri: 1 }
Thu Dec 15 04:40:07 [conn13] command admin.$cmd command: { whatsmyuri: 1 } ntoreturn:1 reslen:62 0ms
Thu Dec 15 04:40:07 [conn13] runQuery called crowdspoke_staging.$cmd { count: "items", query: { _sid: { $exists: false } }, fields: {} }
Thu Dec 15 04:40:07 [conn13] run command crowdspoke_staging.$cmd { count: "items", query: { _sid: { $exists: false } }, fields: {} }
Thu Dec 15 04:40:11 [DataFileSync] flushing mmap took 0ms for 15 files
Thu Dec 15 04:40:11 [PeriodicTask::Runner] task: WriteBackManager::cleaner took: 0ms
Thu Dec 15 04:40:11 [PeriodicTask::Runner] task: DBConnectionPool-cleaner took: 0ms
Thu Dec 15 04:40:11 [PeriodicTask::Runner] task: DBConnectionPool-cleaner took: 0ms
Thu Dec 15 04:41:11 [DataFileSync] flushing mmap took 0ms for 15 files
Thu Dec 15 04:41:11 [PeriodicTask::Runner] task: WriteBackManager::cleaner took: 0ms
Thu Dec 15 04:41:11 [PeriodicTask::Runner] task: DBConnectionPool-cleaner took: 0ms
Thu Dec 15 04:41:11 [PeriodicTask::Runner] task: DBConnectionPool-cleaner took: 0ms
Thu Dec 15 04:41:26 [clientcursormon] mem (MB) res:771 virt:37020 mapped:18376
Thu Dec 15 04:41:55 [conn13] command crowdspoke_staging.$cmd command: { count: "items", query: { _sid: { $exists: false } }, fields: {} } ntoreturn:1 reslen:48 107664ms
Thu Dec 15 04:41:55 [conn13] runQuery called crowdspoke_staging.items { _sid: { $exists: false } }
Thu Dec 15 04:42:11 [DataFileSync] flushing mmap took 0ms for 15 files
Thu Dec 15 04:42:11 [PeriodicTask::Runner] task: WriteBackManager::cleaner took: 0ms
Thu Dec 15 04:42:11 [PeriodicTask::Runner] task: DBConnectionPool-cleaner took: 0ms
Thu Dec 15 04:42:11 [PeriodicTask::Runner] task: DBConnectionPool-cleaner took: 0ms
Thu Dec 15 04:42:14 [conn13] used cursor: 0x3217a10
Thu Dec 15 04:42:14 [conn13] query crowdspoke_staging.items nscanned:30690 nreturned:101 reslen:84631 18832ms
Thu Dec 15 04:42:14 [conn13] killcursors: found 1 of 1
Thu Dec 15 04:42:14 [conn13] killcursors 0ms
Thu Dec 15 04:42:14 [conn13] Socket recv() conn closed? 127.0.0.1:54928
Thu Dec 15 04:42:14 [conn13] SocketException: remote: 127.0.0.1:54928 error: 9001 socket exception [0] server [127.0.0.1:54928]
Thu Dec 15 04:42:14 [conn13] end connection 127.0.0.1:54928
[arthur@stage1 ~]$ nohup mongo crowdspoke_staging assign_sids.js > sid3.log &
[1] 1499
[arthur@stage1 ~]$ tail -f sid3.log
MongoDB shell version: 2.0.0
connecting to: crowdspoke_staging
107.666s to count items without _sid
900734 items need to be updated
Thu Dec 15 04:42:14 Error: error doing update shell/collection.js:200
failed to load: assign_sids.js
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment