Bug with Engine#processes

2 views
Skip to first unread message

Ocha

unread,
Feb 9, 2011, 6:29:50 PM2/9/11
to ruote
Hello,

I was looking at processes method in engine.rb (ruote 2.1.11) and I
see that list of processes returned by that method can be different
when passing in an options hash. If there are options passed in (for
example :skip=>0) then we will get only processes that have
expressions associated because of expression_wfids method in base.rb.

I ran into a problem when I called Engine.processes and tried to read
definition_name for each process. I got a method missing error on
'attribute' for nilclass.

I would recommend changing Engine#processes to:

if opts.size > 0
wfids = @context.storage.expression_wfids(opts)
return wfids.size if opts[:count]
else
wfids = @context.storage.expression_wfids
end
list_processes(wfids, opts)

let me know what you think...

Thanks,
Ocha

John Mettraux

unread,
Feb 9, 2011, 6:37:27 PM2/9/11
to openwfe...@googlegroups.com

On Wed, Feb 09, 2011 at 03:29:50PM -0800, Ocha wrote:
>
> I was looking at processes method in engine.rb (ruote 2.1.11) and I
> see that list of processes returned by that method can be different
> when passing in an options hash. If there are options passed in (for
> example :skip=>0) then we will get only processes that have
> expressions associated because of expression_wfids method in base.rb.
>
> I ran into a problem when I called Engine.processes and tried to read
> definition_name for each process. I got a method missing error on
> 'attribute' for nilclass.

Hello Ocha,

welcome to ruote's mailing list.

Could I have the backtrace fo the "missing error" ?

> I would recommend changing Engine#processes to:
>
> if opts.size > 0
> wfids = @context.storage.expression_wfids(opts)
> return wfids.size if opts[:count]
> else
> wfids = @context.storage.expression_wfids
> end
> list_processes(wfids, opts)
>
> let me know what you think...

OK, #list_processes is meant to deal with a 'wfids' set to nil. I will look at the error backtrace and make the appropriate modification.


Thanks in advance,

--
John Mettraux - http://jmettraux.wordpress.com

Iuri Gagnidze

unread,
Feb 10, 2011, 11:48:46 AM2/10/11
to openwfe...@googlegroups.com
Hi John,

Unfortunately I don¹t have a backtrace ‹ we patched it(in the calling
code, non ruote files) by manually skipping processes that have 0
expressions. We were getting missing_method 'attribute' for nilclass when
we were trying to iterate through processes that collect their
definition_name. The error was raised ultimately for processes that had 0
expressions in them (and maybe wfid=nil, not sure about this). Running
through ruote Engine#processes I found that wfid variable can be different
if passing options hash with some garbage in it (eg :test=>²test²). I
would expect to have the same list of processes returned by
Engine#processes if I don¹t pass options hash or if I pass options hash
with unusable keys.

Thanks
Iuri

>--
>you received this message because you are subscribed to the "ruote users"
>group.
>to post : send email to openwfe...@googlegroups.com
>to unsubscribe : send email to
>openwferu-use...@googlegroups.com
>more options : http://groups.google.com/group/openwferu-users?hl=en


John Mettraux

unread,
Feb 10, 2011, 9:52:26 PM2/10/11
to openwfe...@googlegroups.com

On Thu, Feb 10, 2011 at 10:48:46AM -0600, Iuri Gagnidze wrote:
>
> Unfortunately I don¹t have a backtrace ‹ we patched it(in the calling
> code, non ruote files) by manually skipping processes that have 0
> expressions. We were getting missing_method 'attribute' for nilclass when
> we were trying to iterate through processes that collect their
> definition_name. The error was raised ultimately for processes that had 0
> expressions in them (and maybe wfid=nil, not sure about this).

Hello Iuri,

I think I know the root cause.

https://github.com/jmettraux/ruote/blob/f496d53ba0962c3f3048b09b5015e19fe07cc928/lib/ruote/engine/process_status.rb#L161-164
https://github.com/jmettraux/ruote/blob/f496d53ba0962c3f3048b09b5015e19fe07cc928/lib/ruote/engine/process_status.rb#L72-91

Could be triggered by a process that has no root expression anymore (this covers your "no expressions anymore" case).

I will come up with a proper test case and a proper fix.

> Running
> through ruote Engine#processes I found that wfid variable can be different
> if passing options hash with some garbage in it (eg :test=>²test²). I
> would expect to have the same list of processes returned by
> Engine#processes if I don¹t pass options hash or if I pass options hash
> with unusable keys.

OK, that's a second issue, those garbage opts get passed to Storage#expression_wfids

https://github.com/jmettraux/ruote/blob/2e75b2b75ca1caa5495e0756e0986fa34aafd46e/lib/ruote/engine.rb#L269
https://github.com/jmettraux/ruote/blob/2e75b2b75ca1caa5495e0756e0986fa34aafd46e/lib/ruote/storage/base.rb#L114-133

I guess the "if opts.size > 0" is hurting (as suggested by your patch).

I will add a test case and integrate your patch.

By the way, what storage implementation are you using ?


Thanks for reporting those issues, stay tuned,

John Mettraux

unread,
Feb 12, 2011, 4:54:51 AM2/12/11
to openwfe...@googlegroups.com

On Fri, Feb 11, 2011 at 11:52:26AM +0900, John Mettraux wrote:
>
> On Thu, Feb 10, 2011 at 10:48:46AM -0600, Iuri Gagnidze wrote:
> >
> > Unfortunately I don¹t have a backtrace ‹ we patched it(in the calling
> > code, non ruote files) by manually skipping processes that have 0
> > expressions. We were getting missing_method 'attribute' for nilclass when
> > we were trying to iterate through processes that collect their
> > definition_name. The error was raised ultimately for processes that had 0
> > expressions in them (and maybe wfid=nil, not sure about this).
>
> I will come up with a proper test case and a proper fix.

Hello Iuri,

this got fixed in

https://github.com/jmettraux/ruote/commit/851a2daf9e87b7bbc91d29f5d7fdac5b5d744c30

> > Running
> > through ruote Engine#processes I found that wfid variable can be different
> > if passing options hash with some garbage in it (eg :test=>²test²). I
> > would expect to have the same list of processes returned by
> > Engine#processes if I don¹t pass options hash or if I pass options hash
> > with unusable keys.
>

> I will add a test case and integrate your patch.

I integrated your patch as

https://github.com/jmettraux/ruote/commit/6c1e9c5529a7cf343b58e5553f116b7a5379f457

#processes now looks like

https://github.com/jmettraux/ruote/blob/9597c8997c89dcc83553d90bd721679b1d2f6a12/lib/ruote/engine.rb#L263-268

Your initial issue was caused by "leftovers", ie workitems, errors or schedules for which there are no more expressions. #processes is no simplified and should not return ProcessStatus instances when there are no expressions (as you pointed out).

I've added a #leftovers method to Engine to retrieve such "leftovers" (and potentially delete them and/or investigate why they ended up being left over).

https://github.com/jmettraux/ruote/commit/9597c8997c89dcc83553d90bd721679b1d2f6a12


Many thanks,

Iuri Gagnidze

unread,
Feb 12, 2011, 1:54:17 PM2/12/11
to openwfe...@googlegroups.com

Thanks John.

Reply all
Reply to author
Forward
0 new messages