diff --git a/cfg/tarantool_box_cfg.c b/cfg/tarantool_box_cfg.c index d036612b1e92fe82d43834823eb9e54f2d433095..2924909e017906eded4ee0697636f28b56212ef9 100644 --- a/cfg/tarantool_box_cfg.c +++ b/cfg/tarantool_box_cfg.c @@ -24,8 +24,52 @@ cmpNameAtoms(NameAtom *a, NameAtom *b) { return (a == NULL && b == NULL) ? 1 : 0; } +void +init_tarantool_cfg(tarantool_cfg *c) { + c->__confetti_flags = 0; + + c->username = NULL; + c->coredump = 0; + c->admin_port = 0; + c->log_level = 0; + c->slab_alloc_arena = 0; + c->slab_alloc_minimal = 0; + c->slab_alloc_factor = 0; + c->work_dir = NULL; + c->pid_file = NULL; + c->logger = NULL; + c->logger_nonblock = 0; + c->io_collect_interval = 0; + c->backlog = 0; + c->readahead = 0; + c->snap_dir = NULL; + c->wal_dir = NULL; + c->primary_port = 0; + c->secondary_port = 0; + c->too_long_threshold = 0; + c->custom_proc_title = NULL; + c->memcached = 0; + c->memcached_namespace = 0; + c->memcached_expire_per_loop = 0; + c->memcached_expire_full_sweep = 0; + c->snap_io_rate_limit = 0; + c->rows_per_wal = 0; + c->wal_fsync_delay = 0; + c->wal_writer_inbox_size = 0; + c->local_hot_standby = 0; + c->wal_dir_rescan_delay = 0; + c->panic_on_snap_error = 0; + c->panic_on_wal_error = 0; + c->remote_hot_standby = 0; + c->wal_feeder_ipaddr = NULL; + c->wal_feeder_port = 0; + c->namespace = NULL; +} + int fill_default_tarantool_cfg(tarantool_cfg *c) { + c->__confetti_flags = 0; + c->username = NULL; c->coredump = 0; c->admin_port = 0; diff --git a/cfg/tarantool_box_cfg.h b/cfg/tarantool_box_cfg.h index 19d130b16c59fd16044c1034fc9807cd6f77acec..d1d777b2fe4cf3138ba63c1615874805cb3bd5c3 100644 --- a/cfg/tarantool_box_cfg.h +++ b/cfg/tarantool_box_cfg.h @@ -170,6 +170,8 @@ typedef struct tarantool_cfg { #define CNF_STRUCT_DEFINED(s) ((s) != NULL && ((s)->__confetti_flags & CNF_FLAG_STRUCT_NOTSET) == 0) #endif +void init_tarantool_cfg(tarantool_cfg *c); + int fill_default_tarantool_cfg(tarantool_cfg *c); void parse_cfg_file_tarantool_cfg(tarantool_cfg *c, FILE *fh, int check_rdonly, int *n_accepted, int *n_skipped); diff --git a/cfg/tarantool_feeder_cfg.c b/cfg/tarantool_feeder_cfg.c index 654730105b994c4489d404c6b33bc4c3e85025e3..c1119f2157fda5eb9ddde5cdb6d0a1b2fb917430 100644 --- a/cfg/tarantool_feeder_cfg.c +++ b/cfg/tarantool_feeder_cfg.c @@ -24,8 +24,34 @@ cmpNameAtoms(NameAtom *a, NameAtom *b) { return (a == NULL && b == NULL) ? 1 : 0; } +void +init_tarantool_cfg(tarantool_cfg *c) { + c->__confetti_flags = 0; + + c->username = NULL; + c->coredump = 0; + c->admin_port = 0; + c->log_level = 0; + c->slab_alloc_arena = 0; + c->slab_alloc_minimal = 0; + c->slab_alloc_factor = 0; + c->work_dir = NULL; + c->pid_file = NULL; + c->logger = NULL; + c->logger_nonblock = 0; + c->io_collect_interval = 0; + c->backlog = 0; + c->readahead = 0; + c->wal_feeder_bind_ipaddr = NULL; + c->wal_feeder_bind_port = 0; + c->wal_feeder_dir = NULL; + c->custom_proc_title = NULL; +} + int fill_default_tarantool_cfg(tarantool_cfg *c) { + c->__confetti_flags = 0; + c->username = NULL; c->coredump = 0; c->admin_port = 0; diff --git a/cfg/tarantool_feeder_cfg.h b/cfg/tarantool_feeder_cfg.h index f65ae646ddb4aaeabacde8c879558162f164b5d6..8384d02ded333f1a3e3d2963956fe4170c14359d 100644 --- a/cfg/tarantool_feeder_cfg.h +++ b/cfg/tarantool_feeder_cfg.h @@ -86,6 +86,8 @@ typedef struct tarantool_cfg { #define CNF_STRUCT_DEFINED(s) ((s) != NULL && ((s)->__confetti_flags & CNF_FLAG_STRUCT_NOTSET) == 0) #endif +void init_tarantool_cfg(tarantool_cfg *c); + int fill_default_tarantool_cfg(tarantool_cfg *c); void parse_cfg_file_tarantool_cfg(tarantool_cfg *c, FILE *fh, int check_rdonly, int *n_accepted, int *n_skipped); diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 42546162d6893e56d3319b132abfc1ff8fe816af..e8cb94d5081188d233c47c6a4eb807c38afd8197 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -56,7 +56,7 @@ set (recompiled_core_sources set (common_sources tbuf.m palloc.m util.m diagnostics.m salloc.m pickle.m coro.m stat.m log_io.m - log_io_remote.m iproto.m exceptions.m errcode.c latch.c) + log_io_remote.m iproto.m exceptions.m errcode.c latch.m) if (ENABLE_TRACE) set (common_sources ${common_sources} trace.m) diff --git a/core/latch.c b/core/latch.m similarity index 82% rename from core/latch.c rename to core/latch.m index 8d5f9b956f38e75fb01b86647a1f9827bc4521dc..2c3b5268ee9159dbdb161e9a53b2ba7e20e02ee9 100644 --- a/core/latch.c +++ b/core/latch.m @@ -27,21 +27,39 @@ void tnt_latch_init(struct tnt_latch *latch) { latch->locked = false; + latch->owner = NULL; } -bool +void +tnt_latch_destroy(struct tnt_latch *latch) +{ + assert(latch->locked == false); + + latch->owner = NULL; +} + +int tnt_latch_trylock(struct tnt_latch *latch) { - if (latch->locked) - return false; + if (latch->locked) { + assert(latch->owner != fiber); + + return -1; + } + + assert(latch->owner == NULL); latch->locked = true; + latch->owner = fiber; - return true; + return 0; } void tnt_latch_unlock(struct tnt_latch *latch) { + assert(latch->owner == fiber); + latch->locked = false; + latch->owner = NULL; } diff --git a/core/log_io_remote.m b/core/log_io_remote.m index 9af536fbee54daaa64a125653e753ddde378a7e5..9da5ed6d15d9bd76737e6249c8c88e0d1e2808f8 100644 --- a/core/log_io_remote.m +++ b/core/log_io_remote.m @@ -133,22 +133,19 @@ pull_from_remote(void *state) struct remote_state *h = state; struct tbuf *row; - fiber_setcancelstate(true); - for (;;) { + fiber_setcancelstate(true); row = remote_read_row(h->r->confirmed_lsn + 1); + fiber_setcancelstate(false); + h->r->recovery_lag = ev_now() - row_v11(row)->tm; h->r->recovery_last_update_tstamp = ev_now(); - fiber_setcancelstate(false); - if (h->handler(h->r, row) < 0) { fiber_close(); continue; } - fiber_setcancelstate(true); - fiber_gc(); } } diff --git a/core/tarantool.m b/core/tarantool.m index 69d702e7ff10d3764365611921656098cbbb9866..0483df8d7056e124a325dd9b7e341cd64a8c1167 100644 --- a/core/tarantool.m +++ b/core/tarantool.m @@ -70,7 +70,7 @@ bool init_storage, booting = true; extern int daemonize(int nochdir, int noclose); static i32 -load_cfg(struct tarantool_cfg *conf, i32 check_rdonly, bool reload) +load_cfg(struct tarantool_cfg *conf, i32 check_rdonly) { FILE *f; i32 n_accepted, n_skipped; @@ -97,87 +97,86 @@ load_cfg(struct tarantool_cfg *conf, i32 check_rdonly, bool reload) if (n_accepted == 0 || n_skipped != 0) return -1; - return mod_check_config(conf, reload); + return mod_check_config(conf); } -static i32 -reload_cfg_safe(struct tbuf *out) +static void +swap_tarantool_cfg(struct tarantool_cfg *old_cfg, struct tarantool_cfg *new_cfg) { - struct tarantool_cfg new_cfg1, new_cfg2; - i32 ret; - - // Load with checking readonly params - if (dup_tarantool_cfg(&new_cfg1, &cfg) != 0) { - destroy_tarantool_cfg(&new_cfg1); - - return -1; - } - ret = load_cfg(&new_cfg1, 1, true); - if (ret == -1) { - tbuf_append(out, cfg_out->data, cfg_out->len); - - destroy_tarantool_cfg(&new_cfg1); - - return -1; - } - // Load without checking readonly params - if (fill_default_tarantool_cfg(&new_cfg2) != 0) { - destroy_tarantool_cfg(&new_cfg2); - - return -1; - } - ret = load_cfg(&new_cfg2, 0, true); - if (ret == -1) { - tbuf_append(out, cfg_out->data, cfg_out->len); - - destroy_tarantool_cfg(&new_cfg1); - - return -1; - } - // Compare only readonly params - char *diff = cmp_tarantool_cfg(&new_cfg1, &new_cfg2, 1); - if (diff != NULL) { - destroy_tarantool_cfg(&new_cfg1); - destroy_tarantool_cfg(&new_cfg2); + struct tarantool_cfg tmp; - out_warning(0, "Could not accept read only '%s' option", diff); - tbuf_append(out, cfg_out->data, cfg_out->len); - - return -1; - } - destroy_tarantool_cfg(&new_cfg1); - - mod_reload_config(&cfg, &new_cfg2); - - destroy_tarantool_cfg(&cfg); - - cfg = new_cfg2; - - return 0; + tmp = *old_cfg; + *old_cfg = *new_cfg; + *new_cfg = tmp; } i32 reload_cfg(struct tbuf *out) { static struct tnt_latch *latch = NULL; - i32 ret; + struct tarantool_cfg new_cfg, aux_cfg; if (latch == NULL) { latch = palloc(eter_pool, sizeof(*latch)); tnt_latch_init(latch); } - if (tnt_latch_trylock(latch) == false) { - out_warning(0, "Could not reload configuration: it is reloading right now"); + if (tnt_latch_trylock(latch) == -1) { + out_warning(0, "Could not reload configuration: it is being reloaded right now"); + tbuf_append(out, cfg_out->data, cfg_out->len); return -1; } - ret = reload_cfg_safe(out); + @try { + init_tarantool_cfg(&new_cfg); + init_tarantool_cfg(&aux_cfg); - tnt_latch_unlock(latch); + /* + Prepare a copy of the original config file + for confetti, so that it can compare the new + file with the old one when loading the new file. + Load the new file and return an error if the it + contains a different value for some read-only + parameter. + */ + if (dup_tarantool_cfg(&aux_cfg, &cfg) != 0 || + load_cfg(&aux_cfg, 1) != 0) + return -1; + /* + Load the new configuration file, but + skip the check for read only parameters. + new_cfg contains only defaults and + new settings. + */ + if (fill_default_tarantool_cfg(&new_cfg) != 0 || + load_cfg(&new_cfg, 0) != 0) + return -1; + + /* Check that no default value has been changed. */ + char *diff = cmp_tarantool_cfg(&aux_cfg, &new_cfg, 1); + if (diff != NULL) { + out_warning(0, "Could not accept read only '%s' option", diff); + return -1; + } + + /* Now pass the config to the module, to take action. */ + if (mod_reload_config(&cfg, &new_cfg) != 0) + return -1; + /* All OK, activate the config. */ + swap_tarantool_cfg(&cfg, &new_cfg); + } + @finally { + destroy_tarantool_cfg(&aux_cfg); + destroy_tarantool_cfg(&new_cfg); - return ret; + if (cfg_out->len != 0) + tbuf_append(out, cfg_out->data, cfg_out->len); + + tnt_latch_unlock(latch); + } + + return 0; } const char * @@ -445,7 +444,7 @@ main(int argc, char **argv) assert(cfg_out); if (gopt(opt, 'k')) { - if (fill_default_tarantool_cfg(&cfg) != 0 || load_cfg(&cfg, 0, false) != 0) { + if (fill_default_tarantool_cfg(&cfg) != 0 || load_cfg(&cfg, 0) != 0) { say_error("check_config FAILED" "%.*s", cfg_out->len, (char *)cfg_out->data); @@ -455,7 +454,7 @@ main(int argc, char **argv) return 0; } - if (fill_default_tarantool_cfg(&cfg) != 0 || load_cfg(&cfg, 0, false) != 0) + if (fill_default_tarantool_cfg(&cfg) != 0 || load_cfg(&cfg, 0) != 0) panic("can't load config:" "%.*s", cfg_out->len, (char *)cfg_out->data); diff --git a/include/latch.h b/include/latch.h index b202ebd4c8d4f87993250d098fe664d68fa9bc68..a86c35a15d7b8911e2800b2b3ca075515b9a003f 100644 --- a/include/latch.h +++ b/include/latch.h @@ -23,16 +23,20 @@ * SUCH DAMAGE. */ +#include <fiber.h> + #include <stdbool.h> /* * Internal implementation of a container for a mutex like object * with similar interface. It's used boolean variable because of * single threaded nature of tarantool. But it's rather simple to change - * this varibable to a mutex object to maintain multi threaded aproach. + * this variable to a mutex object to maintain multi threaded approach. */ struct tnt_latch { bool locked; + + struct fiber *owner; }; /** @@ -41,13 +45,17 @@ struct tnt_latch { * @param latch Latch to be initialized. */ void tnt_latch_init(struct tnt_latch *latch); +/** + * Destroy the given latch. + */ +void tnt_latch_destroy(struct tnt_latch *latch); /** * Set the latch to the locked state. If it's already locked - * returns false value immediatly. + * returns -1 value immediately otherwise returns 0. * * @param latch Latch to be locked. */ -bool tnt_latch_trylock(struct tnt_latch *latch); +int tnt_latch_trylock(struct tnt_latch *latch); /** * Unlock the locked latch. * diff --git a/include/tarantool.h b/include/tarantool.h index 0bd70d571d6d8df5c5e15756d012ab3c1d390624..29301ecdb9c8f8ce602ef8086ca4f56a8246a0e5 100644 --- a/include/tarantool.h +++ b/include/tarantool.h @@ -35,8 +35,8 @@ void mod_init(void); struct tarantool_cfg; extern const char *mod_name; -i32 mod_check_config(struct tarantool_cfg *conf, bool reload); -void mod_reload_config(struct tarantool_cfg *old_conf, struct tarantool_cfg *new_conf); +i32 mod_check_config(struct tarantool_cfg *conf); +i32 mod_reload_config(struct tarantool_cfg *old_conf, struct tarantool_cfg *new_conf); int mod_cat(const char *filename); void mod_snapshot(struct log_io_iter *); void mod_info(struct tbuf *out); diff --git a/mod/box/box.m b/mod/box/box.m index df44b50d4cadb8192af14a2e757db49a0a77e028..20a4cf15ba8ac41bbf2a55ec91002e5cb40f3e94 100644 --- a/mod/box/box.m +++ b/mod/box/box.m @@ -1396,27 +1396,31 @@ memcached_bound_to_primary(void *data __attribute__((unused))) } i32 -mod_check_config(struct tarantool_cfg *new_conf, bool reload) +mod_check_config(struct tarantool_cfg *conf) { - if (!reload) - return 0; + if (conf->remote_hot_standby > 0 && conf->local_hot_standby > 0) { + out_warning(0, "Remote and local hot standby modes " + "can't be enabled simultaneously"); - if (cfg.remote_hot_standby != new_conf->remote_hot_standby) { + return -1; + } + + return 0; +} + +i32 +mod_reload_config(struct tarantool_cfg *old_conf, struct tarantool_cfg *new_conf) +{ + if (old_conf->remote_hot_standby != new_conf->remote_hot_standby) { if (recovery_state->finalize != true) { out_warning(0, "Could not propagate %s before local recovery finished", - cfg.remote_hot_standby == true ? "slave to master" : + old_conf->remote_hot_standby == true ? "slave to master" : "master to slave"); return -1; } } - return 0; -} - -void -mod_reload_config(struct tarantool_cfg *old_conf, struct tarantool_cfg *new_conf) -{ if (old_conf->remote_hot_standby != new_conf->remote_hot_standby) { /* Local recovery must be finalized at this point */ assert(recovery_state->finalize == true); @@ -1427,7 +1431,7 @@ mod_reload_config(struct tarantool_cfg *old_conf, struct tarantool_cfg *new_conf old_conf->wal_feeder_port != new_conf->wal_feeder_port)) remote_recovery_restart(new_conf); - return; + return 0; } void diff --git a/mod/feeder/feeder.m b/mod/feeder/feeder.m index 8e34f5a911b1ab86ca797bc97231d92c53c202d0..2176767be4ae38d9c947515d89bf28e632339595 100644 --- a/mod/feeder/feeder.m +++ b/mod/feeder/feeder.m @@ -95,16 +95,16 @@ recover_feed_slave(int sock) } i32 -mod_check_config(struct tarantool_cfg *conf __attribute__((unused)), bool reload __attribute__((unused))) +mod_check_config(struct tarantool_cfg *conf __attribute__((unused))) { return 0; } -void +i32 mod_reload_config(struct tarantool_cfg *old_conf __attribute__((unused)), struct tarantool_cfg *new_conf __attribute__((unused))) { - return; + return 0; } void diff --git a/test/box_replication/common.test b/test/box_replication/common.test index eac6bc1ce3f9c2aed672966b1019bda3126b71e3..694f613d7550053a48ca6162eb4c7d57ee3744a7 100644 --- a/test/box_replication/common.test +++ b/test/box_replication/common.test @@ -34,7 +34,7 @@ print """ """ for i in range(1, 10): master.sql.execute("insert into t0 values ({0}, 'the tuple #{0}')".format(i), - noprint=False) + silent=False) print """ # @@ -43,7 +43,7 @@ print """ """ for i in range(1, 10): master.sql.execute("select * from t0 where k0 = {0}".format(i), - noprint=False) + silent=False) slave.wait_sync(10) @@ -54,7 +54,7 @@ print """ """ for i in range(1,10): slave.sql.execute("select * from t0 where k0 = {0}".format(i), - noprint=False) + silent=False) print """ # @@ -62,7 +62,7 @@ print """ # """ slave.sql.execute("insert into t0 values (100, 'the tuple #100')", - noprint=False) + silent=False) print """ # @@ -77,9 +77,9 @@ print """ # """ slave.sql.execute("insert into t0 values (100, 'the tuple #100')", - noprint=False) + silent=False) slave.sql.execute("select * from t0 where k0 = 100", - noprint=False) + silent=False) print """ # @@ -96,13 +96,17 @@ print """ master.reconfigure("box_replication/tarantool_to_slave.cfg") master.wait_sync(11) master.sql.execute("select * from t0 where k0 = 100", - noprint=False) + silent=False) # Cleanup. beholder.stop() +beholder.cleanup(True) feeder.stop() -slave.stop() +feeder.cleanup(True) slave_feeder.stop() +slave_feeder.cleanup(True) +slave.stop() +slave.cleanup(True) server.stop() server.deploy(self.suite_ini["config"]) diff --git a/test/box_replication/feeder.cfg b/test/box_replication/feeder.cfg index 694ea975511adc91c697e1fcacf3d89150c3a146..99eae82a96660cef3cd319cb07c04da0679443ca 100644 --- a/test/box_replication/feeder.cfg +++ b/test/box_replication/feeder.cfg @@ -1,4 +1,4 @@ -pid_file = "feeder.pid" +pid_file = "tarantool.pid" wal_feeder_bind_ipaddr = "127.0.0.1" wal_feeder_bind_port = 33016 diff --git a/test/box_replication/feeder_slave.cfg b/test/box_replication/feeder_slave.cfg index 88f6832c813651a0f20bef3806acb88fe4d30710..fbe20480cb82e89927bf68baa7f4dae233fc994e 100644 --- a/test/box_replication/feeder_slave.cfg +++ b/test/box_replication/feeder_slave.cfg @@ -1,4 +1,4 @@ -pid_file = "feeder.pid" +pid_file = "tarantool.pid" wal_feeder_bind_ipaddr = "127.0.0.1" wal_feeder_bind_port = 33116 diff --git a/test/box_replication/tarantool.cfg b/test/box_replication/tarantool.cfg index db7ecff892dbb57fd0c2b38ac9240a466aad7c46..212ed8616732320f922c9f137faf77e583b77033 100644 --- a/test/box_replication/tarantool.cfg +++ b/test/box_replication/tarantool.cfg @@ -1,43 +1,9 @@ -# -# Limit of memory used to store tuples to 100MB -# (0.1 GB) -# This effectively limits the memory, used by -# Tarantool. However, index and connection memory -# is stored outside the slab allocator, hence -# the effective memory usage can be higher (sometimes -# twice as high). -# -slab_alloc_arena = 0.1 +pid_file = "tarantool.pid" -# -# Store the pid in this file. Relative to -# startup dir. -# -pid_file = "box.pid" - -# -# Pipe the logs into the following process. -# Use -a rather than --append to work correctly on FreeBSD -# -logger="tee -a tarantool.log" - -# -# Read only and read-write port. primary_port = 33013 -# Read-only port. secondary_port = 33014 -# -# The port for administrative commands. -# admin_port = 33015 -# -# Each write ahead log contains this many rows. -# When the limit is reached, Tarantool closes -# the WAL and starts a new one. -rows_per_wal = 50 -# Define a simple namespace with 1 HASH-based -# primary key. namespace[0].enabled = 1 namespace[0].index[0].type = "HASH" namespace[0].index[0].unique = 1 diff --git a/test/box_replication/tarantool_beholder.cfg b/test/box_replication/tarantool_beholder.cfg index f96098e679d9d9992fd6d9da1fc85d2cae828d3d..14d623b2d1e00a7880f24dd59aece90698226f97 100644 --- a/test/box_replication/tarantool_beholder.cfg +++ b/test/box_replication/tarantool_beholder.cfg @@ -1,37 +1,9 @@ -# -# Limit of memory used to store tuples to 100MB -# (0.1 GB) -# This effectively limits the memory, used by -# Tarantool. However, index and connection memory -# is stored outside the slab allocator, hence -# the effective memory usage can be higher (sometimes -# twice as high). -# -slab_alloc_arena = 0.1 +pid_file = "tarantool.pid" -# -# Store the pid in this file. Relative to -# startup dir. -# -pid_file = "box_beholder.pid" - -# -# Read only and read-write port. primary_port = 33013 -# Read-only port. secondary_port = 33024 -# -# The port for administrative commands. -# admin_port = 33025 -# -# Each write ahead log contains this many rows. -# When the limit is reached, Tarantool closes -# the WAL and starts a new one. -rows_per_wal = 50 -# Define a simple namespace with 1 HASH-based -# primary key. namespace[0].enabled = 1 namespace[0].index[0].type = "HASH" namespace[0].index[0].unique = 1 diff --git a/test/box_replication/tarantool_beholder_to_slave.cfg b/test/box_replication/tarantool_beholder_to_slave.cfg index 1f761746f9292d617d4c70904de183759329de8a..e4e8a1af38c7b2d3cec83c2bc6a3e9662ffb619b 100644 --- a/test/box_replication/tarantool_beholder_to_slave.cfg +++ b/test/box_replication/tarantool_beholder_to_slave.cfg @@ -1,45 +1,15 @@ -# -# Limit of memory used to store tuples to 100MB -# (0.1 GB) -# This effectively limits the memory, used by -# Tarantool. However, index and connection memory -# is stored outside the slab allocator, hence -# the effective memory usage can be higher (sometimes -# twice as high). -# -slab_alloc_arena = 0.1 +pid_file = "tarantool.pid" -# -# Store the pid in this file. Relative to -# startup dir. -# -pid_file = "box_beholder.pid" - -# -# Read only and read-write port. primary_port = 33013 -# Read-only port. secondary_port = 33024 -# -# The port for administrative commands. -# admin_port = 33025 -# -# Each write ahead log contains this many rows. -# When the limit is reached, Tarantool closes -# the WAL and starts a new one. -rows_per_wal = 50 -# Define a simple namespace with 1 HASH-based -# primary key. namespace[0].enabled = 1 namespace[0].index[0].type = "HASH" namespace[0].index[0].unique = 1 namespace[0].index[0].key_field[0].fieldno = 0 namespace[0].index[0].key_field[0].type = "NUM" -# Defines an address of a remote feeder that should push -# updates to a server. remote_hot_standby = 1 wal_feeder_ipaddr = "127.0.0.1" wal_feeder_port = 33116 diff --git a/test/box_replication/tarantool_slave.cfg b/test/box_replication/tarantool_slave.cfg index b772d503d9d8113a4ab7dc8246590e26fec39a2f..3170af2d724c10d0a2ff02197783435c065908f2 100644 --- a/test/box_replication/tarantool_slave.cfg +++ b/test/box_replication/tarantool_slave.cfg @@ -1,51 +1,15 @@ -# -# Limit of memory used to store tuples to 100MB -# (0.1 GB) -# This effectively limits the memory, used by -# Tarantool. However, index and connection memory -# is stored outside the slab allocator, hence -# the effective memory usage can be higher (sometimes -# twice as high). -# -slab_alloc_arena = 0.1 +pid_file = "tarantool.pid" -# -# Store the pid in this file. Relative to -# startup dir. -# -pid_file = "box.pid" - -# -# Pipe the logs into the following process. -# Use -a rather than --append to work correctly on FreeBSD -# -logger="tee -a tarantool.log" - -# -# Read only and read-write port. primary_port = 33113 -# Read-only port. secondary_port = 33114 -# -# The port for administrative commands. -# admin_port = 33115 -# -# Each write ahead log contains this many rows. -# When the limit is reached, Tarantool closes -# the WAL and starts a new one. -rows_per_wal = 50 -# Define a simple namespace with 1 HASH-based -# primary key. namespace[0].enabled = 1 namespace[0].index[0].type = "HASH" namespace[0].index[0].unique = 1 namespace[0].index[0].key_field[0].fieldno = 0 namespace[0].index[0].key_field[0].type = "NUM" -# Defines an address of a remote feeder that should push -# updates to a server. remote_hot_standby = 1 wal_feeder_ipaddr = "127.0.0.1" wal_feeder_port = 33016 diff --git a/test/box_replication/tarantool_slave_to_master.cfg b/test/box_replication/tarantool_slave_to_master.cfg index c803044be6459e2b93889299858234aceb4d36cc..4cc0c24f10895b32b8a660f23fcb95b8aca6130a 100644 --- a/test/box_replication/tarantool_slave_to_master.cfg +++ b/test/box_replication/tarantool_slave_to_master.cfg @@ -1,43 +1,9 @@ -# -# Limit of memory used to store tuples to 100MB -# (0.1 GB) -# This effectively limits the memory, used by -# Tarantool. However, index and connection memory -# is stored outside the slab allocator, hence -# the effective memory usage can be higher (sometimes -# twice as high). -# -slab_alloc_arena = 0.1 +pid_file = "tarantool.pid" -# -# Store the pid in this file. Relative to -# startup dir. -# -pid_file = "box.pid" - -# -# Pipe the logs into the following process. -# Use -a rather than --append to work correctly on FreeBSD -# -logger="tee -a tarantool.log" - -# -# Read only and read-write port. primary_port = 33113 -# Read-only port. secondary_port = 33114 -# -# The port for administrative commands. -# admin_port = 33115 -# -# Each write ahead log contains this many rows. -# When the limit is reached, Tarantool closes -# the WAL and starts a new one. -rows_per_wal = 50 -# Define a simple namespace with 1 HASH-based -# primary key. namespace[0].enabled = 1 namespace[0].index[0].type = "HASH" namespace[0].index[0].unique = 1 diff --git a/test/box_replication/tarantool_to_slave.cfg b/test/box_replication/tarantool_to_slave.cfg index 58d16be3e958630f5d63e86bfeea2745b8c310f9..495fb11c357ec373c458a908c0139243e6fba14c 100644 --- a/test/box_replication/tarantool_to_slave.cfg +++ b/test/box_replication/tarantool_to_slave.cfg @@ -1,51 +1,15 @@ -# -# Limit of memory used to store tuples to 100MB -# (0.1 GB) -# This effectively limits the memory, used by -# Tarantool. However, index and connection memory -# is stored outside the slab allocator, hence -# the effective memory usage can be higher (sometimes -# twice as high). -# -slab_alloc_arena = 0.1 +pid_file = "tarantool.pid" -# -# Store the pid in this file. Relative to -# startup dir. -# -pid_file = "box.pid" - -# -# Pipe the logs into the following process. -# Use -a rather than --append to work correctly on FreeBSD -# -logger="tee -a tarantool.log" - -# -# Read only and read-write port. primary_port = 33013 -# Read-only port. secondary_port = 33014 -# -# The port for administrative commands. -# admin_port = 33015 -# -# Each write ahead log contains this many rows. -# When the limit is reached, Tarantool closes -# the WAL and starts a new one. -rows_per_wal = 50 -# Define a simple namespace with 1 HASH-based -# primary key. namespace[0].enabled = 1 namespace[0].index[0].type = "HASH" namespace[0].index[0].unique = 1 namespace[0].index[0].key_field[0].fieldno = 0 namespace[0].index[0].key_field[0].type = "NUM" -# Defines an address of a remote feeder that should push -# updates to a server. remote_hot_standby = 1 wal_feeder_ipaddr = "127.0.0.1" wal_feeder_port = 33116 diff --git a/test/lib/box.py b/test/lib/box.py index 6f9fb86729c7ddf481039cd5e34e84ca54196e32..edc3f0f90a0612113964ad501a13b4bbc2c433db 100644 --- a/test/lib/box.py +++ b/test/lib/box.py @@ -34,7 +34,7 @@ class Box(TarantoolConnection): res = res + buf return res - def execute_no_reconnect(self, command, noprint=True): + def execute_no_reconnect(self, command, silent=True): statement = sql.parse("sql", command) if statement == None: return "You have an error in your SQL syntax\n" @@ -57,7 +57,7 @@ class Box(TarantoolConnection): else: response = None - if not noprint: + if not silent: print command print statement.unpack(response) diff --git a/test/lib/server.py b/test/lib/server.py index 659da68af99cb58768d4f61859fea461db2da78c..27154999e2a484ddf8c623bcb60189079ea578f5 100644 --- a/test/lib/server.py +++ b/test/lib/server.py @@ -92,12 +92,14 @@ class Server(object): return exe raise RuntimeError("Can't find server executable in " + path) - def cleanup(self): + def cleanup(self, full=False): trash = [] for re in self.re_vardir_cleanup: trash += glob.glob(os.path.join(self.vardir, re)) for filename in trash: os.remove(filename) + if full: + shutil.rmtree(self.vardir) def configure(self, config): self.config = os.path.abspath(config) diff --git a/test/lib/tarantool_admin.py b/test/lib/tarantool_admin.py index 4788002c2933f24e16659c7fcd279c2b9a1a67d7..bce37e34e437514a82535ceb9b7da9e09666e7da 100644 --- a/test/lib/tarantool_admin.py +++ b/test/lib/tarantool_admin.py @@ -29,7 +29,7 @@ from tarantool_connection import TarantoolConnection is_admin_re = re.compile("^\s*(show|save|exec|exit|reload|help)", re.I) class TarantoolAdmin(TarantoolConnection): - def execute_no_reconnect(self, command, noprint): + def execute_no_reconnect(self, command, silent): self.socket.sendall(command) bufsiz = 4096 @@ -46,7 +46,7 @@ class TarantoolAdmin(TarantoolConnection): # validate yaml by parsing it yaml.load(res) - if not noprint: + if not silent: print command.replace('\n', '') print res[:-1] return res diff --git a/test/lib/tarantool_box_server.py b/test/lib/tarantool_box_server.py index 1215ac049d75c3cbaf63391fab0e738e2d6acabd..04bfa7ffef64cb39e074dfc4ad9f219e036001ac 100644 --- a/test/lib/tarantool_box_server.py +++ b/test/lib/tarantool_box_server.py @@ -5,6 +5,7 @@ import ConfigParser from tarantool_server import TarantoolServer, TarantoolConfigFile from tarantool_admin import TarantoolAdmin from box import Box +import time class TarantoolBoxServer(TarantoolServer): def __new__(cls, core="tarantool", module="box"): @@ -37,7 +38,8 @@ class TarantoolBoxServer(TarantoolServer): synced = 0 while synced == 0: synced = 1 - data = self.admin.execute("show info\n", noprint=True) + data = self.admin.execute("show info\n", silent=True) info = yaml.load(data)["info"] if (info["lsn"] != lsn): synced = 0 + time.sleep(0.1) diff --git a/test/lib/tarantool_connection.py b/test/lib/tarantool_connection.py index 4b3c23513d61e1f037200f0f63959407495b3518..50653f8790f6865a6076afad32ec371bc3cc0fbd 100644 --- a/test/lib/tarantool_connection.py +++ b/test/lib/tarantool_connection.py @@ -64,9 +64,9 @@ class TarantoolConnection: else: self.reconnect() - def execute(self, command, noprint=True): + def execute(self, command, silent=True): self.opt_reconnect() - return self.execute_no_reconnect(command, noprint) + return self.execute_no_reconnect(command, silent) def write(self, fragment): """This is to support print >> admin, "command" syntax. diff --git a/test/lib/tarantool_server.py b/test/lib/tarantool_server.py index 7aeca3a413971b9aa0c7a0fa9a5c5bc1a5accc45..7f68075c62d0bdf34284be5911e69769aa9fc1de 100644 --- a/test/lib/tarantool_server.py +++ b/test/lib/tarantool_server.py @@ -46,13 +46,13 @@ class TarantoolServer(Server): config.readfp(TarantoolConfigFile(fp, dummy_section_name)) self.pidfile = config.get(dummy_section_name, "pid_file") - def reconfigure(self, config, noprint=False): + def reconfigure(self, config, silent=False): if config == None: os.unlink(os.path.join(self.vardir, self.default_config_name)) else: self.config = os.path.abspath(config) shutil.copy(self.config, os.path.join(self.vardir, self.default_config_name)) - self.admin.execute("reload configuration\n", noprint=noprint) + self.admin.execute("reload configuration\n", silent=silent) def version(self): p = subprocess.Popen([self.binary, "--version"],