[SERVER-29057] Unreplicated temporary collection creations should use unique names Created: 03/May/17 Updated: 30/Oct/23 Resolved: 28/Jul/17 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Replication |
| Affects Version/s: | None |
| Fix Version/s: | 3.5.11 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Judah Schvimer | Assignee: | Benety Goh |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | neweng | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | ||||||||||||||||||||
| Sprint: | Repl 2017-07-31 | ||||||||||||||||||||
| Participants: | |||||||||||||||||||||
| Linked BF Score: | 15 | ||||||||||||||||||||
| Description |
|
In multiple places we create temporary collections and use in-memory counters to make the names unique. If the node shuts down and starts back up, these names may no longer be unique. We can use a UUID to be more unique. Here are two examples: |
| Comments |
| Comment by Githook User [ 28/Jul/17 ] |
|
Author: {'email': 'benety@mongodb.com', 'username': 'benety', 'name': 'Benety Goh'}Message: This applies to rare oplog replay scenarios where the collection to create already exists. |
| Comment by Githook User [ 28/Jul/17 ] |
|
Author: {'email': 'benety@mongodb.com', 'username': 'benety', 'name': 'Benety Goh'}Message: |
| Comment by Githook User [ 28/Jul/17 ] |
|
Author: {'email': 'benety@mongodb.com', 'username': 'benety', 'name': 'Benety Goh'}Message: |
| Comment by Githook User [ 28/Jul/17 ] |
|
Author: {'email': 'benety@mongodb.com', 'username': 'benety', 'name': 'Benety Goh'}Message: This function generates a unique collection name suitable for temporary |
| Comment by Githook User [ 27/Jul/17 ] |
|
Author: {'email': 'benety@mongodb.com', 'username': 'benety', 'name': 'Benety Goh'}Message: |
| Comment by Githook User [ 27/Jul/17 ] |
|
Author: {'email': 'benety@mongodb.com', 'username': 'benety', 'name': 'Benety Goh'}Message: |
| Comment by Judah Schvimer [ 04/May/17 ] |
|
renameCollection looks like another example of this: |
| Comment by Eric Milkie [ 04/May/17 ] |
|
After discussion, it's more clear what this ticket work represents. The examples listed in the description are not in fact the ones we should be changing. Instead, we only need to change the temp table name generation logic for temporary tables that are NOT replicated. One example is the convertToCapped temporary table. |
| Comment by Eric Milkie [ 04/May/17 ] |
|
I thought temporary collections did not live across startups (they are dropped because that's what makes them temporary). |
| Comment by Matthew Russotto [ 03/May/17 ] |
|
Yes, some of our current code includes the existing collection name which wouldn't leave much. But I guess we don't need that. |
| Comment by Geert Bosch [ 03/May/17 ] |
|
We have 120 - 63 - 1 == 56 characters for the collection part of the namespace name. The UUID is 36 bytes in ASCII representation, so that leaves some space for a prefix like tmp_ or whatever indicating to humans this is a temporary collection. |
| Comment by Matthew Russotto [ 03/May/17 ] |
|
We also probably want to ensure our temporary names don't exceed namespace length limits. |
| Comment by Geert Bosch [ 03/May/17 ] |
|
We probably should make a single method that creates a new temp collection with a unique name. Once we enable collection UUIDs we can change them to use the actual UUID of the collection. Until then we can just generate a new one. |