Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r1plG-00DvUr-6x for pgsql-hackers@arkaria.postgresql.org; Sat, 11 Nov 2023 15:19:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1r1plD-007dgQ-3e for pgsql-hackers@arkaria.postgresql.org; Sat, 11 Nov 2023 15:18:59 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r1plC-007dgH-Gk for pgsql-hackers@lists.postgresql.org; Sat, 11 Nov 2023 15:18:58 +0000 Received: from mail-ot1-x333.google.com ([2607:f8b0:4864:20::333]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from ) id 1r1pl8-0054de-Jn for pgsql-hackers@postgresql.org; Sat, 11 Nov 2023 15:18:57 +0000 Received: by mail-ot1-x333.google.com with SMTP id 46e09a7af769-6d645cfd238so938747a34.2 for ; Sat, 11 Nov 2023 07:18:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dunslane-net.20230601.gappssmtp.com; s=20230601; t=1699715933; x=1700320733; darn=postgresql.org; h=in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:from:to:cc:subject:date :message-id:reply-to; bh=ICXeAD6+YHrbx+DuJVPvfHIU7HtW2Mm/dcbrsn1Kf3o=; b=0Zldox+5/RJu5NXDWAmOzG3Qf0U2JV17fU9v+Vjejb3BRnCBxD4tHKgHkAlBMuU8Ot 9CeKYWwJNgK8c/QLYh6ws0mtcKbVw8t8T5/UD0TPK+OnDzdUo/g9enUcRANAuyYln6Ni uKFCrd2VP5FPVGeiyEqrGedpbkx79Nolrpx9CHEZ8k6lUCpQvnFvdQ7gr8+PTVRmFMOX 67+gVYuecSjVTSpU1sAd5u9OENSAtJ02eYjHf7Kd+PPO50ZQOLcU32uqXjTGrt6LDwaN 3uUZFoDA903PN4gg3zKg4OTDevldBCMBaqtEYunVSWH3wnmhpTKXqBAoHkh6QvWFLA3L X4EQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699715933; x=1700320733; h=in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=ICXeAD6+YHrbx+DuJVPvfHIU7HtW2Mm/dcbrsn1Kf3o=; b=pvQL6LeXyJ67AW880/ch1KdUcRsFP+uXO3FNcmFAWiKgM9UHKlcUbWhDLrqeRp0Qm8 RrM3PvOZa7iVZK87w2UTzMPU3j6vY7Np7QnXupCzwNQDOuixqze5ihxzH0JxNTS332Tq N/HHctyOUwFUXxIxcItm4jkY8exSFym3gWJ5HVsjniOUxn2vlXUj/F9wufkKOphgKGOY eDiJByuVf10FByuEnm6WHZjGoAG1plQAl6jziut7DKtUg/Ns3oxVSPPYl6+b5sfk/bEC jhY6qDdz4zxXfLTFFZEB2w75mff0WkjVZ7nfTIGnVqKXh7xUpjHWUR80oEEHVIksh80+ Oj1g== X-Gm-Message-State: AOJu0YyrM9verhORdsDhTTBkYXkvckF3T0+67RxmiLFIgBjxD/K5yX1s w+qOcx6u/zHHAr1Jjz2IslCSIA== X-Google-Smtp-Source: AGHT+IFkZnkzi91dfkXptcLoiIgdso6en1fWgZohTccfQb33304Th2I7fck6JvtWr+wLbJ6rDDdTWQ== X-Received: by 2002:a05:6358:88f:b0:168:d22e:8ff7 with SMTP id m15-20020a056358088f00b00168d22e8ff7mr2591624rwj.4.1699715933146; Sat, 11 Nov 2023 07:18:53 -0800 (PST) Received: from ?IPV6:2605:a601:9122:d800::2bb? ([2605:a601:9122:d800::2bb]) by smtp.googlemail.com with ESMTPSA id y15-20020a0ceacf000000b006779f7e68cdsm634336qvp.79.2023.11.11.07.18.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 11 Nov 2023 07:18:52 -0800 (PST) Content-Type: multipart/alternative; boundary="------------vud4dulIcqiNnY5vWk75CpyX" Message-ID: <9293e623-1d5e-0bd3-9b61-6129821b6f42@dunslane.net> Date: Sat, 11 Nov 2023 10:18:51 -0500 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.15.1 Subject: Re: pg_basebackup check vs Windows file path limits Content-Language: en-US To: Alexander Lakhin , Daniel Gustafsson Cc: PostgreSQL Hackers References: <666ac55b-3400-fb2c-2cea-0281bf36a53c@dunslane.net> <76f33a1f-ddce-80a6-6f39-fefa0668f4a6@dunslane.net> <3AC47E65-02A0-42BF-8A3E-B38FD09FE702@yesql.se> <94341cbe-9491-60e9-f01a-7ed770295cfa@dunslane.net> <81023744-772d-889b-99b8-bd1d58bd761b@dunslane.net> <67093EFC-3800-48B0-9E20-82A37A5F2A7B@yesql.se> <0c1c289c-f55a-1cc3-4ce1-44d7e8353e70@dunslane.net> <3B1D0F8A-DB97-462A-937F-73B3FCFE2713@yesql.se> <8e3130c2-5c51-5cd5-9f0d-b0cd938bcd6b@dunslane.net> <13663265-cac2-ec5d-d378-0dd44a895f8e@gmail.com> From: Andrew Dunstan In-Reply-To: <13663265-cac2-ec5d-d378-0dd44a895f8e@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk This is a multi-part message in MIME format. --------------vud4dulIcqiNnY5vWk75CpyX Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Hi, Alexander On 2023-11-11 Sa 08:00, Alexander Lakhin wrote: > Hello Andrew, > > 08.07.2023 18:52, Andrew Dunstan wrote: >>> Since this test is passing on HEAD which has slightly shorter paths, I'm wondering if we should change this: >>> >>> rename("$pgdata/pg_replslot", "$tempdir/pg_replslot") >>>   or BAIL_OUT "could not move $pgdata/pg_replslot"; >>> dir_symlink("$tempdir/pg_replslot", "$pgdata/pg_replslot") >>>   or BAIL_OUT "could not symlink to $pgdata/pg_replslot"; >>> >>> to use the much shorter $sys_tempdir created a few lines below. >>> >> Pushed a tested fix along those lines. >> > > Today I've started up my Windows VM to run some tests and discovered a > test > failure caused by that fix (e213de8e7): > >meson test > Ok:                 246 > Expected Fail:      0 > Fail:               1 > Unexpected Pass:    0 > Skipped:            14 > Timeout:            0 > > ...\010_pg_basebackup\log\regress_log_010_pg_basebackup.txt contains: > [04:42:45.321](0.291s) Bail out!  could not move > T:\postgresql\build/testrun/pg_basebackup/010_pg_basebackup\data/t_010_pg_basebackup_main_data/pgdata/pg_replslot > > With a diagnostic print added before rename() in 010_pg_basebackup.pl, > I see: > rename("T:\postgresql\build/testrun/pg_basebackup/010_pg_basebackup\data/t_010_pg_basebackup_main_data/pgdata/pg_replslot", > "C:\Users\User\AppData\Local\Temp\fGT76tZUWr/pg_replslot") > That is, I have the postgres source tree and the user tempdir placed on > different disks. > > perldoc on rename() says that it usually doesn't work across filesystem > boundaries, so I think it's not a Windows-specific issue. > > Hmm, maybe we should be using File::Copy::move() instead of rename(). The docco for that says:         If possible, move() will simply rename the file. Otherwise, it         copies the file to the new location and deletes the original. If an         error occurs during this copy-and-delete process, you may be left         with a (possibly partial) copy of the file under the destination         name. Can you try it out? cheers andrew -- Andrew Dunstan EDB:https://www.enterprisedb.com --------------vud4dulIcqiNnY5vWk75CpyX Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: 8bit



Hi, Alexander


On 2023-11-11 Sa 08:00, Alexander Lakhin wrote:
Hello Andrew,

08.07.2023 18:52, Andrew Dunstan wrote:
Since this test is passing on HEAD which has slightly shorter paths, I'm wondering if we should change this:
rename("$pgdata/pg_replslot", "$tempdir/pg_replslot")
  or BAIL_OUT "could not move $pgdata/pg_replslot";
dir_symlink("$tempdir/pg_replslot", "$pgdata/pg_replslot")
  or BAIL_OUT "could not symlink to $pgdata/pg_replslot";

to use the much shorter $sys_tempdir created a few lines below.

Pushed a tested fix along those lines.


Today I've started up my Windows VM to run some tests and discovered a test
failure caused by that fix (e213de8e7):
>meson test
Ok:                 246
Expected Fail:      0
Fail:               1
Unexpected Pass:    0
Skipped:            14
Timeout:            0

...\010_pg_basebackup\log\regress_log_010_pg_basebackup.txt contains:
[04:42:45.321](0.291s) Bail out!  could not move T:\postgresql\build/testrun/pg_basebackup/010_pg_basebackup\data/t_010_pg_basebackup_main_data/pgdata/pg_replslot

With a diagnostic print added before rename() in 010_pg_basebackup.pl, I see:
rename("T:\postgresql\build/testrun/pg_basebackup/010_pg_basebackup\data/t_010_pg_basebackup_main_data/pgdata/pg_replslot", "C:\Users\User\AppData\Local\Temp\fGT76tZUWr/pg_replslot")
That is, I have the postgres source tree and the user tempdir placed on
different disks.

perldoc on rename() says that it usually doesn't work across filesystem
boundaries, so I think it's not a Windows-specific issue.



Hmm, maybe we should be using File::Copy::move() instead of rename(). The docco for that says:

        If possible, move() will simply rename the file. Otherwise, it
        copies the file to the new location and deletes the original. If an
        error occurs during this copy-and-delete process, you may be left
        with a (possibly partial) copy of the file under the destination
        name.


Can you try it out?


cheers


andrew

--
Andrew Dunstan
EDB: https://www.enterprisedb.com
--------------vud4dulIcqiNnY5vWk75CpyX--