diff --git a/src/box/box.cc b/src/box/box.cc index b4867af3d4ce3b08e0a0685467595e4ae3849a1c..0a3a80adf8784ae6ac778ae3a66ca420e20cf062 100644 --- a/src/box/box.cc +++ b/src/box/box.cc @@ -634,6 +634,9 @@ box_snapshot(void) if (status != 0) goto error; + /* complete snapshot */ + tuple_end_snapshot(); + /* wait for engine snapshot completion */ engine_foreach(box_snapshot_wait_engine, &snap_lsn); @@ -646,8 +649,6 @@ box_snapshot(void) /* remove previous snapshot reference */ engine_foreach(box_snapshot_delete_engine, &snapshot_last_lsn); - /* complete snapshot */ - tuple_end_snapshot(); snapshot_last_lsn = snap_lsn; snapshot_pid = 0; diff --git a/src/box/engine.cc b/src/box/engine.cc index ffa5283039967573ee6cf4774f36f7d7c7a2d9a9..4c4d5f119c06d378cb373b4d26652378e70b6beb 100644 --- a/src/box/engine.cc +++ b/src/box/engine.cc @@ -28,6 +28,7 @@ */ #include "engine.h" #include "space.h" +#include "schema.h" #include "exception.h" #include "salad/rlist.h" #include <stdlib.h> @@ -108,3 +109,53 @@ void engine_shutdown() delete e; } } + +static void +do_one_recover_step(struct space *space, void * /* param */) +{ + if (space_index(space, 0)) { + space->engine->recover(space); + } else { + /* in case of space has no primary index, + * derive it's engine handler recovery state from + * the global one. */ + space->engine->initRecovery(); + } +} + +static inline void +space_end_recover_snapshot_cb(EngineFactory *f, void *udate) +{ + (void)udate; + f->recoveryEvent(END_RECOVERY_SNAPSHOT); +} + +void +space_end_recover_snapshot() +{ + /* + * For all new spaces created from now on, when the + * PRIMARY key is added, enable it right away. + */ + engine_foreach(space_end_recover_snapshot_cb, NULL); + space_foreach(do_one_recover_step, NULL); +} + +static inline void +space_end_recover_cb(EngineFactory *f, void *udate) +{ + (void)udate; + f->recoveryEvent(END_RECOVERY); +} + +void +space_end_recover() +{ + /* + * For all new spaces created after recovery is complete, + * when the primary key is added, enable all keys. + */ + engine_foreach(space_end_recover_cb, NULL); + + space_foreach(do_one_recover_step, NULL); +} diff --git a/src/box/engine.h b/src/box/engine.h index e14134510271d9eb4ee151fff2009c26b40a2616..9bc0f5c692ae9b24dfe7ee12c87d37144a9e1fe5 100644 --- a/src/box/engine.h +++ b/src/box/engine.h @@ -218,4 +218,18 @@ engine_id(Engine *engine) return engine->factory->id; } +/** + * Called at the end of recovery from snapshot. + * Build primary keys in all spaces. + * */ +void +space_end_recover_snapshot(); + +/** + * Called at the end of recovery. + * Build secondary keys in all spaces. + */ +void +space_end_recover(); + #endif /* TARANTOOL_BOX_ENGINE_H_INCLUDED */ diff --git a/src/box/schema.cc b/src/box/schema.cc index 6ce440d4290dc1162a92448a0ed9dc300dd0c623..be69a719736149386c75e3c2f2c2225e17da02d3 100644 --- a/src/box/schema.cc +++ b/src/box/schema.cc @@ -163,19 +163,6 @@ space_cache_replace(struct space *space) return p_old ? (struct space *) p_old->val : NULL; } -static void -do_one_recover_step(struct space *space, void * /* param */) -{ - if (space_index(space, 0)) { - space->engine->recover(space); - } else { - /* in case of space has no primary index, - * derive it's engine handler recovery state from - * the global one. */ - space->engine->initRecovery(); - } -} - /** A wrapper around space_new() for data dictionary spaces. */ struct space * sc_space_new(struct space_def *space_def, @@ -307,44 +294,6 @@ schema_init() key_def_delete(key_def); } -static inline void -space_end_recover_snapshot_cb(EngineFactory *f, void *udate) -{ - (void)udate; - f->recoveryEvent(END_RECOVERY_SNAPSHOT); -} - -void -space_end_recover_snapshot() -{ - /* - * For all new spaces created from now on, when the - * PRIMARY key is added, enable it right away. - */ - engine_foreach(space_end_recover_snapshot_cb, NULL); - - space_foreach(do_one_recover_step, NULL); -} - -static inline void -space_end_recover_cb(EngineFactory *f, void *udate) -{ - (void)udate; - f->recoveryEvent(END_RECOVERY); -} - -void -space_end_recover() -{ - /* - * For all new spaces created after recovery is complete, - * when the primary key is added, enable all keys. - */ - engine_foreach(space_end_recover_cb, NULL); - - space_foreach(do_one_recover_step, NULL); -} - void schema_free(void) { diff --git a/src/box/schema.h b/src/box/schema.h index cbd77926c2fe8d50f7602a04b1cc873b2d48c94d..5aea8ea7f61c676fd910f49bcdf967f39845cd46 100644 --- a/src/box/schema.h +++ b/src/box/schema.h @@ -105,20 +105,6 @@ schema_init(); void schema_free(); -/** - * Called at the end of recovery from snapshot. - * Build primary keys in all spaces. - * */ -void -space_end_recover_snapshot(); - -/** - * Called at the end of recovery. - * Build secondary keys in all spaces. - */ -void -space_end_recover(); - struct space *schema_space(uint32_t id); /* @@ -163,5 +149,4 @@ func_by_name(const char *name, uint32_t name_len) bool schema_find_grants(const char *type, uint32_t id); - #endif /* INCLUDES_TARANTOOL_BOX_SCHEMA_H */