Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m5YMr-0000p0-HF for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Jul 2021 18:51:53 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1m5YMp-0006M6-BX for pgsql-hackers@arkaria.postgresql.org; Mon, 19 Jul 2021 18:51:51 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1m5YMo-0006Ly-NE for pgsql-hackers@lists.postgresql.org; Mon, 19 Jul 2021 18:51:51 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1m5YMl-0004YJ-9q for pgsql-hackers@postgresql.org; Mon, 19 Jul 2021 18:51:49 +0000 Received: by mail-pj1-x1031.google.com with SMTP id gx2so926414pjb.5 for ; Mon, 19 Jul 2021 11:51:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=enterprisedb.com; s=google; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=ymcpsigtv1CUtKowTwYHVgmuUTwKaKBD6oCDxfgJVvs=; b=BVtBMlLkubqqtpCDCMBmN/M0xxOXZ18DisBEwhCaHR8eZt0q5NTApBLxyw72B6lBUo wrYJpu00AUpwWiqYu4RqP0nryM3xgIa3/xXq2TBBdtix+wOfMAP1t9qn+JiNlu9e42Jq t7pkAE5VfXNpANw7fGHAoHXre1XXOeB/6zEiObSXLY1tK+2H2oJ8/mcwC+XapO7a/nUs tOe2ZeOl8rbJlo+Fr3rJzxzsG9YCRNZQVdwHHGs/AO5xNq3MOSHRp544RAZJHrZVYKKb JE0PsDkUkCvtFwPJ5/MK96bKe1WtpeoohPbfH0/2/9wQhj3uERX51cjlg7hDZj95p0lt NerA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=ymcpsigtv1CUtKowTwYHVgmuUTwKaKBD6oCDxfgJVvs=; b=PxMFsoP7mDh84ZOfcRM0xQm4LfMkxtQmHkzNPCREi6AZ+X3kiqM0lLVR3g7e8G0+CW rkcNS9lFmFfNhnMsXPvQVIgr8t42boAnYQ7EX8kMY+EsNE+wqAWcknjU9qkWy0rFK4qf ZnUDxgOdb/jnmszplQIsZpt7bI8p87sKg0GgR6KaFDMr0y5H3pfip6vRHY01mFMqfI6o Ea8IXQ0tkPbh4f6eJa6dq0xBkOaInjvjK3KiGMAYBZo4Xo+uYw21IyDevT5XmFxVVCte PF6TwFPLeV4FTa/iW7Pdh43KNNIyswqmzHDU33TSIFmw1iKTZ1pVPNFo3xq1hzppBu8q ukVA== X-Gm-Message-State: AOAM5334/91gtQyjXFco7Gai0mBmt7wc/xFHwGWhRx92iLL7lQu+wbbk 2384bVhRHLB7vOqA4aeblSCUBxILYGH3TN/UFfn9/FcxfCJIrtrFoHPtKHWCmwLL2zRhbp3lWXb RhOnxyu18cmDEfKI7DOBsjXeGzLgmJ7voM1zdleF2xcsJREQjoJ4WZ+CtUFiiueguX0EXdjDgcB IUuaQgZD5/b+Leuv/OuZ++nivkaunnzpt5QSOh X-Google-Smtp-Source: ABdhPJxK/a9WPSZG2GBUF0ycafb1gIu334GpohF9WfLAfCFe1P0jh96KKj5N4Wcf7uE9ripooY8LDw== X-Received: by 2002:a17:902:9688:b029:129:183a:2a61 with SMTP id n8-20020a1709029688b0290129183a2a61mr20199430plp.27.1626720705929; Mon, 19 Jul 2021 11:51:45 -0700 (PDT) Received: from laptop280-ma-us.hitronhub.home (24-113-193-150.wavecable.com. [24.113.193.150]) by smtp.gmail.com with ESMTPSA id a13sm21822684pfl.92.2021.07.19.11.51.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 19 Jul 2021 11:51:45 -0700 (PDT) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.120.23.2.7\)) Subject: Re: refactoring basebackup.c From: Mark Dilger In-Reply-To: Date: Mon, 19 Jul 2021 11:51:44 -0700 Cc: "pgsql-hackers@postgresql.org" , tushar Content-Transfer-Encoding: quoted-printable Message-Id: References: <58D2BD01-B541-4032-9C0B-B6143841E7ED@enterprisedb.com> To: Robert Haas X-Mailer: Apple Mail (2.3608.120.23.2.7) X-CLOUD-SEC-AV-Info: enterprisedb,google_mail,monitor X-CLOUD-SEC-AV-Sent: true X-Gm-Spam: 0 X-Gm-Phishy: 0 List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk > On Jul 8, 2021, at 8:56 AM, Robert Haas wrote: >=20 > The interesting > patches in terms of functionality are 0006 and 0007; The difficulty in v3-0007 with pg_basebackup only knowing how to parse = tar archives seems to be a natural consequence of not sufficiently = abstracting out the handling of the tar format. If the bbsink and = bbstreamer abstractions fully encapsulated a set of parsing callbacks, = then pg_basebackup wouldn't contain things like: streamer =3D bbstreamer_tar_parser_new(streamer); but instead would use the parser callbacks without knowledge of whether = they were parsing tar vs. cpio vs. whatever. It just seems really odd = that pg_basebackup is using the extensible abstraction layer and then = defeating the purpose by knowing too much about the format. It might = even be a useful exercise to write cpio support into this patch set = rather than waiting until v16, just to make sure the abstraction layer = doesn't have tar-specific assumptions left over. printf(_(" -F, --format=3Dp|t output format (plain (default), = tar)\n")); printf(_(" -z, --gzip compress tar output\n")); printf(_(" -Z, --compress=3D0-9 compress tar output with given = compression level\n")); This is the pre-existing --help output, not changed by your patch, but = if you anticipate that other output formats will be supported in future = releases, perhaps it's better not to write the --help output in such a = way as to imply that -z and -Z are somehow connected with the choice of = tar format? Would changing the --help now make for less confusion = later? I'm just asking... The new options to pg_basebackup should have test coverage in = src/bin/pg_basebackup/t/010_pg_basebackup.pl, though I expect you are = waiting to hammer out the interface before writing the tests. > the rest is > preparatory refactoring. patch v3-0001: The new function AppendPlainCommandOption writes too many spaces, which = does no harm, but seems silly, resulting in lines like: LOG: received replication command: BASE_BACKUP ( LABEL 'pg_basebackup = base backup', PROGRESS, WAIT 0, MANIFEST 'yes') patch v3-0003: The introduction of the sink abstraction seems incomplete, as = basebackup.c still has knowledge of things like tar headers. Calls like = _tarWriteHeader(sink, ...) feel like an abstraction violation. I = expected perhaps this would get addressed in later patches, but it = doesn't. + * 'bbs_buffer' is the buffer into which data destined for the bbsink + * should be stored. It must be a multiple of BLCKSZ. + * + * 'bbs_buffer_length' is the allocated length of the buffer. The length must be a multiple of BLCKSZ, not the pointer. patch-v3-0005: + * 'copystream' sends a starts a single COPY OUT operation and = transmits too many verbs. + * Regardless of which method is used, we sent a result set with "is used" vs. "sent" verb tense mismatch. + * So we only check it after the number of bytes sine the last check = reaches typo. s/sine/since/ - * (2) we need to inject backup_manifest or recovery configuration = into it. + * (2) we need to inject backup_manifest or recovery configuration = into + * it. src/bin/pg_basebackup/pg_basebackup.c contains word wrap changes like = the above which would better be left to a different commit, if done at = all. + if (state.manifest_file !=3DNULL) Need a space after !=3D =E2=80=94 Mark Dilger EnterpriseDB: http://www.enterprisedb.com The Enterprise PostgreSQL Company