Skip to content
Snippets Groups Projects
Commit 65470cb4 authored by Ilya Verbin's avatar Ilya Verbin Committed by Vladimir Davydov
Browse files

core: get rid of fiber_set_cancellable in hot_standby_f

Currently it's possible to wakeup a `hot_standby_f` fiber from Lua,
this does not lead to any error, but it results in redundant
`recover_remaining_wals` calls.
This patch handles such spurious wakeups in `hot_standby_f`.

Part of #7166

NO_DOC=refactoring
NO_TEST=refactoring
NO_CHANGELOG=refactoring
parent 6e5b89e0
No related branches found
No related tags found
No related merge requests found
...@@ -403,8 +403,7 @@ class WalSubscription { ...@@ -403,8 +403,7 @@ class WalSubscription {
void wakeup(unsigned events) void wakeup(unsigned events)
{ {
this->events |= events; this->events |= events;
if (f->flags & FIBER_IS_CANCELLABLE) fiber_wakeup(f);
fiber_wakeup(f);
} }
WalSubscription(const char *wal_dir) WalSubscription(const char *wal_dir)
...@@ -500,14 +499,12 @@ hot_standby_f(va_list ap) ...@@ -500,14 +499,12 @@ hot_standby_f(va_list ap)
r->cursor.name : NULL); r->cursor.name : NULL);
bool timed_out = false; bool timed_out = false;
if (subscription.events == 0) { ev_tstamp deadline = ev_monotonic_now(loop())
/** + wal_dir_rescan_delay;
* Allow an immediate wakeup/break loop while (r->watcher != NULL &&
* from recovery_stop_local(). !timed_out &&
*/ subscription.events == 0) {
fiber_set_cancellable(true); timed_out = fiber_yield_deadline(deadline);
timed_out = fiber_yield_timeout(wal_dir_rescan_delay);
fiber_set_cancellable(false);
} }
scan_dir = timed_out || scan_dir = timed_out ||
...@@ -538,6 +535,7 @@ recovery_stop_local(struct recovery *r) ...@@ -538,6 +535,7 @@ recovery_stop_local(struct recovery *r)
{ {
if (r->watcher) { if (r->watcher) {
struct fiber *f = r->watcher; struct fiber *f = r->watcher;
/* Break the loop in hot_standby_f(). */
r->watcher = NULL; r->watcher = NULL;
fiber_cancel(f); fiber_cancel(f);
if (fiber_join(f) != 0) if (fiber_join(f) != 0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment