Re: Idempotency-Key for resuming requests (TUS Resumable Uploads Protocol)

Austin William Wright <aaa@bzfx.net> Fri, 07 October 2022 19:35 UTC

Return-Path: <ietf-http-wg-request+bounce-httpbisa-archive-bis2juki=lists.ie@listhub.w3.org>
X-Original-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Delivered-To: ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com
Received: from localhost (localhost [127.0.0.1]) by ietfa.amsl.com (Postfix) with ESMTP id D2530C14CE2F for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Fri, 7 Oct 2022 12:35:26 -0700 (PDT)
X-Virus-Scanned: amavisd-new at amsl.com
X-Spam-Flag: NO
X-Spam-Score: -7.758
X-Spam-Level:
X-Spam-Status: No, score=-7.758 tagged_above=-999 required=5 tests=[BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.249, HTML_MESSAGE=0.001, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_HI=-5, RCVD_IN_MSPIKE_H2=-0.001, RCVD_IN_ZEN_BLOCKED_OPENDNS=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, URIBL_BLOCKED=0.001, URIBL_DBL_BLOCKED_OPENDNS=0.001, URIBL_ZEN_BLOCKED_OPENDNS=0.001] autolearn=ham autolearn_force=no
Authentication-Results: ietfa.amsl.com (amavisd-new); dkim=pass (1024-bit key) header.d=bzfx.net
Received: from mail.ietf.org ([50.223.129.194]) by localhost (ietfa.amsl.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id AfDaCXWDs9TU for <ietfarch-httpbisa-archive-bis2Juki@ietfa.amsl.com>; Fri, 7 Oct 2022 12:35:22 -0700 (PDT)
Received: from lyra.w3.org (lyra.w3.org [128.30.52.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by ietfa.amsl.com (Postfix) with ESMTPS id A6829C14CE23 for <httpbisa-archive-bis2Juki@lists.ietf.org>; Fri, 7 Oct 2022 12:35:22 -0700 (PDT)
Received: from lists by lyra.w3.org with local (Exim 4.94.2) (envelope-from <ietf-http-wg-request@listhub.w3.org>) id 1ogt4w-0058Ym-HA for ietf-http-wg-dist@listhub.w3.org; Fri, 07 Oct 2022 19:32:14 +0000
Resent-Date: Fri, 07 Oct 2022 19:32:14 +0000
Resent-Message-Id: <E1ogt4w-0058Ym-HA@lyra.w3.org>
Received: from mimas.w3.org ([128.30.52.79]) by lyra.w3.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from <aaa@bzfx.net>) id 1ogt4u-0058XT-LJ for ietf-http-wg@listhub.w3.org; Fri, 07 Oct 2022 19:32:12 +0000
Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by mimas.w3.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.94.2) (envelope-from <aaa@bzfx.net>) id 1ogt4s-009O7c-Ia for ietf-http-wg@w3.org; Fri, 07 Oct 2022 19:32:12 +0000
Received: by mail-pl1-x632.google.com with SMTP id n7so5441047plp.1 for <ietf-http-wg@w3.org>; Fri, 07 Oct 2022 12:32:10 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bzfx.net; s=google; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:from:to:cc:subject:date:message-id:reply-to; bh=1Ind6/ZR/G4byPnPCyNajJ1iBMX1P3bpZe4jbpWfaXc=; b=IP78qjvobs9YdpUP4IOu/IjJvJ3Tlkgq8pYudpuEN2KmdXxyEHTBYUj2DTAH+5JfZU PpjsS96cGrOxWH9M88zibe+myv60BBvDhKlS2uA2fg1yQo9RuE5C2NmbqJxQSBJb3H5k sZv1DjxDHe0BEo9bfgaJ8YY4U5chZGxitts6A=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=references:to:cc:in-reply-to:date:subject:mime-version:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=1Ind6/ZR/G4byPnPCyNajJ1iBMX1P3bpZe4jbpWfaXc=; b=KWbYqKwtE+Gt4PUMePKFNyDloegCxY9iSYJq3AuWEAND2dLdPxlY81BVBg9HycUDi3 VkOc5ydZxe50ZqA0HKiUeB+lcvY2QFeZDftCXFumqc9ZGo+Z2iczjHiEwNL/GjD072Z9 SlP9GoWtHpncBT2ObFZXfbecdT7VnHst7NvjCj91/BPKgufXDPONFdH4psOygHcODZMQ XwNOQcJBiRsBf6Q3fcnuBnpRX/vCrnmKOHvg22n+nOXFQuox9YWpaBZGMcX17cWyxLkD NzBcf8+Tzbi6aq8VHqy/zE27InlyGecvFeosHgXgy+k0v2YpVWD4MbY067Gu76J2jmh6 iXGQ==
X-Gm-Message-State: ACrzQf27niqUDtUVj5pNuUhbAiJ3ZOCM94aLM7rQnxBuzV5XFA6L5H4i AzKKXIHRvxVsRxrY1KeJCYoZ4g==
X-Google-Smtp-Source: AMsMyM5zRwx6JnbfYCEW49rbcqmac9fc7uEmIH4zwbEDqwt0U8MfbfJju2lr2pLKt49X5IFWNvH+IQ==
X-Received: by 2002:a17:90b:4c43:b0:203:1ba4:f29a with SMTP id np3-20020a17090b4c4300b002031ba4f29amr7185637pjb.76.1665171118985; Fri, 07 Oct 2022 12:31:58 -0700 (PDT)
Received: from smtpclient.apple (71-223-234-98.phnx.qwest.net. [71.223.234.98]) by smtp.gmail.com with ESMTPSA id n7-20020a170903110700b0017d061a6119sm1881653plh.116.2022.10.07.12.31.57 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 07 Oct 2022 12:31:58 -0700 (PDT)
From: Austin William Wright <aaa@bzfx.net>
Message-Id: <09E9720A-9E44-4EF4-A795-7973659A8D70@bzfx.net>
Content-Type: multipart/alternative; boundary="Apple-Mail=_81D08CC1-A319-4A22-A373-038BA053421F"
Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3696.120.41.1.1\))
Date: Fri, 07 Oct 2022 12:31:55 -0700
In-Reply-To: <CANY19NsytBEjDWDv6bqSVB3cTMYEka9d5fp3DQ=6YuFqRGvhFw@mail.gmail.com>
Cc: ietf-http-wg <ietf-http-wg@w3.org>
To: Marius Kleidl <marius@transloadit.com>
References: <9CB21DA8-9DBD-429B-930A-E67774652B06@bzfx.net> <CANY19NsytBEjDWDv6bqSVB3cTMYEka9d5fp3DQ=6YuFqRGvhFw@mail.gmail.com>
X-Mailer: Apple Mail (2.3696.120.41.1.1)
Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=aaa@bzfx.net; helo=mail-pl1-x632.google.com
X-W3C-Hub-DKIM-Status: validation passed: (address=aaa@bzfx.net domain=bzfx.net), signature is good
X-W3C-Hub-Spam-Status: No, score=-6.1
X-W3C-Hub-Spam-Report: BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, W3C_AA=-1, W3C_DB=-1, W3C_IRA=-1, W3C_WL=-1
X-W3C-Scan-Sig: mimas.w3.org 1ogt4s-009O7c-Ia ce21200709a420966a4e72b6efc99ed4
X-Original-To: ietf-http-wg@w3.org
Subject: Re: Idempotency-Key for resuming requests (TUS Resumable Uploads Protocol)
Archived-At: <https://www.w3.org/mid/09E9720A-9E44-4EF4-A795-7973659A8D70@bzfx.net>
Resent-From: ietf-http-wg@w3.org
X-Mailing-List: <ietf-http-wg@w3.org> archive/latest/40426
X-Loop: ietf-http-wg@w3.org
Resent-Sender: ietf-http-wg-request@w3.org
Precedence: list
List-Id: <ietf-http-wg.w3.org>
List-Help: <https://www.w3.org/Mail/>
List-Post: <mailto:ietf-http-wg@w3.org>
List-Unsubscribe: <mailto:ietf-http-wg-request@w3.org?subject=unsubscribe>

On Oct 7, 2022, at 08:02, Marius Kleidl <marius@transloadit.com> wrote:
> 
> Dear Austin,
> 
> you brought up a good point by throwing Idempotency-Key into the recent Interim meeting. Idempotency and resumability are related but not the same, because when resuming an upload you want to start the data transfer at a different offset to avoid transmitting the same data again. I am missing this part from your proposal. How does the client obtain the information which data the server has already received and which part it must still transmit? Or did I just miss that piece?

Indeed, I hand-waved away the details about how exactly the unsent data is resumed, and how you resynchronize the client state with the server (determining how many bytes the server received or lost). I assumed the current technique, using an Upload-Offset header and making a HEAD request, will suffice.

But since GET/HEAD is supposed to be cachable (and so returning a client-specific Upload-Offset would be dubious), let me propose an alternative way of resynchronizing the client state, there's three parts to this:

(1) While you are making the first upload, the server can (optionally) periodically send “1xx Received" responses indicating how many bytes have been saved to durable storage. This allows the client to forget about these bytes, saving memory. When resuming an upload, the client can start from the last sent “1xx Received” offset.

(2) If you make a RESUME request with no upload, then the server simply returns how many bytes it has saved. This just changes the HEAD method <https://www.ietf.org/archive/id/draft-ietf-httpbis-resumable-upload-00.html#name-offset-retrieving-procedure-2> out with the new method.

(3) You make a RESUME request with an upload body, however you don’t know the offset. So you wait for the server to send the “1xx Received” offset indicating the bytes received from the previous request; the client then resumes the upload at this point (and making additional “1xx Received” responses as it processes the incoming data). (Note how this is quite similar to the 100 Continue workflow, where the client waits for acknowledgement from the server before proceeding with the upload.)

Finally, yes, it also seems to me that idempotency and resumability aren't exactly the same in general. It occurred to me, a request can be idempotent because it overwrites the server state entirely (PUT), or because the request is conditional (If-Match).

What’s important here is both Idempotency-Key and resumable uploads are the same type of conditional request: the request should only be executed if it hasn’t previously been completed.

Thanks,

Austin.


> 
> That being said, I think that an idempotency key could play an important role in resumable uploads, especially considering the creation of uploads resources.
> 
> Best regards,
> Marius
> 
> 
> El jue., 6 oct. 2022 1:11, Austin William Wright <aaa@bzfx.net <mailto:aaa@bzfx.net>> escribió:
> Hello HTTP WG,
> 
> It occurred to me that, in general, where a client wants resumable requests, it also wants those requests be idempotent. I noted the HTTP APIs WG is considering an Idempotency-Key header, and it seems to me these should be part of the same mechanism. Let me explain how that might work:
> 
> If the client sends an Idempotency-Key, then the server can respond with a 1xx (Resumption Supported) confirming that the key will be honored for resuming the request.
> 
> Clients that want resumption SHOULD send Idempotency-Key, but they don’t have to (for example, to minimize UA fingerprinting). If the client does not send Idempotency-Key, the server should still send 1xx (Resumption Supported) to assign the request an Idempotency-Key. But it doesn’t have to (for example, 1xx is filtered by gateways).
> 
> Then when the request is interrupted, the client may resume the request with the same URI and Idempotency-Key of the request being resumed. By defining a RESUME method, a client could attempt to send a RESUME request in the hopes the server supports resumption, even if it didn’t receive a 1xx response. (Using the same URI allows the server to partition incomplete requests/uploads by the resource URI. There should be little need to re-send the method, since the server must store the details of the original request anyways, but a header could be defined if such a need is found.)
> 
> I see few downsides with this technique. There’s some builtin redundancy so resumption will work even if one party is buggy, and if a new method is used, there’s no possibility that a server could misinterpret the request. Idempotency-Key would replace "Upload-Token” entirely.
> 
> Thoughts?
> 
> Thanks,
> 
> Austin.