Repository navigation
Conversation
Indexing should happen before purning in order to avoid lance error: LanceError(IO): External error: Not found data. It causes dodgy race conditions intermittently with parameters arguments like: - cleanup_older_than=timedelta(seconds=0) - delete_unverified=True Refs: lancedb#2963
|
I would want some more details into what exact failure we are fixing. Why did the old order not work correctly? I'm not against changing the order (as long as compaction comes before indexing) but I don't expect it to fix any bugs.
This is a very dangerous combination, with or without this fix. If this optimization is run concurrent with any other operation it can lead to the error described. That is because, with this configuration, the cleanup job will delete files from operations that are in-progress. |
Basically, I have such scenario:
I have such indices for my tables: >>> from lancedb import connect_async
... db = await connect_async('/lancedb')
>>> table = await db.open_table('table')
>>> await table.list_indices()
[Index(BTree, columns=["pk"], name="pk_idx"),
Index(Bitmap, columns=["visibility"], name="visibility_idx"),
Index(IvfPq, columns=["embedding"], name="embedding_idx")]During the day run such script to index newly added data: for table_name in table_names:
table = await db.open_table(table_name)
# Clean up files in dirs _versions, _transactions, merge data in data
# dir, add new vectors into scalar and vector indices.
logger.warning(f"Optimizing {table_name} table...")
stats = await table.optimize(cleanup_older_than=timedelta(seconds=0), delete_unverified=True)
logger.info(stats)
logger.info(f"Finished optimizing {table_name} table.")I don't have any kind of concurrency when run the above script, execution of the script is not overlapping, the same table isn't used twice as well.
If so, then why it's not explicitly stated in docs? It's up to you whether accept this PR or not. I don't know all ins and outs of this project, you have this context, but to me is more logical to create index first and then delete any kind of data that potentially may be used for indexing process. |
Are you continuously adding new vectors while you are executing the optimize script? Even if the add is happening in a different script?
That's a good catch. I thought it was stated. I've opened #3125 to fix that.
Makes a lot of sense to me. I just remember we debated this order for a while when it was first introduced and want to refresh my memory on why we chose this path. |
Yes, I don't stop adding new data when run await table.optimize(
cleanup_older_than=timedelta(hours=3),
delete_unverified=False,
)I think it's more of problem with Here's a full script: |
|
Thank you @sprytnyk for investigating and opening this PR! Reordering the |
Indexing should happen before purning in order to avoid lance error: LanceError(IO): External error: Not found data.
It causes dodgy race conditions intermittently with parameters arguments like:
I ran tests with
cargo test --features remote --testsand all them passing.Refs: #2963