possible bug with delta indexing?

34 views
Skip to first unread message

Jason

unread,
Jan 13, 2010, 2:56:39 PM1/13/10
to Thinking Sphinx
We use delayed_delta indexing (TS-1.1.14, sphinx-0.9.9, Rails 2.3.4)

The symptom was that delayed indexing works find in production
(RAILS_ENV=production) but Delayed::Jobs were not getting enqueued in
development mode (RAILS_ENV=development).

It looks like the culprit was ThinkingSphinx::Attributed#live_value
hitting an exception ("undefined method"). It's called when
after_commit fires off update_attribute_values (which calls
attribute_values_for_index which calls live_value).

I am assuming that in production, these exceptions get thrown but
something catches them and the after_commit :index_delta still gets to
run. Perhaps in development mode, things aren't so forgiving?

It looks like live_value runs into a problem with

has permissionables(:readable), :as => :permissionable_kludge, :type
=> :boolean

[I have this defined so an OUTER JOIN gets emitted to permissionables]

The stack is object, :permissionables, :readable, so live_value does

object = object.send(:permissionables)

now object is an array of permissionables. the array doesn't define
":readable" so we then get the undefined method error next time
through the loop.

I don't understand what any of this code is for, so I don't know the
best fix (perhaps this is just a documentation oversight and I'm mis-
using has() or perhaps I didn't properly read the docs).

My kludgey fix (kludge on top of kludge) was to change the has line to
refer to a string and change the type to string so it gets excluded
from the array that attribute_values_for_index iterates down.

Thanks again for a great package!

-- Jason

Pat Allan

unread,
Jan 13, 2010, 6:31:21 PM1/13/10
to thinkin...@googlegroups.com
Hi Jason

Just to confirm - though it sounds like a potential bug - are you using TS 1.1.14? Or 1.3.14 (ie: the latest version)?

--
Pat

> --
> You received this message because you are subscribed to the Google Groups "Thinking Sphinx" group.
> To post to this group, send email to thinkin...@googlegroups.com.
> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/thinking-sphinx?hl=en.
>
>

Jason Yanowitz

unread,
Jan 13, 2010, 7:49:26 PM1/13/10
to thinkin...@googlegroups.com

Oops, yes,1.3.14, the latest.

>> To post to this group, send email to thinking-
>> sph...@googlegroups.com.

Pat Allan

unread,
Jan 14, 2010, 7:55:52 PM1/14/10
to thinkin...@googlegroups.com
Hi Jason

I could have sworn I made live_value play nicely with arrays, but it looks like I'm wrong. Consider it a bug, and I'll try to get it fixed soon.

--
Pat

>>> To post to this group, send email to thinkin...@googlegroups.com.
>>> To unsubscribe from this group, send email to thinking-sphi...@googlegroups.com.

Pat Allan

unread,
Jan 16, 2010, 2:54:26 AM1/16/10
to thinkin...@googlegroups.com
Ah, further investigation reveals why I've not seen this before... live_value is only useful for attributes that can be updated - and MVAs cannot be. If there's an array involved, then it should be an MVA, otherwise Ruby gets confused.

So try the attribute definition with :type => :multi instead.

--
Pat

Reply all
Reply to author
Forward
0 new messages