Repostore crash debug (#521)

* repostore listBlocks reads too much data

* Add assert to make sure data is not queried
This commit is contained in:
Ben Bierens 2023-08-22 08:26:58 +02:00 committed by GitHub
parent f459a2c6f6
commit 238771eb73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 3 additions and 1 deletions

View File

@ -272,7 +272,8 @@ method listBlocks*(
of BlockType.Block: CodexBlocksKey of BlockType.Block: CodexBlocksKey
of BlockType.Both: CodexRepoKey of BlockType.Both: CodexRepoKey
without queryIter =? (await self.repoDs.query(Query.init(key))), err: let query = Query.init(key, value=false)
without queryIter =? (await self.repoDs.query(query)), err:
trace "Error querying cids in repo", blockType, err = err.msg trace "Error querying cids in repo", blockType, err = err.msg
return failure(err) return failure(err)
@ -281,6 +282,7 @@ method listBlocks*(
iter.finished = queryIter.finished iter.finished = queryIter.finished
if not queryIter.finished: if not queryIter.finished:
if pair =? (await queryIter.next()) and cid =? pair.key: if pair =? (await queryIter.next()) and cid =? pair.key:
doAssert pair.data.len == 0
trace "Retrieved record from repo", cid trace "Retrieved record from repo", cid
return Cid.init(cid.value).option return Cid.init(cid.value).option