Fix priority queue assertion which enforce the item to have strict order #14496
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The crash was triggered by recent changes in standard library. In C++ priority queue library, it forces the item inside the queue to have strict order, which means when A > B, B < A is true.
Reference standard library code:
However, in customized compare function for FieldIndex, it only compares sequence_number and collection_group, which leads to two Field Index could potentially evaluate to equal.
Hence this PR add a unique identifier to the field index to make sure they will never evaluate to equal.
The fix can be verified by running
Firestore_Tests_iOS
in Xcode. It should fail in main branch and success with this change.