question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Incorrect behavior in a shard cluster

See original GitHub issue

Currently .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:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
marshallswaincommented, Dec 23, 2019

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?

0reactions
sarkistltcommented, Jan 8, 2020

@marshallswain yes, thank you!

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found