[CSHARP-2049] MapReduce does not work on DB version 3.4.5 Created: 29/Sep/17 Updated: 27/Oct/23 Resolved: 04/Oct/17 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | None |
| Affects Version/s: | 2.4.4 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Blocker - P1 |
| Reporter: | Paolo Laurenti | Assignee: | Robert Stam |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | map_reduce, mapreduce | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||
| Description |
|
MapReduce when run on db with 3.4.5. version does not produce any result. (Both with inline and output collection). I tried with C# driver 2.4.4:
Here's a simple snippet to use to reproduce the bug:
|
| Comments |
| Comment by Robert Stam [ 04/Oct/17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for confirming that removing the semicolon worked for you. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Paolo Laurenti [ 04/Oct/17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
You are right. I agree with you that the silent fail is a problem. Thank you very much. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Robert Stam [ 03/Oct/17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I've created a SERVER ticket for this. I'm not necessarily surprised that a trailing semicolon would not work, but failing silently is a problem. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Robert Stam [ 03/Oct/17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
After a lot of trail and error, it appears that the issue is caused by the trailing semicolon in the string constants for the map and reduce functions:
If you remove the trailing semi colon it works. Can you confirm? | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Paolo Laurenti [ 03/Oct/17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Awesome! | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Robert Stam [ 03/Oct/17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
OK. I'm focusing on testing with 3.4.9 (should be the same as 3.4.5, if not I'll download 3.4.5 and test against that also). Since you find that it works with 3.0.2 (after rewriting the reduce function to not use arrow functions) I won't test against 3.0.2. I have reproduced that when run from C# with 3.4.9 the outcome is an empty Result collection. While single stepping I see that that server has returned the following result to the mapreduce command:
Note that the emit count is 0. When run from the shell the emit count is 1. So that's a clue to the problem there. I'll continue investigating. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Paolo Laurenti [ 03/Oct/17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Yes, you're right. With 3.0.2 you need to change the anonymous functions from arrow functions to standard function. The focus of the issue I am reporting is about running MapReduce from C# .NET code on dbs with versions >= 3.4.5. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Paolo Laurenti [ 03/Oct/17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Sorry Robert, probably my description was not very clear. The subject of this ticket is the C# .NET Driver so, I am reporting a problem running MapReduce from C# code. The problem I am facing occurs when I try to run MapReduce from C# code. As I stated in my description:
I've never tried with 3.4.9 version. Let me know if now the problem is more clear and if I can do something else to help you. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Robert Stam [ 03/Oct/17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Thanks for the quick response. In your original description you stated that it worked with 3.0.2 but not with 3.4.5. Based on your latest information I think it never worked with 3.0.2 (most likely because the Javascript interpreter present in that version of the server does not support arrow functions). So the remaining question is whether it works correctly with 3.4.5 (or 3.4.9 which is the current version). When you run it from the shell does it work correctly? (i.e. does it result in a non-empty Result collection?). That would help determine whether the issue is with the map/reduce functions or with the C# driver. Edit: when I run the most recent example in the shell using the single sample document in the InputCollection I get the following Result collection:
I'll attempt again to reproduce using C# now. But only against 3.4.9. I don't think there's any chance this will work on 3.0.2 because of the arrow function. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Paolo Laurenti [ 03/Oct/17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I tried the following code in my mongoDB shell (3.4.5) and everything works fine.
I copied and pasted the "mapF" and "reduceF" function in my C# code (driver 2.4.4) and the output is an empty "Result" collection (no exception raised). Here's the C# code:
Let me know if I can make some other test in order to help you. Thanks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Comment by Robert Stam [ 03/Oct/17 ] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
I tried to reproduce this and for me it doesn't work with 3.0.2 either. The problem seems to be with the ReduceJS string constant. If I paste it into the mongo shell it doesn't parse correctly:
Can you try debugging your map reduce in the shell first and then pasting the functions back into your C# test program? |