# Can \`rclone serve s3\` handle more than one client?

**URL:** <https://forum.rclone.org/t/can-rclone-serve-s3-handle-more-than-one-client/48329>\
**Category:** Help and Support\
**Created:** [October 21, 2024, 1:01pm UTC](https://forum.rclone.org/t/can-rclone-serve-s3-handle-more-than-one-client/48329 "2024-10-21T13:01:09Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![jaimedelano](https://forum.rclone.org/user_avatar/forum.rclone.org/jaimedelano/32/17712_2.png) [@jaimedelano](https://forum.rclone.org/u/jaimedelano)\
**Post date:** [October 21, 2024, 1:01pm UTC](https://forum.rclone.org/t/can-rclone-serve-s3-handle-more-than-one-client/48329/1 "2024-10-21T13:01:09Z")

</div>

#### What is the problem you are having with rclone?

The server generated by the `rclone serve s3` command appears to be capable of serving only a single client at a time.  
To illustrate, when listing a folder with a considerable number of files with `rclone ls rclone_s3_server:/my-files`, it is not possible to reconnect to the server and run, for example, `rclone copy -P doc.pdf rclone_s3_server:/my-files` until the previous command is completed.

#### Run the command 'rclone version' and share the full output of the command.

rclone 1.68.1

- os/version: gentoo 2.15 (64 bit)
- os/kernel: 6.1.67-gentoo-whatbox (x86\_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.23.1
- go/linking: dynamic
- go/tags: none

#### Which cloud storage system are you using? (eg Google Drive)

S3 + local filesystem

#### The command you were trying to run (eg `rclone copy /tmp remote:tmp`)

```auto
rclone serve s3 --auth-key XXX --auth-proxy XXX --vfs-cache-mode writes --cache-dir cache --vfs-write-back 10s --vfs-cache-max-age 10m --vfs-cache-max-size 1000G --dir-cache-time 100s --server-read-timeout 4h --server-write-timeout 8h --transfers 36 --addr 127.0.0.1:8080 -v

```

#### Please run 'rclone config redacted' and share the full output. If you get command not found, please make sure to update rclone.

```auto
[rclone_s3_server]
type = s3
provider = Rclone
access_key_id = XXX
secret_access_key = XXX
endpoint = XXX
acl = private

```

#### A log from the command that you were trying to run with the `-vv` flag

```auto
It just gets stuck indefinitely.

```

---

<div class="post-metadata">

**Author:** ![asdffdsa](https://forum.rclone.org/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@asdffdsa](https://forum.rclone.org/u/asdffdsa)\
**Post date:** [October 21, 2024, 2:47pm UTC](https://forum.rclone.org/t/can-rclone-serve-s3-handle-more-than-one-client/48329/2 "2024-10-21T14:47:30Z")

</div>

hi,

1. "not possible to reconnect to the server ... until the previous command is completed."
2. "It just gets stuck indefinitely."

those seem to be two different outcomes??

---

<div class="post-metadata">

**Author:** ![jaimedelano](https://forum.rclone.org/user_avatar/forum.rclone.org/jaimedelano/32/17712_2.png) [@jaimedelano](https://forum.rclone.org/u/jaimedelano)\
**Post date:** [October 21, 2024, 3:17pm UTC](https://forum.rclone.org/t/can-rclone-serve-s3-handle-more-than-one-client/48329/3 "2024-10-21T15:17:39Z")

</div>

My previous statement was not sufficiently clear.  
What I intended to convey was that any subsequent action must await the completion of the previous one.  
It looks like the operation is single-threaded.

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [October 21, 2024, 7:29pm UTC](https://forum.rclone.org/t/can-rclone-serve-s3-handle-more-than-one-client/48329/4 "2024-10-21T19:29:24Z")

</div>

It isn't supposed to be single threaded.

Probably there is a lock taken on the root directory while it is listing which is causing the problem.

Does that fit the symptoms?

---

<div class="post-metadata">

**Author:** ![jaimedelano](https://forum.rclone.org/user_avatar/forum.rclone.org/jaimedelano/32/17712_2.png) [@jaimedelano](https://forum.rclone.org/u/jaimedelano)\
**Post date:** [October 21, 2024, 8:08pm UTC](https://forum.rclone.org/t/can-rclone-serve-s3-handle-more-than-one-client/48329/5 "2024-10-21T20:08:10Z")

</div>

I'm not sure. That might be it. I did notice, though, that I can complete uploads that have already been started.

---

<div class="post-metadata">

**Author:** ![jaimedelano](https://forum.rclone.org/user_avatar/forum.rclone.org/jaimedelano/32/17712_2.png) [@jaimedelano](https://forum.rclone.org/u/jaimedelano)\
**Post date:** [October 22, 2024, 9:24am UTC](https://forum.rclone.org/t/can-rclone-serve-s3-handle-more-than-one-client/48329/6 "2024-10-22T09:24:05Z")

</div>

I couldn't find any mention of a lock in cmd/serve/s3.  
It looks like there are mutexes only in the code of the gofakes3/s3mem backend, which Rclone doesn't seem to use.

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [October 22, 2024, 9:54pm UTC](https://forum.rclone.org/t/can-rclone-serve-s3-handle-more-than-one-client/48329/7 "2024-10-22T21:54:04Z")

</div>

There are mutexes in the VFS layer which are probably causing this. Likely the directory lock is held.

---

<div class="post-metadata">

**Author:** ![jaimedelano](https://forum.rclone.org/user_avatar/forum.rclone.org/jaimedelano/32/17712_2.png) [@jaimedelano](https://forum.rclone.org/u/jaimedelano)\
**Post date:** [October 23, 2024, 6:40pm UTC](https://forum.rclone.org/t/can-rclone-serve-s3-handle-more-than-one-client/48329/8 "2024-10-23T18:40:02Z")

</div>

Even unauthenticated user requests are locked up until the previous action is finished. I'm not sure if this is related to the auth-proxy directive, which I use to create backends on the fly.

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [October 23, 2024, 9:24pm UTC](https://forum.rclone.org/t/can-rclone-serve-s3-handle-more-than-one-client/48329/9 "2024-10-23T21:24:27Z")

</div>

I don't think there is locking in the Auth proxy itself, but maybe how it is called.

If you can get a go routine dump at the point it is locking the Auth calls that will show what is going on. Easiest way is to kill the S3 serve with SIGQUIT or use the RC (see the RC docs)

---

<div class="post-metadata">

**Author:** ![jaimedelano](https://forum.rclone.org/user_avatar/forum.rclone.org/jaimedelano/32/17712_2.png) [@jaimedelano](https://forum.rclone.org/u/jaimedelano)\
**Post date:** [October 23, 2024, 11:51pm UTC](https://forum.rclone.org/t/can-rclone-serve-s3-handle-more-than-one-client/48329/10 "2024-10-23T23:51:29Z")

</div>

You're spot on.  
The issue resides in gofakes3.go:AddAuthKeys().

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [October 24, 2024, 10:23am UTC](https://forum.rclone.org/t/can-rclone-serve-s3-handle-more-than-one-client/48329/11 "2024-10-24T10:23:23Z")

</div>

We've narrowed down which lock which is great.

Looking at the gofakes code this lock is being held throughout the http transaction which is wrong and causing the problem as the lock is held through the very long directory listing.

I've had a go at fixing this - can you give this a try please

[v1.69.0-beta.8379.34749b86e.fix-serve-s3-locking](https://beta.rclone.org/branch/fix-serve-s3-locking/v1.69.0-beta.8379.34749b86e.fix-serve-s3-locking/) on branch [fix-serve-s3-locking](https://github.com/rclone/rclone/tree/fix-serve-s3-locking) (uploaded in 15-30 mins)

---

<div class="post-metadata">

**Author:** ![jaimedelano](https://forum.rclone.org/user_avatar/forum.rclone.org/jaimedelano/32/17712_2.png) [@jaimedelano](https://forum.rclone.org/u/jaimedelano)\
**Post date:** [October 24, 2024, 5:32pm UTC](https://forum.rclone.org/t/can-rclone-serve-s3-handle-more-than-one-client/48329/12 "2024-10-24T17:32:49Z")

</div>

This fixes it. Thanks!

---

<div class="post-metadata">

**Author:** ![ncw](https://forum.rclone.org/user_avatar/forum.rclone.org/ncw/32/18_2.png) [@ncw](https://forum.rclone.org/u/ncw)\
**Post date:** [October 25, 2024, 9:37am UTC](https://forum.rclone.org/t/can-rclone-serve-s3-handle-more-than-one-client/48329/13 "2024-10-25T09:37:33Z")

</div>

Thanks for testing.

I've merged this to master now which means it will be in [the latest beta](https://beta.rclone.org/) in 15-30 minutes and released in v1.69

---

<div class="post-metadata">

**Author:** ![system](https://forum.rclone.org/uploads/default/original/2X/3/39ad3235f6ffec76ccd0c81616bd55697b4c300d.png) [@system](https://forum.rclone.org/u/system)\
**Post date:** [October 28, 2024, 9:37am UTC](https://forum.rclone.org/t/can-rclone-serve-s3-handle-more-than-one-client/48329/14 "2024-10-28T09:37:36Z")

</div>

Closed on October 28, 2024, 9:37am UTC

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.
