MDEV-35834 Server crash in FVector::distance_to upon concurrent SELECT

a start node in the shared context must be atomically assigned
to a valid and fully initialized node otherwise a concurrent
thread might use it before it's safe
This commit is contained in:
Sergei Golubchik 2025-01-15 09:57:49 +01:00
parent 8ef37ade17
commit 2c797ffe43

View file

@ -686,8 +686,13 @@ int MHNSW_Share::acquire(MHNSW_Share **ctx, TABLE *table, bool for_update)
graph->file->position(graph->record[0]);
(*ctx)->set_lengths(FVector::data_to_value_size(graph->field[FIELD_VEC]->value_length()));
(*ctx)->start= (*ctx)->get_node(graph->file->ref);
return (*ctx)->start->load_from_record(graph);
auto node= (*ctx)->get_node(graph->file->ref);
if ((err= node->load_from_record(graph)))
return err;
(*ctx)->start= node; // set the shared start only when node is fully loaded
return 0;
}
/* copy the vector, preprocessed as needed */