-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
RESP2 parser error with large, multi-chunk responses #2419
Comments
@leibale, tagging you here since you made that decoder and no one has modified it since. Hope you don't mind. |
@fast-facts thanks for reporting! Can you please share code that reproduce the issue so I'll be able to debug that? |
See below. I did also notice if I remove the
|
@fast-facts tnx, i'll use this to debug it tomorrow edit: I guess I'll need to generate 5k records first... can you share your schema, please? |
However, Notice how the second id, 2497885, gets converted into
Full code:
Running the command directly:
|
err: |
I removed the url from actual sample code and replaced it with |
@fast-facts which version of redisearch are you using? |
@leibale Built from source using the guide: https://redis.io/docs/stack/search/quick_start/ Latest commit:
|
@fast-facts I just checked with the latest version of RediSearch and looks like |
@leibale Thank you, I appreciate your help on this. |
@fast-facts I just tried with RedisSearch 2.0.16, the reply didn't change, it's #2366 that never worked with more than one document.. 🤦♂️ Thanks for helping and answering all the questions, it's very helpful :) edit: |
@fast-facts I tried to reproduce the original issue using this code import { createClient, SchemaFieldTypes } from 'redis';
const client = createClient();
client.on('error', err => console.error('Redis Client Error', err));
await client.connect();
const promises = [
client.flushAll(),
client.ft.create('idx', {
field: SchemaFieldTypes.TEXT
})
];
for (let i = 0; i < 100000; i++) {
promises.push(client.hSet(i.toString(), 'field', 'value'));
}
await Promise.all(promises);
for (let i = 0; i < 100; i++) {
console.log(`Starting ${i}`);
const { documents: { length } } = await client.ft.search('idx', '*', { LIMIT: { from: 0, size: 100000 } });
console.log(`${i} returnd ${length} documents`);
}
await client.disconnect(); but it's working... (make sure not to run this code with your production redis-server, it's executing the |
Yeah, I confirmed that the original issue is resolved when I changed from Not sure how the |
@fast-facts I'll try with |
@leibale Do you, per chance, have an idea of when this would be merged in and a new release created? |
@fast-facts I think it'll be ready tomorrow, I want to review #2424 again and do #2411. You can follow the progress here. Sorry for the release delay... |
No problem, I appreciate your help. |
* ref #2419 - fix FT.SEARCH RETURN [] * fix transformReply * fix PROFILE SEARCH as well * fix PROFILE SEARCH preserve * move preserve login to `pushSearchOptions` * attach preserve only if true * fix RETURN: [] test
@fast-facts |
Thank you! |
Description
I'm running an FT.Search command that returns 5000 items (using a limit argument). Upon debugging, I noticed the data usually comes in through 8-10 chunks. 95% of the time, the command just hangs. I have to reduce the limit argument to about 1000 for the command to succeed regularly. It seems to be there's some race condition with a larger number of chunks.
I confirmed the issue is not with the redis server or with the network as I was running it directly from the redis-cli command without any issues.
After much debugging, I boiled down the issue to the write function in the RESP2 decoder.
After adding various logging, I noticed that you can guarantee the function finishes, at least for me, if you slow down the parseBulkString function, but obviously the function takes way longer to finish. I added a
console.trace
on line 178 to achieve this. It is possible that I could just slow down some other parts of the file as well to achieve the same result. It might not be anything special about that function.I'm unsure of the nuances of it all to be able to resolve this on my own, but here's the information that I've gathered, mostly through inserting various logging. I'll keep working on it and providing feedback that might be helpful.
I modified the function as such to add logging
Here's a sample of the log it produces during a successful run
Here's a sample of a hanging run (notice the negative numbers)
Node.js Version
18.12.1
Redis Server Version
7.0.8
Node Redis Version
4.6.4
Platform
Windows and Linux
Logs
No response
The text was updated successfully, but these errors were encountered: