Skip to content

timedate, locale: fix barrier to suppress multiple function calls - #9684

Merged
keszybz merged 3 commits into
systemd:masterfrom
yuwata:fix-9672
Jul 26, 2018
Merged

keszybz merged 3 commits into
systemd:masterfrom
yuwata:fix-9672

Conversation

@yuwata

@yuwata yuwata commented Jul 21, 2018

Copy link
Copy Markdown
Member

Fixes #9672.

@martinpitt

Copy link
Copy Markdown
Contributor

Thanks @yutawa! With this PR applied, I did not get the "NTP flag is eternally wrong" bug any more. It is stil false right after enabling NTP (which is a bit confusing), and our entire integration test still fails, but this is something to debug on my side, at least for now. On the CLI this definitively helps.

@martinpitt

Copy link
Copy Markdown
Contributor

Update: While this PR might be a valid fix, it is not fixing the root cause of #9672, which is the wrong PropertiesChanged signal.

@yuwata

yuwata commented Jul 22, 2018

Copy link
Copy Markdown
Member Author

@martinpitt Thank you for checking this PR. I've force-pushed an updated version. Now, timedated wait after stopping/starting NTP client service. PTAL.

Comment thread src/timedate/timedated.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, this changes the semantics of method_set_ntp significantly — before it'd be "set the state" and now it is "set the state, wait for the unit to be started or stopped". Additional wrinkle is that if a second parallel method_set_ntp is made in parallel, the first one will cut the wait short, so the condition is really more like "wait for the unit to be started or stopped OR for another method_set_ntp call to come in". Shouldn't the change be made smaller, to keep the call asynchronous, and only wait on the job to be finished to send out the property change? This should fix the original issue, without changing the semantics of the call. I'm not sure what the proper solution is, so I'm putting this out here for discussion.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I confirm that this fixes the wrong property changed value. However, I agree with @keszybz that it seems cleaner to not make SetNTP blocking, and just defer the PropertyChanged signal until the NTP unit is actually running.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I see. OK, I will update this. Thank you.

@yuwata

yuwata commented Jul 23, 2018

Copy link
Copy Markdown
Member Author

@martinpitt and @keszybz Updated. Changes are

  • Sending reply is not delayed now. Only emitting property change is delayed.
  • When the previous job of starting/stopping unit has not completed, then refuse subsequent SetNTP method calls.

PTAL. Thank you.

@martinpitt

Copy link
Copy Markdown
Contributor

@yuwata: Thanks! The property changes look correct now. The commit message should be adjusted to what it's actually doing (deferring the Property Changed signal, the method itself does not wait), otherwise this LGTM now.

@yuwata

yuwata commented Jul 24, 2018

Copy link
Copy Markdown
Member Author

@martinpitt Thank you for testing this. I've updated commit message.

@keszybz

keszybz commented Jul 24, 2018

Copy link
Copy Markdown
Member

When the previous job of starting/stopping unit has not completed, then refuse subsequent SetNTP method calls.

No, please don't do that. As you write in the commit message, this method can be called frequently. Now that would become an error and require special handling. Instead this should behave the similarly to repeated systemctl start/stop calls. When a new start/stop job is queued, the old one will be cancelled, so the latest one wins. I think it should be enough to just watch for the latest queued job, and forget the earlier ones.

@martinpitt

Copy link
Copy Markdown
Contributor

I think it should be enough to just watch for the latest queued job, and forget the earlier ones.

Oh, that explains a strange new cockpit test case failure that I've seen with this PR applied. Indeed!

@yuwata

yuwata commented Jul 25, 2018

Copy link
Copy Markdown
Member Author

@keszybz and @martinpitt Thank you for the comment. I've force-pushed a revised version. Changes from the previous revision are the following:

  • drop the previously introduced bus error.
  • forget uncompleted previous job.

@keszybz keszybz left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your patience ;) Some more questions from my side...

Comment thread src/timedate/timedated.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: no

Comment thread src/timedate/timedated.c Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So... is this check really necessary? Wouldn't it be simpler and more reliable to just send the job start/stop request always? Imagine the following scenario:

  1. the service is not running
  2. somebody calls enable through timedated, timedated queues a start job
  3. the start job finishes
  4. a stop job is queued through systemctl stop
  5. somebody calls enable through timedated, timedated queues a start job

Even if 4 and 5 are always in that order, depending on whether 3 is earlier or later, the outcome will be different (in one case a new start job will be queued, in the other not).

My thinking is that pid1 is the only place that really know the current state, and the only cost we have from forwarding all the enable/disable calls to it is a dbus call, which is not expensive.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is a very good question. While I update this, I noticed that. So, can I confirm your suggestion? You mean that we should set in some sense that ignore_active_state always true?

I will test the racy conditions later and may update this. Thank you so much for giving comments so many times.

yuwata added 3 commits July 26, 2018 12:13
The commit 5d28074 introduces a
barrier to suppress calling context_update_ntp_status() multiple times.
However, it just stores the address of sd_bus_message object. So,
when an address is reused on the subsequent message, then the status
of NTP clients are not updated.

This makes the stored message object is referenced by the context
object. So, the subsequent message is on cirtainly different address.
…pping NTP service is finished

Before this, the property changed signal is emitted immediately after
StartUnit/StopUnit method is called. So, the running state of the NTP
client service may not updated.
This makes the timing of emitting property changed signal is deferred
until job of starting/stopping NTP client service is completed.

Fixes systemd#9672.
@yuwata

yuwata commented Jul 26, 2018 •

Copy link
Copy Markdown
Member Author

@keszybz Updated. It seems work now with the combination of systemctl start/stop systemd-timesyncd.service.

  • Always call StartUnit/StopUnit regardless its active state.

@keszybz

keszybz commented Jul 26, 2018

Copy link
Copy Markdown
Member

@yuwata thanks.

@keszybz
keszybz merged commit 82296b3 into systemd:master Jul 26, 2018
@yuwata
yuwata deleted the fix-9672 branch July 26, 2018 08:46
yuwata added a commit to yuwata/systemd that referenced this pull request Jul 26, 2018
poettering pushed a commit that referenced this pull request Aug 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

3 participants