Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix search shards count method when targeting concrete and aliased indices #3268

Closed
wants to merge 1 commit into from
Closed

Fix search shards count method when targeting concrete and aliased indices #3268

wants to merge 1 commit into from

Conversation

Paikan
Copy link
Contributor

@Paikan Paikan commented Jun 30, 2013

This is related to the same example as issue #2682.

This bug can lead to a forced query_and_fetch search type which might not be the expected behavior.

I propose to fix it this way because it is a quick 2 lines patch. But maybe we should refactor a bit and add a shared method for searchShards and searchShardsCount to avoid divergent behavior in the future.

Reading the code it seems like searchShardsCount is mainly implemented to test if we are hitting 1 shard or more than 1 shards so maybe it could be renamed and optimized for that specific use case.

Feel free to fix the problem otherwise or to tell me what do you prefer and I will be happy to change this pull request.

@javanna
Copy link
Member

javanna commented Jul 30, 2013

Thanks for pointing this out! Let me just check if I got it right. The searchShards method has been fixed (I see that #2682 is closed and the related #2683 has been merged) but the same change has not been applied to the searchShardsCount method, right? And that would lead to erroneously forcing query_and_fetch if the searchShardsCount returns 1?

I guess it would be nice to share the same code between the two methods then and maybe write a test that reproduces the bug that we are trying to address. What do you think?

@ghost ghost assigned javanna Jul 30, 2013
@Paikan
Copy link
Contributor Author

Paikan commented Jul 30, 2013

@javanna yeah you got it perfectly right!

Yeah I agree I can work on it and update my pull request hopefully before the end of the week if you want. If you want it done before it is ok if you prefer to implement it yourself

@javanna
Copy link
Member

javanna commented Jul 31, 2013

No rush, you can go ahead and update your pull request when you have time.

@Paikan
Copy link
Contributor Author

Paikan commented Jul 31, 2013

@javanna great thanks I will

@kimchy
Copy link
Member

kimchy commented Aug 17, 2013

hey, I suggest we pull this fix first, just so we have a fix in master and 0.90, and think about optimization / refactoring in a separate issue?

One note regarding potentially sharing code, its important that we don't cause the round robin iterators be invoked when calling searchShardsCount, cause if they will, it will mean that with the common case, of 1 replica, the same copy of the data will be hit each time (a single search request will increment the round robin index by 1 for the count, and then the next one will increment it again for the search).

@Paikan
Copy link
Contributor Author

Paikan commented Aug 17, 2013

@kimchy sure we can push this fix and work on the refactoring in a separate issue.

I was about to update the pull request with the refactoring tomorrow (I am still missing the unit tests for it). Basically what I have done is create a new private method Set computeTargetedShards(ClusterState clusterState, String[] indices, String[] concreteIndices, @nullable Map<String, Set> routing) with the shared logic in it. It is called by searchShardsCount and searchShards.

@Paikan
Copy link
Contributor Author

Paikan commented Aug 17, 2013

@kimchy sorry a part is missing there the computeTargetedShards would return a set of IndexShardRoutingTable

@kimchy
Copy link
Member

kimchy commented Aug 17, 2013

@Paikan I am ok with the current pull request, then @javanna, lets pull this in once you double check it. Then, lets open a new pull request with the suggested refactoring, and discuss it there.

@Paikan
Copy link
Contributor Author

Paikan commented Aug 17, 2013

@kimchy ok I am going to open another issue with my proposed pull request tomorrow and we will be able to discuss more there about the suggested refactoring and maybe ways to optimize / improve it

@javanna
Copy link
Member

javanna commented Aug 19, 2013

Merged into 8e137b1 and backported to 0.90. Thanks @Paikan !!
I've also added a test for it...have a look at 7f7f79d if you're interested ;)

@javanna javanna closed this Aug 19, 2013
@Paikan Paikan deleted the fix-search-shards-count branch August 19, 2013 17:33
@Paikan
Copy link
Contributor Author

Paikan commented Aug 19, 2013

@javanna thanks for pushing this and for adding the missing unit test it was quite interesting indeed.

@kimchy I have opened and updated PR #3530 to discuss about refactoring.

mute pushed a commit to mute/elasticsearch that referenced this pull request Jul 29, 2015
martijnvg added a commit that referenced this pull request Apr 25, 2018
* es/6.x: (106 commits)
  Revert "Fix elasticsearch-cli dependency"
  Fix elasticsearch-cli dependency
  [Watcher] Use index.auto_expand_replicas: 0-1 (#3284)
  [DOCS] Reformatted machine learning overview (#3346)
  [DOCS] Added monitoring PRs to 6.1 release notes (#3297)
  [DOCS] Added xpack.ml.node_concurrent_job_allocations setting (#3327)
  [DOCS] Fixed troubleshooting titles
  Watcher: Set index and type dynamically in index action (#3264)
  Tests: Ensure that watcher is started in HipchatServiceTests
  Fix test due to BytesSizeValue negative value deprecation
  [DOCS] Explain ML datafeed run-as integration/limitations (#3311)
  Monitoring: Ensure all monitoring watches filter by timestamp (#3238)
  Fix license messaging for Logstash functionality (#3268)
  [DOCS] Updated titles of ML APIs
  Fixes test to support BytesSizeValue changes (#3321)
  Revert "Fixes test to support BytesSizeValue changes (#3321)"
  Fixes test to support BytesSizeValue changes (#3321)
  Add missing import
  Check for existing x-pack directory when running the `users` CLI tool (#3271)
  [DOCS] Fixed title in 6.1.0 release notes
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants