Coder Social home page Coder Social logo

Comments (4)

cdecker avatar cdecker commented on July 30, 2024

Maybe we can push this issue upstream to make strict monotonicity optional by adding an additional flag to struct timers. My fear is that this could possibly result in multiple executions of the same timers?

from lightning.

rustyrussell avatar rustyrussell commented on July 30, 2024

gwillen [email protected] writes:

In the ccan timer module, there's an assertion that can crash if time moves backwards. I know there are different perspectives on this, but it seems like lightningd can probably recover from slight non-monotonicity of time, so it's worth thinking about whether crashing is the best outcome in this case.

Ouch, thanks!

So you know what happened? NTP jump or manual setting?

lightningd: ccan/ccan/timer/timer.c:307: timers_expire: Assertion `now >= timers->base' failed.
lightningd(24325): FATAL SIGNAL 6 RECEIVED
Fatal signal 6. Log dumped in crash.log
Aborted

Yuck. Saying that time shouldn't go backwards is fairly fundamental,
and a useful sanity check. Lots of things assume time makes progress.
And a library can't report soft errors.

OTOH, real life always wins over my personal preferences :)

One option is to switch to timemono, which really can't go backwards.
But timemono is completely detached from any wallclock time, so it's
only useful for relative timers.

Which implies an API change to always use relative time (this actually
matches with all non-test usage I can find).

I'll look harder.

Thanks!
Rusty.

from lightning.

gwillen avatar gwillen commented on July 30, 2024

This was a purely artificial example -- I accidentally jumped the time when debugging some time-handling code in an unrelated project. So it's not really "real life".

Although I'm curious what you mean by "a library can't report soft errors", since I am generally a fan of what seems like the opposite philosophy, "a library should generally never crash the binary it's executing within." But I think it's fine if we decide that lightningd crashes are acceptable in weird conditions, we just have to be aware (and perhaps document) that this is possible since it's possibly surprising.

from lightning.

cdecker avatar cdecker commented on July 30, 2024

It happens from time to time, I noticed it 2-3 times when coming back from suspend. It's likely that the clock drifts substantially and then NTP kicks in between two calls to timer_expire. So I wouldn't exactly call this a rare event :-)

from lightning.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.