Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
picodata
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Container Registry
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
core
picodata
Commits
74d3109e
Commit
74d3109e
authored
2 years ago
by
Georgy Moshkin
Browse files
Options
Downloads
Patches
Plain Diff
fix(tarantool-sys): yielding on_shutdown triggers on ctrl-d
parent
2b30f83a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!151
Refactor/more minor changes
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tarantool-patches/0009-fix-triggers-fix-yielding-on_shutdown-triggers-on-ct.patch
+59
-0
59 additions, 0 deletions
...ix-triggers-fix-yielding-on_shutdown-triggers-on-ct.patch
with
59 additions
and
0 deletions
tarantool-patches/0009-fix-triggers-fix-yielding-on_shutdown-triggers-on-ct.patch
0 → 100644
+
59
−
0
View file @
74d3109e
From 2242618aceaf955b5ded6d3cda857287e71a7a17 Mon Sep 17 00:00:00 2001
From: Georgy Moshkin <gmoshkin@picodata.io>
Date: Thu, 16 Jun 2022 17:13:58 +0300
Subject: [PATCH] fix(triggers): fix yielding on_shutdown triggers on ctrl-d
The problem was: when on_shutdown triggers are running at the end of the
main function, no event loop is running. So if a trigger yields, then
on_shutdown_fiber yields when trying to join it and returns execution
into the main fiber, which won't ever let the triggers run again.
A fix is to run the event loop in the main fiber while the on_shutdown
triggers are running. This event loop will be interrupted once the
triggers are finished and tarantool will be able to finish successfully.
---
src/main.cc | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/src/main.cc b/src/main.cc
index de082c17f..67ae056f1 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -100,6 +100,11 @@
static double start_time;
static struct fiber *on_shutdown_fiber = NULL;
/** A flag restricting repeated execution of tarantool_exit(). */
static bool is_shutting_down = false;
+/**
+ * A flag preventing main fiber from exiting until on_shutdown triggers have
+ * finished.
+ */
+static bool on_shutdown_is_running = false;
static int exit_code = 0;
double
@@ -136,9 +141,11 @@
static int
on_shutdown_f(va_list ap)
{
(void) ap;
+ on_shutdown_is_running = true;
trigger_fiber_run(&box_on_shutdown_trigger_list, NULL,
on_shutdown_trigger_timeout);
ev_break(loop(), EVBREAK_ALL);
+ on_shutdown_is_running = false;
return 0;
}
@@ -791,6 +803,10 @@
main(int argc, char **argv)
* any signals.
*/
tarantool_exit(exit_code);
+ if (on_shutdown_is_running) {
+ /* on_shutdown_fiber will call ev_break(ALL) after it ends */
+ ev_run(loop(), 0);
+ }
/* freeing resources */
tarantool_free();
return exit_code;
--
2.25.1
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment