[Tarantool-patches] [PATCH v2 1/2] engine: add is_scheduled arg to engine->begin_checkpoint

Nikita Pettik korablev at tarantool.org
Tue Apr 28 04:03:42 MSK 2020


In some cases it may turn out to be useful to know whether checkpoint
process was launched manually (explicitly calling box.snapshot()) or
automatically via checkpoint daemon. In particular, to unthrottle vinyl
scheduler when it comes for manual checkpoints. So let's extend engine's
vtab method begin_checkpoint() with corresponding argument.

Needed for #3519
---
 src/box/engine.c       | 7 ++++---
 src/box/engine.h       | 6 +++---
 src/box/gc.c           | 8 ++++----
 src/box/memtx_engine.c | 3 ++-
 src/box/vinyl.c        | 3 ++-
 5 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/src/box/engine.c b/src/box/engine.c
index 8dc0df1d0..88ed92861 100644
--- a/src/box/engine.c
+++ b/src/box/engine.c
@@ -129,11 +129,11 @@ engine_end_recovery(void)
 }
 
 int
-engine_begin_checkpoint(void)
+engine_begin_checkpoint(bool is_scheduled)
 {
 	struct engine *engine;
 	engine_foreach(engine) {
-		if (engine->vtab->begin_checkpoint(engine) < 0)
+		if (engine->vtab->begin_checkpoint(engine, is_scheduled) < 0)
 			return -1;
 	}
 	return 0;
@@ -356,9 +356,10 @@ generic_engine_end_recovery(struct engine *engine)
 }
 
 int
-generic_engine_begin_checkpoint(struct engine *engine)
+generic_engine_begin_checkpoint(struct engine *engine, bool is_scheduled)
 {
 	(void)engine;
+	(void)is_scheduled;
 	return 0;
 }
 
diff --git a/src/box/engine.h b/src/box/engine.h
index 07d7fac9b..c4da01e13 100644
--- a/src/box/engine.h
+++ b/src/box/engine.h
@@ -157,7 +157,7 @@ struct engine_vtab {
 	 * engine (snapshot is a memtx idea of a checkpoint).
 	 * Must not yield.
 	 */
-	int (*begin_checkpoint)(struct engine *);
+	int (*begin_checkpoint)(struct engine *, bool is_scheduled);
 	/**
 	 * Wait for a checkpoint to complete.
 	 */
@@ -354,7 +354,7 @@ void
 engine_complete_join(struct engine_join_ctx *ctx);
 
 int
-engine_begin_checkpoint(void);
+engine_begin_checkpoint(bool is_scheduled);
 
 /**
  * Create a checkpoint.
@@ -396,7 +396,7 @@ int generic_engine_begin_initial_recovery(struct engine *,
 					  const struct vclock *);
 int generic_engine_begin_final_recovery(struct engine *);
 int generic_engine_end_recovery(struct engine *);
-int generic_engine_begin_checkpoint(struct engine *);
+int generic_engine_begin_checkpoint(struct engine *, bool);
 int generic_engine_wait_checkpoint(struct engine *, const struct vclock *);
 void generic_engine_commit_checkpoint(struct engine *, const struct vclock *);
 void generic_engine_abort_checkpoint(struct engine *);
diff --git a/src/box/gc.c b/src/box/gc.c
index cbcdf7d12..8e8ffea75 100644
--- a/src/box/gc.c
+++ b/src/box/gc.c
@@ -377,7 +377,7 @@ gc_add_checkpoint(const struct vclock *vclock)
 }
 
 static int
-gc_do_checkpoint(void)
+gc_do_checkpoint(bool is_scheduled)
 {
 	int rc;
 	struct wal_checkpoint checkpoint;
@@ -389,7 +389,7 @@ gc_do_checkpoint(void)
 	 * Rotate WAL and call engine callbacks to create a checkpoint
 	 * on disk for each registered engine.
 	 */
-	rc = engine_begin_checkpoint();
+	rc = engine_begin_checkpoint(is_scheduled);
 	if (rc != 0)
 		goto out;
 	rc = wal_begin_checkpoint(&checkpoint);
@@ -436,7 +436,7 @@ gc_checkpoint(void)
 				gc.checkpoint_schedule.interval);
 	fiber_wakeup(gc.checkpoint_fiber);
 
-	if (gc_do_checkpoint() != 0)
+	if (gc_do_checkpoint(false) != 0)
 		return -1;
 
 	/*
@@ -506,7 +506,7 @@ gc_checkpoint_fiber_f(va_list ap)
 			 */
 			continue;
 		}
-		if (gc_do_checkpoint() != 0)
+		if (gc_do_checkpoint(true) != 0)
 			diag_log();
 	}
 	return 0;
diff --git a/src/box/memtx_engine.c b/src/box/memtx_engine.c
index 4da80824a..394c5d974 100644
--- a/src/box/memtx_engine.c
+++ b/src/box/memtx_engine.c
@@ -619,8 +619,9 @@ fail:
 }
 
 static int
-memtx_engine_begin_checkpoint(struct engine *engine)
+memtx_engine_begin_checkpoint(struct engine *engine, bool is_scheduled)
 {
+	(void) is_scheduled;
 	struct memtx_engine *memtx = (struct memtx_engine *)engine;
 
 	assert(memtx->checkpoint == NULL);
diff --git a/src/box/vinyl.c b/src/box/vinyl.c
index ea4839dea..2a01322f7 100644
--- a/src/box/vinyl.c
+++ b/src/box/vinyl.c
@@ -2726,8 +2726,9 @@ vinyl_engine_set_snap_io_rate_limit(struct engine *engine, double limit)
 /* {{{ Checkpoint */
 
 static int
-vinyl_engine_begin_checkpoint(struct engine *engine)
+vinyl_engine_begin_checkpoint(struct engine *engine, bool is_scheduled)
 {
+	(void) is_scheduled;
 	struct vy_env *env = vy_env(engine);
 	assert(env->status == VINYL_ONLINE);
 	/*
-- 
2.17.1



More information about the Tarantool-patches mailing list