On 07/20/2018 11:04 AM, Gordon Sim wrote:
On 20/07/18 15:50, Andrew Stitcher wrote:
On Fri, 2018-07-20 at 10:47 -0400, Andrew Stitcher wrote:
On Fri, 2018-07-20 at 15:44 +0100, Gordon Sim wrote:
...
I believe Kim is using restart() but is debugging some issue where
the
task is postponed after it has already fired, which he does not
want
(not sure why not). Is that right Kim?
In that case I think you need to create a new Timer instance.
IIRC once a one shot timer has elapsed you can't restart it any more
-
I may have got that wrong though as I didn't check the code
thoroughly.
To (try to) clarify further: The Timwer class can be used in two
different ways (perhaps these should have actually been different
classes, but here we are!): A periodic mode and a one shot mode.
restart() is used for the one-shot mode to delay firing;
setupNextFiring() is used in the periodic mode to set up the next
firing. I don't think you can sensibly use both for the same timer.
That is indeed illuminating!
And I think I probably mis-stated Kim's issue. Perhaps it is that the
task is not being delayed because it has already fired?
I am using the timer in periodic mode, ie with period set to an interval
that is used to repeatedly set up a new firing. I have created a
subclass of qpid::sys::TimerTask, but the state of the TimerTask is
private, and the subclass has no visibility of the firing state of the
TimerTask. The subclassed TimerTask
(qpid::linearstore::journal::InactivityFireEvent) keeps its own state to
determine how to interact with the parent class.
The idea is as follows: If the timer fires after some journal activity
(but not enough to fill the write buffer), the journal is flushed. Only
when new journal activity occurs, setUpNextFire() is called to start the
timer again.
If the journal buffer fills before the timer fires, then if flushes on
its own. In this case, if the next journal activity starts before the
timer fires, will restart the timer. If the timer fires after a flush
but before further activity, the fire does nothing and returns.
The problem I am seeing is described in some detail at
https://bugzilla.redhat.com/show_bug.cgi?id=1599778#c12. It is a
multi-threaded issue in which if the following occur almost at the same
time on separate threads, then the timer can be placed in an errored
state: the timer fires, a flush occurs directly from the journal, and
journal write activity occurs that attempts to reset the timer.
My contention is that there is no reasonable way to avoid this issue
using TimerTask::restart() without a check that the timer has not yet
fired. It is because this *can* occur that an error condition is
created, which in turn results in the error messages seen in the above BZ.
Perhaps adding a method which includes this check for restarting the
timer would be the simplest solution.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]