[SERVER-21751] Change _id format in local.startup_log collection to avoid duplicate key errors in systems missing RTC Created: 03/Dec/15 Updated: 06/Dec/22 |
|
| Status: | Backlog |
| Project: | Core Server |
| Component/s: | Admin, Diagnostics |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Minor - P4 |
| Reporter: | Martin Hundebøll | Assignee: | Backlog - Security Team |
| Resolution: | Unresolved | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||
| Assigned Teams: |
Server Security
|
||||||||
| Participants: | |||||||||
| Description |
|
We are running mongod on an embedded device (sounds weird, I know...), and since we have no RTC on the device, it always starts from epoch. This makes the logging at startup likely to fail after a few boots, since the _id key is constructed from the system hostname appended with the milliseconds since epoch: Would it be possible to make the index key an auto incremented value or something similar? Until now, I have mitigated the problem by removing the startup logging entirely from db/db.cpp: Can this cause be problems in other conexts? |
| Comments |
| Comment by Andy Schwerin [ 11/Mar/16 ] |
|
mnhu, if MongoDB supported auto-increment fields, your proposal would be the obvious choice. Unfortunately, MongoDB does not support auto-increment fields because of their implications for sharded (partitioned) clusters. |
| Comment by Martin Hundebøll [ 08/Mar/16 ] |
|
schwerin, unfortunately no. We have wifi, which I believe is used to source entropy, but I am not sure. And it isn't guaranteed to up and running at boot. Since it is for diagnostic purposes, wouldn't it make sense to use an (auto) incremental value as index, and simply log the time in a non-unique field instead? |
| Comment by Eric Milkie [ 08/Mar/16 ] |
|
mnhu, do you know the answer for Andy's question posed above? In order to reliably generate random numbers without collisions, for our _id values, an embedded system needs a source of entropy. |
| Comment by Andy Schwerin [ 03/Dec/15 ] |
|
In this embedded scenario, do you have a good source of entropy for random number generation? |
| Comment by Ramon Fernandez Marina [ 03/Dec/15 ] |
|
Thanks for your report mnhu. Unfortunately there's currently no way to avoid those collisions when the clock jumps back to the past. Note that the entries in local.startup_log are mostly there for diagnostic purposes, so I don't think removing them will have any negative side effects. We're going to keep this ticket open to discuss options about the _id for the documents in the startup_log collection, and whether they can/should be changed to some other format. Regards, |