[SERVER-16260] Some commands no longer accept values of the Symbol BSON type Created: 21/Nov/14 Updated: 15/Jan/15 Resolved: 08/Jan/15 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Internal Code |
| Affects Version/s: | 2.8.0-rc0 |
| Fix Version/s: | 2.8.0-rc5 |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Emily Stolfo | Assignee: | Matt Kangas |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
|||||||||||||||||||||
| Backwards Compatibility: | Fully Compatible | |||||||||||||||||||||
| Operating System: | ALL | |||||||||||||||||||||
| Steps To Reproduce: | For reference when reading the following: a Ruby symbol is represented in the form :symbol and is serialized to the BSON Symbol type.
This is what mongosniff shows:
With MongoDB nightly Nov-18-2014 and the most recent Ruby driver (1.12.0.rc0):
And this is the mongosniff output
In looking at the commit that changed this behavior, other commands are probably affected as well. |
|||||||||||||||||||||
| Participants: | ||||||||||||||||||||||
| Description |
|
The server no longer accepts the Symbol BSON type for some command values. In particular, the 'drop' command is affected. I believe it is because of this commit https://github.com/mongodb/mongo/commit/d41f98bd0fdc3d392fc19aadfdc62a020d17fede |
| Comments |
| Comment by Githook User [ 08/Jan/15 ] |
|
Author: {u'username': u'kangas', u'name': u'Matt Kangas', u'email': u'matt.kangas@mongodb.com'}Message: Followup to Add dbtest for commands that accept Symbol BSON type as collection name
|
| Comment by Bernie Hackett [ 08/Dec/14 ] |
I think this is a reasonable plan of action. |
| Comment by J Rassi [ 08/Dec/14 ] |
|
Unlike the drop_collection() helper, the command() helper in the Ruby driver isn't actually explicitly documented to take symbols as values inside the "selector" argument, but sure, you're right, I wouldn't be surprised if applications are doing that anyway (though, note also that I do not believe that any server command accepts the Symbol type for any of its command-specific options during parsing). If it is expected that users will invoke the command() helper with symbol values, then the command() helper needs to be serializing those values to the String BSON type; it is a defect in the Ruby driver (or in the driver documentation for the command() helper, depending on how you look at it) that it is sending Symbol elements to the server in command objects, because the server is not going to handle them correctly (if any application currently is using the driver this way, it /will/ get broken by a future server release, I assure you). I suppose then I'd change my recommendation to 1) in the Ruby driver, fix the drop_collection() helper and the command() helper, and similarly audit the rest of db.rb, 2) in the server, accept Symbol in all of the commands that were changed by the above commit, with a comment explaining why and a plan to remove it in 3.0. |
| Comment by Bernie Hackett [ 08/Dec/14 ] |
|
rassi@10gen.com - the bigger issue is every driver has a generic command helper. That means in Ruby any command could have its name passed as a symbol. This change will potentially break a large number of applications, and not just those calling drop_database. |
| Comment by J Rassi [ 08/Dec/14 ] |
|
emily.stolfo@10gen.com: could you please file/schedule a ticket to fix the drop_collection() helper in the 1.x-stable branch, and also perform an audit that all other helpers in db.rb correctly invoke to_s on the collection name before sending it to the server (so we can similarly deal with such helpers now)? In the past, it looks like we have resolved this by applying a fix to the Ruby driver (e.g. matt.kangas@10gen.com: I would recommend adding logic to handle Symbol /only/ in the drop command, with a comment indicating that it is needed because of bug in a helper the Ruby driver (I'd mention this ticket in the comment, and I'd also suggest filing another ticket in SERVER to remove this Symbol-specific parsing logic for 3.0). I just checked all of the other commands changed from d41f98bd, and none of them have a corresponding helper in the Ruby driver that could end up constructing a command object with a Symbol collection name; thus, we do not need to change the parsing logic in other commands. |
| Comment by Matt Kangas [ 21/Nov/14 ] |
|
You're absolutely right. Noted. |
| Comment by Emily Stolfo [ 21/Nov/14 ] |
|
While the BSON Symbol type has been deprecated, this is still a backwards breaking change in the server, regardless of whether newer Ruby driver versions continue to send it. I believe the BSON Symbol type is 14. |
| Comment by Matt Kangas [ 21/Nov/14 ] |
|
The BSON symbol type has been deprecated since 2011. Perhaps the Ruby driver should stop sending BSON type But since all Ruby drivers in the wild currently send it, the server should accept both String and Symbol values (BSON types 2, (Corrected: Symbol is 0x0E, integer value 14) |