Tarantool development patches archive
 help / color / mirror / Atom feed
From: Serge Petrenko <sergepetrenko@tarantool.org>
To: v.shpilevoy@tarantool.org, kyukhin@tarantool.org
Cc: tarantool-patches@dev.tarantool.org
Subject: [Tarantool-patches] [PATCH] feedback_daemon: add synchro replication usage reporting
Date: Tue, 13 Oct 2020 16:34:18 +0300	[thread overview]
Message-ID: <20201013133418.34422-1-sergepetrenko@tarantool.org> (raw)

---
https://github.com/tarantool/tarantool/tree/sp/feedback_daemon_synchro

 src/box/lua/feedback_daemon.lua       | 12 ++++++++++++
 test/box-tap/feedback_daemon.test.lua | 21 ++++++++++++++++++---
 2 files changed, 30 insertions(+), 3 deletions(-)

diff --git a/src/box/lua/feedback_daemon.lua b/src/box/lua/feedback_daemon.lua
index 179e8fb47..aa296c445 100644
--- a/src/box/lua/feedback_daemon.lua
+++ b/src/box/lua/feedback_daemon.lua
@@ -150,6 +150,7 @@ local function fill_in_schema_stats_impl(schema)
         vinyl     = 0,
         temporary = 0,
         ['local'] = 0,
+        sync      = 0,
     }
 
     local indices = {
@@ -188,6 +189,9 @@ local function fill_in_schema_stats_impl(schema)
         if space.is_local then
             spaces['local'] = spaces['local'] + 1
         end
+        if space.is_sync then
+            spaces.sync = spaces.sync + 1
+        end
         fill_in_indices_stats(space, indices)
 
         fiber.yield()
@@ -222,10 +226,18 @@ local function fill_in_features(feedback)
     fill_in_schema_stats(feedback.features)
 end
 
+local function fill_in_options(feedback)
+    local options = {}
+    options.election_mode = box.cfg.election_mode
+    options.synchro_quorum = box.cfg.replication_synchro_quorum
+    feedback.options = options
+end
+
 local function fill_in_feedback(feedback)
     fill_in_base_info(feedback)
     fill_in_platform_info(feedback)
     fill_in_features(feedback)
+    fill_in_options(feedback)
 
     return feedback
 end
diff --git a/test/box-tap/feedback_daemon.test.lua b/test/box-tap/feedback_daemon.test.lua
index a04995d8a..c1ae5f81b 100755
--- a/test/box-tap/feedback_daemon.test.lua
+++ b/test/box-tap/feedback_daemon.test.lua
@@ -67,7 +67,7 @@ if not ok then
     os.exit(0)
 end
 
-test:plan(19)
+test:plan(21)
 
 local function check(message)
     while feedback_count < 1 do
@@ -152,6 +152,7 @@ local expected = {
     vinyl_spaces = 0,
     temporary_spaces = 0,
     local_spaces = 0,
+    sync_spaces = 0,
     tree_indices = 0,
     rtree_indices = 0,
     hash_indices = 0,
@@ -168,6 +169,7 @@ box.schema.create_space('features_vinyl', {engine = 'vinyl'})
 box.schema.create_space('features_memtx_empty')
 box.schema.create_space('features_memtx',
         {engine = 'memtx', is_local = true, temporary = true})
+box.schema.create_space('features_sync', {is_sync=true})
 box.space.features_vinyl:create_index('vinyl_pk', {type = 'tree'})
 box.space.features_memtx:create_index('memtx_pk', {type = 'tree'})
 box.space.features_memtx:create_index('memtx_hash', {type = 'hash'})
@@ -195,11 +197,12 @@ box.space.features_memtx:create_index('functional_multikey',
 actual = daemon.generate_feedback()
 local schema_stats = actual.features.schema
 test:test('features.schema', function(t)
-    t:plan(12)
-    t:is(schema_stats.memtx_spaces, 2, 'memtx engine usage gathered')
+    t:plan(13)
+    t:is(schema_stats.memtx_spaces, 3, 'memtx engine usage gathered')
     t:is(schema_stats.vinyl_spaces, 1, 'vinyl engine usage gathered')
     t:is(schema_stats.temporary_spaces, 1, 'temporary space usage gathered')
     t:is(schema_stats.local_spaces, 1, 'local space usage gathered')
+    t:is(schema_stats.sync_spaces, 1, 'sync space  usage gathered')
     t:is(schema_stats.tree_indices, 6, 'tree index gathered')
     t:is(schema_stats.hash_indices, 1, 'hash index gathered')
     t:is(schema_stats.rtree_indices, 1, 'rtree index gathered')
@@ -216,9 +219,21 @@ actual = daemon.generate_feedback()
 test:is(actual.features.schema.hash_indices, 2,
         'internal cache invalidates when schema changes')
 
+--
+-- collect synchronous replication and election box.cfg options.
+--
+em = box.cfg.election_mode
+quorum = box.cfg.replication_synchro_quorum
+box.cfg{election_mode='candidate', replication_synchro_quorum=2}
+actual = daemon.generate_feedback()
+test:is(actual.options.election_mode, 'candidate', 'election_mode option reported')
+test:is(actual.options.synchro_quorum, 2, 'replication_synchro_quorum option reported')
+box.cfg{election_mode=em, replication_synchro_quorum=quorum}
+
 box.space.features_vinyl:drop()
 box.space.features_memtx_empty:drop()
 box.space.features_memtx:drop()
+box.space.features_sync:drop()
 
 test:check()
 os.exit(0)
-- 
2.24.3 (Apple Git-128)

             reply	other threads:[~2020-10-13 13:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-13 13:34 Serge Petrenko [this message]
2020-10-13 13:54 ` Serge Petrenko
2020-10-13 14:01 ` Cyrill Gorcunov
2020-10-13 14:05   ` Serge Petrenko
2020-10-13 15:56 ` Serge Petrenko
2020-10-14 23:50 ` Vladislav Shpilevoy
2020-10-15  8:30   ` Serge Petrenko
2020-10-15 19:45     ` Vladislav Shpilevoy
2020-10-20 17:09 ` Илья Конюхов
2020-10-20 19:16   ` Serge Petrenko
2020-10-21  8:42     ` Alexander V. Tikhonov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201013133418.34422-1-sergepetrenko@tarantool.org \
    --to=sergepetrenko@tarantool.org \
    --cc=kyukhin@tarantool.org \
    --cc=tarantool-patches@dev.tarantool.org \
    --cc=v.shpilevoy@tarantool.org \
    --subject='Re: [Tarantool-patches] [PATCH] feedback_daemon: add synchro replication usage reporting' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox