-
Notifications
You must be signed in to change notification settings - Fork 470
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
Rails 6 test issue #1195
Comments
My initial guess is that the issues aren't related - I wouldn't expect callbacks to be involved when starting Sphinx. Is this issue just in the test environment? i.e. do TS/Sphinx work fine in dev (i.e. using the standard rake tasks, etc)? |
It's just in the test environment. Starting sphinx in development works. I just rebuilt and got some errors:
wireless module model has:
There isn't a pcms_wireless_modules table. I'm looking to see if there was a change to has_one in rails 6. |
What does the index definition for the WirelessModule model look like? |
|
Hmm… I've no idea if this is related, and the syntax you've got should still work. But also, you can use the method notation rather than arguments without any issues (it was only a problem back before TS v3 and MRI 1.9): has pcm.id, as: :pcm_id
has pcm.serial_number, as: :pcm |
Tried that in no luck. I commented out the offending lines in the indexes but I'm still seeing the error in rspec unfortunately. |
Weird, when I'm running
|
|
I had to comment out some indexes. And fix some other issues. I'll follow up when I'm more sure about the cause. |
This part of the output you shared makes me wonder if it's actually the same issue as #1191 - which I still haven't had the chance to look into deeply (sorry @thebravoman!). But it's good to know that this seems to have started with your Rails 6 upgrade, and it looks like you're perhaps both using SQL-backed indices rather than real-time indices (which is maybe why I've not seen it in my own apps, but helps narrow down the focus). Something seems to be evaluating index definitions multiple times… no idea if it's thread-related. Perhaps that helps your own debugging, but I'll try to get a test app set up soon and see if I can reproduce with SQL-backed indices + Rails 6 + test environment. |
My offer for reproducing it on my machine and getting together over a video
call still stands, if this could help you narrow It down.
…On Tue, Jun 8, 2021, 07:42 Pat Allan ***@***.***> wrote:
ERROR: section 'activation_description_core_0' (type='source') already exists in config/test.sphinx.conf
This part of the output you shared makes me wonder if it's actually the
same issue as #1191 <#1191>
- which I still haven't had the chance to look into deeply (sorry
@thebravoman <https://github.com/thebravoman>!). But it's good to know
that this seems to have started with your Rails 6 upgrade, and it looks
like you're perhaps both using SQL-backed indices rather than real-time
indices (which is maybe why I've not seen it in my own apps, but helps
narrow down the focus).
Something seems to be evaluating index definitions multiple times… no idea
if it's thread-related. Perhaps that helps your own debugging, but I'll try
to get a test app set up soon and see if I can reproduce with SQL-backed
indices + Rails 6 + test environment.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1195 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAKAGBOYX7ZFQRGJ7GYT5ADTRWNTLANCNFSM4546YFJA>
.
|
Appreciated! Let me try and reproduce within a test app first - I'm hoping that would at least help give me a bit more context so any video calls are more productive :) |
Just thought of another question for you both: are you using the old-style classic loader, or Zeitwork's new approach? |
Oh, and: how are your index files named? e.g. |
Exactly that. |
I commented out a line in our code that calls I also added a |
If you feel comfortable diving into the TS code: it might be worth looking at how the preload_indices and preload_index methods are behaving. And I'm not sure if it's related, but the mutex (since Rails 5.1.5) is not a standard Ruby one, but rather something custom for Rails/Active Suppoort, that permits dependency loading while locked (see #1132). With both of those things in mind, I'm wondering if shifting def preload_indices
@@mutex.synchronize do
return if @preloaded_indices
@preloaded_indices = true
@indices = []
@sources = []
index_paths.each do |path|
Dir["#{path}/**/*.rb"].sort.each { |file| preload_index file }
end
normalise
verify
end
end (For what it's worth: I tried creating a sample app using Rails 6 and SQL-backed indices, and the super simple test suite was fine… also: it's interesting to note that this sounds like it's a consistent problem for @atomical, but intermittent for @thebravoman 🤔 - I'm really hoping it's the same cause though!) |
The model is app/models/course.rb $ tree app/indices/
app/indices/
├── course_index.rb |
It loads the indexes twice when What I mean by that is if I put a puts statement in one of the index files it prints twice. And then I get an error for duplicate index in the configuration file. I put a debugger statement in preload_indices and it's only being called once. Which is strange. |
Should an index file be require'd by Rails before Sphinx loads it with preload_index()? Would that be a problem? |
@thebravoman Try modifying this method in
I think I've got it working. |
Thanks so much for that debugging! With those clues, I was able to reproduce the problem in my test app, with eager_load set to true and using the classic autoloader (either scenario separately is fine, though). The fix I've added to my test app is putting the following line in config.eager_load_paths.reject! { |path| path == Rails.root.join("app", "indices").to_s } I'll look into making Thinking Sphinx do this automatically (and thus, we don't need that check against which files are loaded). @thebravoman: would love to know if this also fixes things for you? The fact that your issue has been intermittent makes me unsure if this is the exact same issue, but perhaps it's related? |
Thanks @pat
Tests passed on my side. My current rails is 6.1 just to let you know. |
This is perhaps only an issue with the classic autoloader, but it makes sense for the change to happen either way. This fix hopefully resolves #1191 and #1195, and was possible due to debugging assistance from @atomical and @thebravoman.
Just pushed a fix via 02bbb50 - if either/both of you are able to confirm the latest in gem "thinking-sphinx",
:git => "https://github.com/pat/thinking-sphinx.git",
:branch => "develop" |
All good on my side. The gitrepo has a typo - it should be thinking-sphinx and not thinking-sphinix. |
My laptop keyboard is a little flaky :/ fixed - and especially, thank you for testing! |
I just thought of something. I have a rails engine and it is located in
There I have a model
Currently my indices are in
but I would like to move them to
My point is - is it possible to have inidices in many folders, not only app/indices but also gems/my-engine/app/indices and if it is should this be taken into account with the recent change? |
Indices in engines should get picked up automatically, provided they're in the engine's |
Of course. I will try it and if there are issues I will open a separate issue here. I just wanted to make sure the case of engines (as it is supported) is not forgotten with this change. |
Ah… I guess that depends on whether Rails adds an engine's |
Just released v5.2.0 which includes this fix (and a further improvement that should ensure engine app/indices paths are also removed from eager_load_paths). So, I think this issue is all resolved - certainly, feel free to re-open the issue if I've got that wrong! |
I'm seeing this after our Rails 6 upgrade. I'm wondering if this deprecation warning finally turned into an error?
#1165
The text was updated successfully, but these errors were encountered: