Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenStack SWIFT: fseek(): stream does not support seeking #25954

Closed
solracsf opened this issue Mar 5, 2021 · 11 comments
Closed

OpenStack SWIFT: fseek(): stream does not support seeking #25954

solracsf opened this issue Mar 5, 2021 · 11 comments
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug feature: object storage

Comments

@solracsf
Copy link
Member

solracsf commented Mar 5, 2021

Duplicate of #8275 or #14617 but for OpenStack SWIFT, as #20033 does NOT fix it (it is intended for S3 only).

[PHP] Error: Error: fseek(): stream does not support seeking at /public/3rdparty/icewind/streams/src/Wrapper.php#82 at <<closure>>

 0. <<closure>>
    OC\Log\ErrorHandler::onError(2, "fseek(): stream ... g", "/srv/users/ ... p", 82, {offset: 32768,whence: 0})
 1. /public/3rdparty/icewind/streams/src/Wrapper.php line 82
    fseek(null, 32768, 0)
 2. <<closure>>
    Icewind\Streams\Wrapper->stream_seek(32768, 0)
 3. /public/3rdparty/icewind/streams/src/Wrapper.php line 82
    fseek(null, 32768, 0)
 4. <<closure>>
    Icewind\Streams\Wrapper->stream_seek(32768, 0)
 5. /public/3rdparty/sabre/dav/lib/DAV/CorePlugin.php line 184
    fseek(null, 32768, 0)
 6. /public/3rdparty/sabre/event/lib/WildcardEmitterTrait.php line 89
    Sabre\DAV\CorePlugin->httpGet(Sabre\HTTP\Request {}, Sabre\HTTP\Response {})
 7. /public/3rdparty/sabre/dav/lib/DAV/Server.php line 474
    Sabre\DAV\Server->emit("method:GET", [Sabre\HTTP\Requ ... }])
 8. /public/3rdparty/sabre/dav/lib/DAV/Server.php line 251
    Sabre\DAV\Server->invokeMethod(Sabre\HTTP\Request {}, Sabre\HTTP\Response {})
 9. /public/3rdparty/sabre/dav/lib/DAV/Server.php line 319
    Sabre\DAV\Server->start()
10. /public/apps/dav/lib/Server.php line 332
    Sabre\DAV\Server->exec()
11. /public/apps/dav/appinfo/v2/remote.php line 35
    OCA\DAV\Server->exec()
12. /public/remote.php line 167
    require_once("/srv/users/ ... p")

GET /remote.php/dav/files/user/Videos/40590592_2138161566405349_5883589116544679936_n.mp4
@solracsf solracsf added bug 0. Needs triage Pending check for reproducibility or if it fits our roadmap feature: object storage labels Mar 5, 2021
@vpecinka

This comment has been minimized.

@vpecinka
Copy link
Contributor

My traceback says also a problem arised in nextcloud/3rdparty/sabre/dav/lib/DAV/CorePlugin.php:184

The code says

            // Streams may advertise themselves as seekable, but still not
            // actually allow fseek.  We'll manually go forward in the stream
            // if fseek failed.
            if (!stream_get_meta_data($body)['seekable'] || -1 === fseek($body, $start, SEEK_SET)) {
                $consumeBlock = 8192;
                for ($consumed = 0; $start - $consumed > 0;) {
                    if (feof($body)) {
                        throw new Exception\RequestedRangeNotSatisfiable('The start offset ('.$start.') exceeded the size of the entity ('.$consumed.')');
                    }
                    $consumed += strlen(fread($body, min($start - $consumed, $consumeBlock)));
                }
            }

however as seen the stream_seek() is called via wrapper nextcloud/3rdparty/icewind/streams/src/Wrapper.php:82

        public function stream_seek($offset, $whence = SEEK_SET) {
                $result = fseek($this->source, $offset, $whence);
                return $result == 0 ? true : false;
        }

that returns false or true (not -1)

@vpecinka
Copy link
Contributor

Ok, i discovered there is Icewind\Streams\SeekableWrapper , replacing it in the Swift.php seems working

--- lib/private/Files/ObjectStore/Swift.php.orig	2021-02-24 20:07:09.000000000 +0100
+++ lib/private/Files/ObjectStore/Swift.php	2021-03-17 17:27:04.987925583 +0100
@@ -29,12 +29,13 @@
 use GuzzleHttp\Client;
 use GuzzleHttp\Exception\BadResponseException;
 use function GuzzleHttp\Psr7\stream_for;
-use Icewind\Streams\RetryWrapper;
+use Icewind\Streams\SeekableWrapper;
 use OCP\Files\NotFoundException;
 use OCP\Files\ObjectStore\IObjectStore;
 use OCP\Files\StorageAuthException;
 
-const SWIFT_SEGMENT_SIZE = 1073741824; // 1GB
+
+const SWIFT_SEGMENT_SIZE = 209715200;
 
 class Swift implements IObjectStore {
 	/**
@@ -126,7 +127,7 @@
 			}
 		}
 
-		return RetryWrapper::wrap($response->getBody()->detach());
+		return SeekableWrapper::wrap($response->getBody()->detach());
 	}
 
 	/**

Can anybody confirm?

@solracsf
Copy link
Member Author

I can try it next week.
cc @icewind1991 if you can give us your opinion before submit any PR.

@vpecinka
Copy link
Contributor

Still, I think the approach as in #20033 is better, as Swift supports Range: bytes=.... The SeekableWrapper seems always reading only forwards, not backwards.

@AndyXheli

This comment has been minimized.

@szaimen

This comment has been minimized.

@ghost

This comment has been minimized.

@ghost ghost added the stale Ticket or PR with no recent activity label Aug 5, 2021
@AndyXheli

This comment has been minimized.

@ghost ghost removed the stale Ticket or PR with no recent activity label Aug 5, 2021
@ghost

This comment has been minimized.

@ghost ghost added the stale Ticket or PR with no recent activity label Sep 4, 2021
@solracsf solracsf removed needs info stale Ticket or PR with no recent activity labels Sep 18, 2021
@q-wertz
Copy link

q-wertz commented May 17, 2022

Still valid on NC 23.0.4

@solracsf solracsf closed this as completed Oct 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0. Needs triage Pending check for reproducibility or if it fits our roadmap bug feature: object storage
Projects
None yet
Development

No branches or pull requests

5 participants