Howard
did reproduce this, seems the delayed job is processed 4 times failing 3
times with
AASM::InvalidTransition: Event 'review' cannot transition from
'reviewable' - 1 failed attempts
Whereas each time the works in the job are processed. The first time
they got the state 3 the following duplicates 2. You can see the
changing works_added column in the table imports.
Claudia
--
Claudia Juergen
Universitaetsbibliothek Dortmund
Eldorado
0231/755-4043
https://eldorado.tu-dortmund.de/
I've not had time to look at this, but thanks to both of you for putting
the information up on Github and to you Claudia for proposing a
different workflow to go along with this. I hope to get to it soon, but
I've been spending more time on another project recently.
Howard
one other thing, no import review notification email is sent, allthough
the state changes from processing to reviewable. This was all tested on
the i18n branch. The settings for email are configured properly and the
system is able to sent mail on user registration etc.
Claudia
--
Howard
Would it be possible for you to send me the file that was causing
duplicates to be generated? I've been trying to duplicate the bug with a
small (one record) file of my own creation, but I'm not seeing it.
Thanks,
Howard
bundle show assm
I don't have any version information for this in the Gemfile, but I do
recall that I had to rewrite some of the Import model code as a result
of going to a new version of assm. I'm currently on 2.3.1. Based on the
history of aasm it was probably a 2.1 (or prior) => 2.2 problem.
Regardless, I'll more specific in the Gemfile.
Thanks,
Howard
the aasm gem used on the i18n instance with the same behaviour is 2.3.1.
Claudia
--
I think it's step 4 which causes the trouble
The 'last_error" from the table delayed_jobs is always the same:
Event 'review' cannot transition from 'reviewable'
...
One other question, might be related to the issue, but can just be me
being new to rails, ruby etc.
The email notifications are not sent.
Is this due to the fact, that I'm running in development mode as
config/environments/development.rb indicates.
But other emails (register, password forgotten) etc are sent.
Claudia
--
one other question about step 4. When the work is saved, isn't the
deduplication run? This sets the state to either accepted or duplicate.
There is no option for in process at this point.
And a question about the delayed_jobs. There is no configuration like
config/initializers/delayed_job.rb
So the default settings are taken and if I got it right a job is tried
25 times.
creating
config/initializers/delayed_job.rb
with just the
Delayed::Worker.max_attempts = 1
stopped the perpetual creation of duplicate works during import
Nonetheless the work created during import still got STATE_ACCEPTED
instead of STATE_IN_PROCESS.
Claudia
Am 07.11.2011 22:43, schrieb hading2:
--
Howard
Based on the delayed_job errors that Claudia reported it looks like
somehow batch_import in the Import model is getting called more than
once on an Import. batch_import is supposed to take an import in the
processing state, create works from it, and then save it and transition
it to the reviewable state. The error that she reports seems to indicate
that it is finding an import already in the reviewable state and hence
throwing an error. However, the attempt to transition occurs at the end
of the method, so the work creation happens regardless, which could
explain the creation of multiples.
A dirty fix might be to a) have this method check that the import it is
working on is in the right state and/or b) have it work inside a
transaction so that the extra works get thrown away if there is a
problem. I don't consider this ideal because it still doesn't give me
any idea _why_ batch_import is getting called more than once. I
speculate that this could be because there an error occurs and
delayed_job retries the job, but things aren't getting rolled back
correctly - but this explanation doesn't really help to understand why
it eventually succeeds instead of failing eternally.
I'm still thinking about it, but I may implement my dirty fix, as I
don't see any harm in it regardless. If I do that I'll write again when
I push it and you both can let me know if it fixes things or at least
changes what goes wrong. I still haven't managed to duplicate the issue
here.
Howard
I've pushed a possible dirty fix of the nature I described to master. If
John and/or Claudia (it's not in i18n yet, though) would be willing to
give this a try and let me know if it fixes or changes anything I'd
appreciate it.
Note that since it affects delayed_job tasks in addition to restarting
your rails server you also need to 'bundle exec rake bibapp:restart' so
that delayed_job will run with the new code.
Thanks,
Howard
as for the why it is the delayed_job being retried. Setting the maximum
attempts to 1 via a config/initializers/delayed_job.rb containing
Delayed::Worker.max_attempts = 1
will result in only 1 work being created. Still the transisiton seems to
fails as notify_user is not reached.
As you can't reproduce the error, might be the environment. I'm working
on Suse Linux 10 with Postgres 8.4.
There were other problems e.g. starting Solr, which were solved by
replacing localhost with 127.0.0.1 in
app/models/publisher.rb
config/initializers/solr.rb
lib/tasks/solr.rake
Claudia
--
the transition error only occurs on the second attempt. Setting the
delayed job to 1 attempt the last_error in the delayed_jobs is
{No route matches {:controller=>"imports", :action=>"show",
:user_id=>34, :locale=>#<User id: 2, email: "claudia...@udo.edu",
crypted_password: "0909b8a03
acc14caf0ab333b07557f9d8d2e3ed0", salt: "KqFX4JzsdFWcvdJHTLh",
created_at: "2011-10-25 12:41:16", updated_at: "2011-10-25 12:41:37",
remember_token: nil, remember_token_expires_a
t: nil, activation_code: nil, activated_at: "2011-10-25 12:41:37",
persistence_token:
"9f76012b609391560adef7c3ef1c46558b6ba33730bd5e9be86...">}
...
Claudia
So perhaps the first time through it is actually making it most of the
way through, including creating the work and transitioning the state of
the Import, but then errors out, leaving the other attempts to fail on
attempting the transition.
My change from yesterday might partially fix this, or not, depending on
where the error below is happening. I'm not sure where it's coming from,
but I will look at it today. If it does partially fix it what should
happen now is that the delayed job will still fail, I think, but all the
db state will be rolled back, so it would keep retrying from the same
place.
I think it's possible that the error below comes from the notifier - it
may be trying to generate the URL for the user to get back to review the
import, but the parameters are obviously wrong here. I'm not sure why
the master branch would fail in this place, though.
Ah well, I'll give it a look soon.
Howard
the changes from yesterday did fix this, even with the attempts not
restricted to 1 the import is done once and the transition succeeds. The
notifier is reached. Only the works imported are still editable in the
manage contributorships prior to the import being accepted.
Claudia
--
Note also that if you're switching branches back and forth you may need
to restart bibapp each time, as delayed_job will be holding on to
whatever code was present when _it_ was started - it doesn't reload code
like 'rails server' does.
John - have you had a chance to try to see if the change works for you yet?
Claudia - see my other email about the problem you're still seeing here.
I need to know in what context it is occurring before I can figure out
what to do about it.
Howard
Haven't tried i18n with this fix, yet.
Bibapp has been restarted between switching.
Claudia
--