From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from [87.239.111.99] (localhost [127.0.0.1]) by dev.tarantool.org (Postfix) with ESMTP id 44BF76EC5D; Thu, 8 Apr 2021 16:43:27 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 44BF76EC5D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1617889407; bh=sDlFVpCb5K/Kbm4nltlQ9hX5VDf354dEf4RkcM8Y96k=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=r54zQ+fJ+oDuDgpCCa2/gx0H1ZqCYN8BZ9lzIGZscNQ4hEtC/3iu92Pyfwi01pa10 OmZbZM6i0et8IHOlr0p+lBVr+MpT8f5bl0LBY8bcpYztCiXOEwo/fWXDvvMt0ia2OM HDt8/5QrNa0Xk3lAQuvN3iymz6pCWdzlUAmp0Zzg= Received: from smtp35.i.mail.ru (smtp35.i.mail.ru [94.100.177.95]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id A33266EC61 for ; Thu, 8 Apr 2021 16:41:40 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org A33266EC61 Received: by smtp35.i.mail.ru with esmtpa (envelope-from ) id 1lUUuh-0000gw-Lq; Thu, 08 Apr 2021 16:41:40 +0300 To: v.shpilevoy@tarantool.org, alexander.turenko@tarantool.org Date: Thu, 8 Apr 2021 16:38:41 +0300 Message-Id: <94310caa91eac51c74dcde413407de12bd935a85.1617888916.git.sergepetrenko@tarantool.org> X-Mailer: git-send-email 2.24.3 (Apple Git-128) In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-7564579A: B8F34718100C35BD X-77F55803: 4F1203BC0FB41BD912A3E3D5D4B49FC1FB6C11AAC314D64EDF2811C24C4EA09700894C459B0CD1B96E8B26D15CA4B6850C4B5AD94EB5FF4738DE5FFF3BE3010046FB58697BC30720 X-7FA49CB5: FF5795518A3D127A4AD6D5ED66289B5278DA827A17800CE7A33E1178EA603666EA1F7E6F0F101C67BD4B6F7A4D31EC0BCC500DACC3FED6E28638F802B75D45FF8AA50765F79006375C4806A08D329A618638F802B75D45FF914D58D5BE9E6BC1A93B80C6DEB9DEE97C6FB206A91F05B20FD680AE432F601BC9355CF8ED35FCDBFEEB761FB9071033D2E47CDBA5A96583C09775C1D3CA48CFE3800B164E348C91117882F4460429724CE54428C33FAD30A8DF7F3B2552694AC26CFBAC0749D213D2E47CDBA5A9658378DA827A17800CE7ABB305BD10C6E5099FA2833FD35BB23DF004C906525384302BEBFE083D3B9BA71A620F70A64A45A98AA50765F79006372E808ACE2090B5E1725E5C173C3A84C3C5EA940A35A165FF2DBA43225CD8A89FB26E97DCB74E6252156CCFE7AF13BCA4B5C8C57E37DE458BEDA766A37F9254B7 X-C1DE0DAB: C20DE7B7AB408E4181F030C43753B8186998911F362727C4C7A0BC55FA0FE5FC09B348080E4584309E63253FB0349721762196DE88922BC3B1881A6453793CE9C32612AADDFBE061C61BE10805914D3804EBA3D8E7E5B87ABF8C51168CD8EBDB63AF70AF8205D7DCDC48ACC2A39D04F89CDFB48F4795C241BDAD6C7F3747799A X-C8649E89: 4E36BF7865823D7055A7F0CF078B5EC49A30900B95165D3458239C6F30CE7ACF480BA2F4F6278BB40F4E8D6280E0559D65C02B123EAA8A15BCB3E0AD3B2325741D7E09C32AA3244CF223AD0DF471CC5ABD96FE93D6F3F5FE435BF7150578642F927AC6DF5659F194 X-D57D3AED: 3ZO7eAau8CL7WIMRKs4sN3D3tLDjz0dLbV79QFUyzQ2Ujvy7cMT6pYYqY16iZVKkSc3dCLJ7zSJH7+u4VD18S7Vl4ZUrpaVfd2+vE6kuoey4m4VkSEu530nj6fImhcD4MUrOEAnl0W826KZ9Q+tr5ycPtXkTV4k65bRjmOUUP8cvGozZ33TWg5HZplvhhXbhDGzqmQDTd6OAevLeAnq3Ra9uf7zvY2zzsIhlcp/Y7m53TZgf2aB4JOg4gkr2bioju+jaMfvANXpxn287BXLzRA== X-Mailru-Sender: 3B9A0136629DC9125D61937A2360A4465E4806B976005D2AE8430D9C02E3CF2E38388D7629360032424AE0EB1F3D1D21E2978F233C3FAE6EE63DB1732555E4A8EE80603BA4A5B0BC112434F685709FCF0DA7A0AF5A3A8387 X-Mras: Ok Subject: [Tarantool-patches] [PATCH v2 5/5] feedback_daemon: count and report some events X-BeenThere: tarantool-patches@dev.tarantool.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , From: Serge Petrenko via Tarantool-patches Reply-To: Serge Petrenko Cc: tarantool-patches@dev.tarantool.org Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Bump `feedback_version` to 7 and introduce a new field: `feedback.events`. It holds a counter for every event we may choose to register later on. Currently the possible events are "create_space", "drop_space", "create_index", "drop_index". All the registered events and corresponding counters are sent in a report in `feedback.events` field. Also, the first registered event triggers the report sending right away. So, we may follow such events like "first space/index created/dropped" Closes #5750 --- src/box/lua/feedback_daemon.lua | 31 ++++++++++++++++++++++++--- src/box/lua/schema.lua | 14 ++++++++++++ test/box-tap/feedback_daemon.test.lua | 23 +++++++++++++++++++- 3 files changed, 64 insertions(+), 4 deletions(-) diff --git a/src/box/lua/feedback_daemon.lua b/src/box/lua/feedback_daemon.lua index 93bbb2a11..660ef8403 100644 --- a/src/box/lua/feedback_daemon.lua +++ b/src/box/lua/feedback_daemon.lua @@ -312,13 +312,18 @@ local function fill_in_stats(feedback) feedback.stats = stats end -local function fill_in_feedback(feedback) +local function fill_in_events(self, feedback) + feedback.events = self.cached_events +end + +local function fill_in_feedback(self, feedback) fill_in_base_info(feedback) fill_in_platform_info(feedback) fill_in_repo_url(feedback) fill_in_features(feedback) fill_in_options(feedback) fill_in_stats(feedback) + fill_in_events(self, feedback) return feedback end @@ -368,12 +373,29 @@ local function guard_loop(self) self.shutdown:put("stopped") end +local function save_event(self, event) + if type(event) ~= 'string' then + error("Usage: box.internal.feedback_daemon.save_event(string)") + end + self.cached_events[event] = (self.cached_events[event] or 0) + 1 + if self.cached_events[event] == 1 then + -- The first occurred event of this type triggers report dispatch + -- immediately. + self.send() + end +end + -- these functions are used for test purposes only local function start(self) self:stop() if self.enabled then - self.control = fiber.channel() + -- There may be up to 5 fibers triggering a send during bootstrap or + -- shortly after it. And maybe more to come. Do not make anyone wait for + -- feedback daemon to process the incoming events, and set channel size + -- to 10 just in case. + self.control = fiber.channel(10) self.shutdown = fiber.channel() + self.cached_events = {} self.guard = fiber.create(guard_loop, self) end log.verbose("%s started", PREFIX) @@ -412,7 +434,7 @@ setmetatable(daemon, { end, -- this function is used in saving feedback in file generate_feedback = function() - return fill_in_feedback({ feedback_version = 6 }) + return fill_in_feedback(daemon, { feedback_version = 7 }) end, start = function() start(daemon) @@ -423,6 +445,9 @@ setmetatable(daemon, { reload = function() reload(daemon) end, + save_event = function(event) + save_event(daemon, event) + end, send = function() if daemon.control ~= nil then daemon.control:put("send") diff --git a/src/box/lua/schema.lua b/src/box/lua/schema.lua index 96503a50e..93ecf7440 100644 --- a/src/box/lua/schema.lua +++ b/src/box/lua/schema.lua @@ -321,6 +321,12 @@ local function update_param_table(table, defaults) return new_table end +local function feedback_save_event(event) + if internal.feedback_daemon ~= nil then + internal.feedback_daemon.save_event(event) + end +end + box.begin = function() if builtin.box_txn_begin() == -1 then box.error() @@ -462,6 +468,8 @@ box.schema.space.create = function(name, options) }) _space:insert{id, uid, name, options.engine, options.field_count, space_options, format} + + feedback_save_event('create_space') return box.space[id], "created" end @@ -531,6 +539,8 @@ box.schema.space.drop = function(space_id, space_name, opts) box.error(box.error.NO_SUCH_SPACE, space_name) end end + + feedback_save_event('drop_space') end box.schema.space.rename = function(space_id, space_name) @@ -1237,6 +1247,8 @@ box.schema.index.create = function(space_id, name, options) local _func_index = box.space[box.schema.FUNC_INDEX_ID] _func_index:insert{space_id, iid, index_opts.func} end + + feedback_save_event('create_index') return space.index[name] end @@ -1257,6 +1269,8 @@ box.schema.index.drop = function(space_id, index_id) _func_index:delete({v.space_id, v.index_id}) end _index:delete{space_id, index_id} + + feedback_save_event('drop_index') end box.schema.index.rename = function(space_id, index_id, name) diff --git a/test/box-tap/feedback_daemon.test.lua b/test/box-tap/feedback_daemon.test.lua index 3d6bf1d9b..a2e041649 100755 --- a/test/box-tap/feedback_daemon.test.lua +++ b/test/box-tap/feedback_daemon.test.lua @@ -70,7 +70,7 @@ if not ok then os.exit(0) end -test:plan(28) +test:plan(30) local function check(message) while feedback_count < 1 do @@ -293,5 +293,26 @@ check_stats(actual.stats) actual = daemon.generate_feedback() test:is(box.info.uptime, actual.uptime, "Server uptime is reported and is correct.") +daemon.reload() +actual = daemon.generate_feedback() + +local events_expected = {} +test:is_deeply(actual.events, events_expected, "Events are empty initially.") + +box.schema.space.create('test') +box.space.test:create_index('pk') +box.space.test.index.pk:drop() +box.space.test:drop() + +actual = daemon.generate_feedback() +events_expected = { + create_space = 1, + create_index = 1, + drop_space = 1, + drop_index = 1, +} + +test:is_deeply(actual.events, events_expected, "Events are counted correctly") + test:check() os.exit(0) -- 2.24.3 (Apple Git-128)