[SERVER-61683] Operation findAndModify not possible on hashed sharded collection Created: 22/Nov/21 Updated: 27/Oct/23 Resolved: 25/Nov/21 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | None |
| Affects Version/s: | 5.0.4 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Wernfried Domscheit | Assignee: | Backlog - Triage Team |
| Resolution: | Community Answered | Votes: | 0 |
| Labels: | findAndModify, hashed, sharding | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||
| Assigned Teams: |
Server Triage
|
||||||||||||||||||||||||||||||||||||||||||
| Operating System: | ALL | ||||||||||||||||||||||||||||||||||||||||||
| Steps To Reproduce: |
I tried workarounds like
But none of them is working. I don't find any possibility to query for a hashed value. Do you have any solution? Kind Regards
|
||||||||||||||||||||||||||||||||||||||||||
| Participants: | |||||||||||||||||||||||||||||||||||||||||||
| Description |
|
When I have a sharded collection with a hashed shard key then findAndModify does not work. I constantly get error "Query for sharded findAndModify must contain the shard key" and I find no way to get rid of it.
|
| Comments |
| Comment by Dmitry Agranat [ 25/Nov/21 ] | ||||||||
|
Hi wernfried.domscheit@sunrise.net, The SERVER project is for bugs and feature suggestions for the MongoDB server. For these questions, we'd like to encourage you to start by asking our community for help by posting on the MongoDB Developer Community Forums. If the discussion there leads you to suspect a bug in the MongoDB server, then we'd want to investigate it as a possible bug here in the SERVER project. Regards, | ||||||||
| Comment by Wernfried Domscheit [ 22/Nov/21 ] | ||||||||
|
OK, this one is working:
But typically I don't know the timestamp, because it is the current time ISODate(), I only know the _id which is the primary key. Is there any solution for this? Wernfried
| ||||||||
| Comment by Dmitry Agranat [ 22/Nov/21 ] | ||||||||
|
wernfried.domscheit@sunrise.net, based on our documentation:
In other words, you must have equality condition/match on your hashed shard key named ts | ||||||||
| Comment by Wernfried Domscheit [ 22/Nov/21 ] | ||||||||
|
The shard key is hash value, how can I query it? The basic idea of a hash value is, that I don't know in which shard the data is, I only know the documents should be evenly distributed. Wernfried
| ||||||||
| Comment by Dmitry Agranat [ 22/Nov/21 ] | ||||||||
|
Hi wernfried.domscheit@sunrise.net, Could you query the field that contains an exact match on the shard key, for example with $eq? If this does not work, could you also post the output from sh.status()? Dima |