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 997356EC40; Mon, 7 Jun 2021 18:55:25 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 997356EC40 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=tarantool.org; s=dev; t=1623081325; bh=4pC+Ax9LQvCLWWrqvKHxVGwZXeaa2htm0S7GnrgpOWA=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=A22PVGVMaLRvunf3zTIQhe23b6Tr93W1h3h1wDFonGHC4bpkH8mu6WqQWxj/4Zn1A BsiKAGHQH87yJsYNJYad1r6k4zvx9d0QQwoYnYUy3GPwRVX+nPYM4UcDKSKU1b9cZd aOIhFagcFiDOt3wjinAzYY4nID8X3FCX1vped1ww= Received: from mail-lj1-f174.google.com (mail-lj1-f174.google.com [209.85.208.174]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 9BFF56EC40 for ; Mon, 7 Jun 2021 18:55:24 +0300 (MSK) DKIM-Filter: OpenDKIM Filter v2.11.0 dev.tarantool.org 9BFF56EC40 Received: by mail-lj1-f174.google.com with SMTP id r16so3764930ljk.9 for ; Mon, 07 Jun 2021 08:55:24 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=u3Iiac32ySU472RMUL0sjpkYn6jdw8ag209DSpwZY8I=; b=RwsfMXCHb2t3NIDGYhjz+sS+cZFJwJGfKx/eApIj+Lyl1DKitAWia2i8x8X1rh2CmF MCHN6bao/FEOrgp0vXwQo70lVwTotah3uVdEsacC0SSpazxu48qiNJfBMaUHik07qcEk oeEs6B9Cl1zzc44bILgWYNULs+MP4sJ5YW+s5Yz0HMN58QJipUj+nKOZSOD2yPDlqpkd Vpo++BEDnMyOfgJIksL3ys5ZoAPqIzvvJcn8o4+uvtSGLdK5CiPJ+F4dfHkgGaVcgTcD //gWJqgkZ458Y8RcD1UdtXmQBW7kCl1aEYDJlIGzEoY5nUXRqW0FK+jhiOv4Uydw8y8A iSSA== X-Gm-Message-State: AOAM533lDfz5IGzEqU+ujgrSCGneY8VKprAyHA92tHxN/PNGCklsi7Qi +bFRWEpEEEigKTpZCtcd3AJTb0hglig= X-Google-Smtp-Source: ABdhPJzdB30DPENd+5oXpX3yUJiGMGtPIwMZz/0cxzzAJAXwp6GnrpJapVhQdSg/YC+znpgTJP0uDw== X-Received: by 2002:a2e:b892:: with SMTP id r18mr15169975ljp.402.1623081323285; Mon, 07 Jun 2021 08:55:23 -0700 (PDT) Received: from grain.localdomain ([5.18.171.94]) by smtp.gmail.com with ESMTPSA id o20sm1539210lfo.302.2021.06.07.08.55.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Jun 2021 08:55:21 -0700 (PDT) Received: by grain.localdomain (Postfix, from userid 1000) id A1E0C5A0042; Mon, 7 Jun 2021 18:55:20 +0300 (MSK) To: tml Date: Mon, 7 Jun 2021 18:55:17 +0300 Message-Id: <20210607155519.109626-1-gorcunov@gmail.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [Tarantool-patches] [PATCH v8 0/2] relay: provide downstream lag information 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: Cyrill Gorcunov via Tarantool-patches Reply-To: Cyrill Gorcunov Cc: Vladislav Shpilevoy Errors-To: tarantool-patches-bounces@dev.tarantool.org Sender: "Tarantool-patches" Guys, take a look once time permit. Previous version is here https://lists.tarantool.org/tarantool-patches/20210506214132.533913-1-gorcunov@gmail.com/ I still think we might need some general statistics engine because this lag rather common data and we could move other "last" things like last_row_time there but since I didn't get approve on the idea I keep the timestamp in replica structure. v4 (by Vlad): - add a test case - add docbot request - dropped off xrow_encode_vclock_timed, we use opencoded assignment for tm value when send ack - struct awstat renamed to applier_wal_stat. Vlad I think this is better name than "applier_lag" because this is statistics on WAL, we simply track remote WAL propagation here, so more general name is better for grep sake and for future extensions - instead of passing applier structure we pass replica_id - the real keeper of this statistics comes into "replica" structure thus unbound of applier itself - for synchro entries we pass a pointer to the applier_wal_stat instead of using replica_id = 0 as a sign that we don't need to update statistics for initial and final join cases - to write and read statistics we provide wal_stat_update and wal_stat_ack helpers to cover the case where single ACK spans several transactions v8: - make one branch less in apply_synchro_row() - keep applier_txn_start_tm inside replica stucture - rename wal_stat to replica_cb_data since this is more logical for case where we have no general stat engine - make applier to send timestamp so that relay will compute delte upon the read, the lag is kept permanently until new write happens - extend doc and changelog a bit - keep reading of relay's lag from TX thread without any modifications because relay get deleted from TX thread and set to non-RELAY_FOLLOW state, thus any attempt to read it won't success. To be honest there is a small race window present: write doubles are not atomic operation thus we might read partially updated timestamp simiraly as we have with @idle field already. I think this should be addressed separately and better without heavy cmsg engine involved but with rw lock instead or plain atomics. branch gorcunov/gh-5447-relay-lag-8 issue https://github.com/tarantool/tarantool/issues/5447 Cyrill Gorcunov (2): applier: send transaction's first row WAL time in the applier_writer_f relay: provide information about downstream lag .../unreleased/gh-5447-downstream-lag.md | 6 ++ src/box/applier.cc | 90 +++++++++++++++--- src/box/lua/info.c | 3 + src/box/relay.cc | 50 ++++++++++ src/box/relay.h | 6 ++ src/box/replication.cc | 1 + src/box/replication.h | 5 + .../replication/gh-5447-downstream-lag.result | 93 +++++++++++++++++++ .../gh-5447-downstream-lag.test.lua | 41 ++++++++ 9 files changed, 280 insertions(+), 15 deletions(-) create mode 100644 changelogs/unreleased/gh-5447-downstream-lag.md create mode 100644 test/replication/gh-5447-downstream-lag.result create mode 100644 test/replication/gh-5447-downstream-lag.test.lua base-commit: 2b25ca6c70908b57c011ee24d2eeb9f6155d2750 -- 2.31.1