deleteRecordAsync does not delete secondary index

Hi everyone! I see an issue using Record Layer and do not know how could I fix it properly.

I scan in a given recordStore by secondary index (let’s call it expiration_timestamp) and getting primary keys that using later in deleteRecordAsync. deleteRecordAsync returns false for some pKeys. I check and looks like there is a number of indexes that referring to nonexistent records.
First of all, I’m not sure how could it happen, as I understand that deleteRecord should delete both the record itself and related index(indexes), but some records have been deleted and related indexes are still there.

So the question is how to delete invalid indexes using record layer? And how to prevent such cases in a first place? I do appreciate if someone could help with this case.

Thanks in advance,
Sergey

Hi Sergey, I apologize for the long delay in replying to your question. To clarify to wording:

as I understand that deleteRecord should delete both the record itself and related index(indexes), but some records have been deleted and related indexes are still there.

I assume you mean “related index entries are still there”? Deleting a record should never delete and index, only the index entries associated with that index.

Do you have an example program that can reproduce this? Certainly, deleting a record should clean up all associated entries, so we would be very interested in a case that can reproduce this problem.

We do have tools to repair invalid value indexes (see https://github.com/FoundationDB/fdb-record-layer/blob/dbd90f9c6bc57518777c756340d02ede2e1e83c5/fdb-record-layer-core/src/test/java/com/apple/foundationdb/record/provider/foundationdb/OnlineIndexScrubberTest.java#L50, note that we don’t have tools to repair other index types at the moment). However, if this indeed is a repeatable bug, we would be very interested in having an example of a test that can result in a corrupt index.