[ActsAsFerret] Index Directory Disappears and Not Re-created


#1

Hi,

This is a recurring issue for me - the index directory on my production
server and everything below it occasionally disappears and isn’t
reconstructed. I tried manually creating the entire index path manually
before starting the server, but it still happened while the server is
running.

I don’t know what’s causing the index to disappear and I’m also not sure
why it’s not automagically re-created in any event?

Using:

Rails 1.1.6
Ferret 0.10.13
Acts_as_ferret (can’t see a version no. but it’s recent)

Any help would be greatly appreciated.


IOError (IO Error occured at <except.c>:79 in xraise
Error occured in fs_store.c:185 - fs_clear_all
clearing all files in
/var/www/apps/accounts/current/config/…/index/production/account:

):
/usr/lib/ruby/gems/1.8/gems/ferret-0.10.13/lib/ferret/index.rb:664:in
initialize' /usr/lib/ruby/gems/1.8/gems/ferret-0.10.13/lib/ferret/index.rb:664:inensure_writer_open’
/usr/lib/ruby/gems/1.8/gems/ferret-0.10.13/lib/ferret/index.rb:270:in
<<' /usr/lib/ruby/1.8/monitor.rb:229:insynchronize’
/usr/lib/ruby/gems/1.8/gems/ferret-0.10.13/lib/ferret/index.rb:254:in
<<' /vendor/plugins/acts_as_ferret/lib/instance_methods.rb:85:inferret_create’
/vendor/rails/activerecord/lib/active_record/callbacks.rb:344:in
callback' /vendor/rails/activerecord/lib/active_record/callbacks.rb:341:incallback’
/vendor/rails/activerecord/lib/active_record/callbacks.rb:266:in
create_without_timestamps' /vendor/rails/activerecord/lib/active_record/timestamp.rb:30:increate’
/vendor/rails/activerecord/lib/active_record/base.rb:1718:in
create_or_update_without_callbacks' /vendor/rails/activerecord/lib/active_record/callbacks.rb:253:increate_or_update’
/vendor/rails/activerecord/lib/active_record/base.rb:1392:in
save_without_validation' /vendor/rails/activerecord/lib/active_record/validations.rb:736:insave_without_transactions’
/vendor/rails/activerecord/lib/active_record/transactions.rb:126:in
save' /vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/database_statements.rb:51:intransaction’
/vendor/rails/activerecord/lib/active_record/transactions.rb:91:in
transaction' /vendor/rails/activerecord/lib/active_record/transactions.rb:118:intransaction’
/vendor/rails/activerecord/lib/active_record/transactions.rb:126:in
`save’


#2

On Thu, Jan 18, 2007 at 01:05:47PM +0100, Michael M. wrote:

Hi,

This is a recurring issue for me - the index directory on my production
server and everything below it occasionally disappears and isn’t
reconstructed. I tried manually creating the entire index path manually
before starting the server, but it still happened while the server is
running.

I don’t know what’s causing the index to disappear and I’m also not sure
why it’s not automagically re-created in any event?

I suspect you use capistrano for your deployment - is it possible that
on each deploy your index gets lost because it is located inside the
releases/…/ subdirectory?

for the index not being recreated problem - maybe it’s just a permission
issue?

Jens


webit! Gesellschaft für neue Medien mbH www.webit.de
Dipl.-Wirtschaftsingenieur Jens Krämer removed_email_address@domain.invalid
Schnorrstraße 76 Tel +49 351 46766 0
D-01069 Dresden Fax +49 351 46766 66


#3

On Wed, Jan 24, 2007 at 12:05:24PM +0100, Michael M. wrote:

I don’t know what’s causing the index to disappear and I’m also not sure
issue?

I’m not sure about that as the log messages don’t seem to indicate it
and the server user is the same as the user that created the release
structure. I do have the index checked in to the repository though (as a
hack) and maybe the attributes on it are wrong (e.g. the dir’s not
executable).

I usually symlink the RAILS_ROOT/index/ directory to shared/index in an
after_update_code recipe.
That way the index physically stays the same from deployment to
deployment.

Jens


webit! Gesellschaft für neue Medien mbH www.webit.de
Dipl.-Wirtschaftsingenieur Jens Krämer removed_email_address@domain.invalid
Schnorrstraße 76 Tel +49 351 46766 0
D-01069 Dresden Fax +49 351 46766 66


#4

Checking in the index is a very bad idea. Instead, the index should be
in the shared directory of your deployment, and releases should symlink
to this shared index.

In deploy.rb, this would look like this:

<<-DESC
Create a shared index dir.
All deployed versions will share the same index, as they share the same
database.
When upgrading ferret, this index might have to be rebuilt.
DESC
task :create_index_dir do
run <<-CMD
mkdir -p -m 777 #{shared_path}/index
CMD
end

<<-DESC
Create a symlink from the current release to the shared index.
DESC
task :create_index_symlink do
run <<-CMD
ln -fs #{shared_path}/index/ #{current_release}/index
CMD
end

Hooks

task :after_setup do
create_index_dir
end

task :after_symlink do
create_index_symlink
end


#5

Jens K. wrote:

On Thu, Jan 18, 2007 at 01:05:47PM +0100, Michael M. wrote:

Hi,

This is a recurring issue for me - the index directory on my production
server and everything below it occasionally disappears and isn’t
reconstructed. I tried manually creating the entire index path manually
before starting the server, but it still happened while the server is
running.

I don’t know what’s causing the index to disappear and I’m also not sure
why it’s not automagically re-created in any event?

I suspect you use capistrano for your deployment - is it possible that
on each deploy your index gets lost because it is located inside the
releases/…/ subdirectory?

Thanks for the reply and you guessed correctly. It’s running capistrano
and maybe that explains why it happens periodically.

for the index not being recreated problem - maybe it’s just a permission
issue?

I’m not sure about that as the log messages don’t seem to indicate it
and the server user is the same as the user that created the release
structure. I do have the index checked in to the repository though (as a
hack) and maybe the attributes on it are wrong (e.g. the dir’s not
executable).

Thanks,
Michael