ssbc / jitdb

A database on top of a log with automatic index generation and maintenance
50 stars 7 forks source link

RangeError ERR_OUT_OF_RANGE #214

Open nsantini opened 2 years ago

nsantini commented 2 years ago

I keep getting these errors but I can't figure out what SSB call is triggering it. Might be from a plugin running in the background...

internal/buffer.js:83
  throw new ERR_OUT_OF_RANGE(type || 'offset',
  ^

RangeError [ERR_OUT_OF_RANGE]: The value of "offset" is out of range. It must be >= 0 and <= 5. Received 22
    at boundsError (internal/buffer.js:83:9)
    at Buffer.readUInt32LE (internal/buffer.js:217:5)
    at safeReadUint32 (/Users/nicolassantini/Workspace/perihelion/node_modules/jitdb/index.js:384:18)
    at matchAgainstPrefix (/Users/nicolassantini/Workspace/perihelion/node_modules/jitdb/index.js:856:9)
    at /Users/nicolassantini/Workspace/perihelion/node_modules/jitdb/index.js:984:11
    at ensureIndexSync (/Users/nicolassantini/Workspace/perihelion/node_modules/jitdb/index.js:802:7)
    at getBitsetForOperation (/Users/nicolassantini/Workspace/perihelion/node_modules/jitdb/index.js:983:9)
    at getBitsetForOperation (/Users/nicolassantini/Workspace/perihelion/node_modules/jitdb/index.js:1012:7)
    at getBitsetForOperation (/Users/nicolassantini/Workspace/perihelion/node_modules/jitdb/index.js:1012:7)
    at /Users/nicolassantini/Workspace/perihelion/node_modules/jitdb/index.js:1013:9 {
  code: 'ERR_OUT_OF_RANGE'
}
staltz commented 2 years ago

Thanks for the stack trace. First we need more details:

And then it would be helpful if you would tell us what kind of operators you used, because this error stack trace should only happen with a prefix index, so it's one of these:

https://github.com/ssb-ngi-pointer/ssb-db2/blob/a039325205ab1a6bbe31c7cbf1e54390aa088cb6/operators/index.js#L64

Given that your error says 22, it might be this https://github.com/ssb-ngi-pointer/ssb-db2/blob/a039325205ab1a6bbe31c7cbf1e54390aa088cb6/operators/index.js#L65 but what's odd is that it's happening on a field that is only 5 bytes long, which is very odd. It means that the msg.value.author is 5 characters long, which is totally weird.

Which is why it would be helpful to know how you're writing your queries.

nsantini commented 2 years ago

Hi @staltz , sorry about the delay, I don't seem to have notifications configured for GitHub 😅

Here are the versions:

The queries I'm running are pretty basic:

staltz commented 2 years ago

Thanks. I'm trying to figure out where is the prefix index used. Can you do an ls -la on the db2/indexes folder? That should show us which indexes you're using and which one is a prefix (or prefix map) index, which the stack trace refers to.

nsantini commented 2 years ago

Here you go

drwxr-xr-x  21 nicolassantini  staff      672 21 Apr 08:21 .
drwxr-xr-x   4 nicolassantini  staff      128 30 Mar 08:14 ..
drwxr-xr-x  11 nicolassantini  staff      352 20 Apr 13:18 aboutSelf
drwxr-xr-x  13 nicolassantini  staff      416 20 Apr 13:18 base
-rw-r--r--   1 nicolassantini  staff       34 21 Apr 08:11 canDecrypt.index
drwxr-xr-x  10 nicolassantini  staff      320 21 Apr 08:11 contacts
drwxr-xr-x  16 nicolassantini  staff      512 20 Apr 13:19 ebt
-rw-r--r--   1 nicolassantini  staff       63 21 Apr 08:11 encrypted.index
drwxr-xr-x  11 nicolassantini  staff      352 20 Apr 13:18 hashtags
drwxr-xr-x  47 nicolassantini  staff     1504 20 Apr 13:44 keys
-rw-r--r--   1 nicolassantini  staff   145360 21 Apr 08:20 meta_.index
-rw-r--r--   1 nicolassantini  staff   144904 20 Apr 13:12 meta_private_true.index
-rw-r--r--   1 nicolassantini  staff  4913156 21 Apr 08:20 seq.index
-rw-r--r--   1 nicolassantini  staff  4913156 21 Apr 08:20 sequence.index
-rw-r--r--   1 nicolassantini  staff  9826296 21 Apr 08:20 timestamp.index
-rw-r--r--   1 nicolassantini  staff  4691612 21 Apr 08:21 value_author.32prefix
-rw-r--r--   1 nicolassantini  staff   197214 21 Apr 08:20 value_content_fork__map.32prefixmap
-rw-r--r--   1 nicolassantini  staff  2742020 21 Apr 08:20 value_content_root__map.32prefixmap
-rw-r--r--   1 nicolassantini  staff   139828 21 Apr 08:20 value_content_type_blog.index
-rw-r--r--   1 nicolassantini  staff   145360 21 Apr 08:20 value_content_type_post.index
-rw-r--r--   1 nicolassantini  staff   145316 20 Apr 13:18 value_content_type_pub.index