Skip to content

Conversation

@vyavdoshenko
Copy link
Contributor

@vyavdoshenko vyavdoshenko commented Apr 23, 2025

The scenario that caused the crash:

FT.CREATE idx SCHEMA n NUMERIC v VECTOR HNSW 8 TYPE FLOAT16 DIM 4 DISTANCE_METRIC L2 M 65537
HSET doc n 0
DEL doc

fixes: #4979

auto id = key_index_.Remove(key);
if (id) {
indices_->Remove(id.value(), *accessor);
try {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I understand. What call exactly throws?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now I understand, I think this should be improved.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The exception occurs inside the library:
third_party/libs/hnswlib/include/hnswlib/hnswalg.h

Screenshot 2025-04-23 at 18 06 06

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, but it's a legitimate flow. so we should protect ourselves and there is no reason for WARNING.
So at least I would move throw/catch into dfly::search::HnswlibAdapter::Remove and remove any logs

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

auto res = Run({"HSET", "doc", "n", "0"});
EXPECT_EQ(res, 1);

res = Run({"HSET", "doc", "n", "1"});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since it's during removal, I assume if we call DEL doc it would achieve similar effect? If yes, it's a clearer test, imho.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, correct. I checked it. DEL doc archives the same effect. I will change the test.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

@vyavdoshenko vyavdoshenko requested a review from romange April 23, 2025 15:51
@vyavdoshenko vyavdoshenko changed the title fix: Adding second hset document causes crash on removing non existent label. fix: HNSW schema deleting document crash Apr 23, 2025
@vyavdoshenko vyavdoshenko self-assigned this Apr 24, 2025
@vyavdoshenko vyavdoshenko enabled auto-merge (squash) April 28, 2025 10:26
@vyavdoshenko vyavdoshenko merged commit 2128eb3 into main Apr 28, 2025
10 checks passed
@vyavdoshenko vyavdoshenko deleted the bobik/hset_vector_crash_fix branch April 28, 2025 11:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dragonfly crashes using VECTOR HNSW schema

3 participants