Incorrect behavior in a shard cluster
See original GitHub issueCurrently .remove
method always uses findAndModify
. It should use deleteOne
if ctx.id
is present.
Main problem right now it’s not possible to remove document by _id
without passing shard key, because .remove
uses findAndModify
, if it would use deleteOne
you’ll be able to remove document just by _id
, without passing extra query with sharding key.
This is my current workaround, in before remove hook:
if (
ctx.id
&& ctx.service
&& ctx.service.Model
) {
await ctx.service.Model.deleteOne({ ...(ctx.params.query || {}), _id: ctx.id });
ctx.result = { _id: ctx.id };
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
CLI argocd admin cluster stats show incorrect shard #11537
[*] I've pasted the output of argocd version . ... I'm trying to manually assign clusters to different application-controller shards. According ...
Read more >What Issues could arise, when reading/writing to a single ...
In a sharded cluster, the individual shards contain the data but some ... be innocuous or could result in unexpected behavior/wrong results.
Read more >Cluster-level shard allocation and routing settings
Shard allocation is the process of allocating shards to nodes. This can happen during initial recovery, replica allocation, rebalancing, or when nodes are ......
Read more >[SERVER-44648] Sharded Cluster not working when one ...
Then the following steps are taken for the sharded cluster availability test. 1. perform a select and insert operation on sharded collection.
Read more >Rebalance uneven shard distribution in ...
Uneven shard sizes in a cluster. ... Incorrect shard allocation strategy. ... Add more data nodes to your OpenSearch Service cluster.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This makes complete sense to me. I completely agree about not having to pass a shard key. The only thing that could make that API worse is having to pass your social security number. 😉
It seems reasonable to me to have
deleteOne
become the default behavior. We could also go the route of supporting both and having an option to do one or the other. I don’t really feel like it’s necessary, though. Care to make a PR?@marshallswain yes, thank you!