You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by "Nuutti Kotivuori (Commented) (JIRA)" <ji...@apache.org> on 2011/10/31 09:14:32 UTC
[jira] [Commented] (COUCHDB-887) _log handler has very odd
semantics for bytes/offset, probably a bug
[ https://issues.apache.org/jira/browse/COUCHDB-887?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13139993#comment-13139993 ]
Nuutti Kotivuori commented on COUCHDB-887:
------------------------------------------
Even your explanation is not really exact. What it does is (abstractly):
- start reading from the end
- seek `bytes` backwards from the end
- seek `offset` bytes forward into the file
- read until a maximum of `bytes` bytes is returned
- stop
The result is that:
- bytes=10000&offset=1000 -> returns last 9000 bytes of log file
- bytes=9000 -> returns last 9000 bytes of log file
Like I said in the bug report, the results are 100% equivalent of just doing 'bytes - offset' on the clientside before making the request, except for the case of 'offset => bytes', in which case EOF is returned because of the attempt to read past file end.
In general, I'm having trouble figuring out what the original motivation behind offset is... I mean, *if* it would seek backwards, you could theoretically get the last 100kB of log in 1kB chunks by doing repeated queries with bytes=1024 and incrementing offset by 1024 each time - but in practice the log file grows between each request, so there'll be lots of repeated lines and such.
> _log handler has very odd semantics for bytes/offset, probably a bug
> --------------------------------------------------------------------
>
> Key: COUCHDB-887
> URL: https://issues.apache.org/jira/browse/COUCHDB-887
> Project: CouchDB
> Issue Type: Bug
> Components: HTTP Interface
> Affects Versions: 0.11, 0.11.1, 0.11.2, 1.0, 1.0.1
> Reporter: Nuutti Kotivuori
> Priority: Trivial
> Attachments: couch_log.erl.diff
>
>
> The _log method for couchdb servers has query arguments "bytes" and "offset", but they seem to behave really weirdly. If offset >= bytes, an eof error is returned - otherwise offset is just substracted from bytes and the request behaves identically otherwise.
> A simple fix to the expected behaviour is included - offset counts backwards from bytes.
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira