-
Notifications
You must be signed in to change notification settings - Fork 616
Backfill Mutations #3323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backfill Mutations #3323
Conversation
Coverage Report 1Affected Products
Test Logs
Notes |
Size Report 1Affected Products
Test Logs
Notes |
d25f862
to
bba4249
Compare
49939d4
to
85eba03
Compare
/test check-changed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
big brain 🤯
/** The result of a write to the local store. */ | ||
public final class LocalWriteResult { | ||
private final int batchId; | ||
/** The result of a applying local mutations. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/of a/of
Optionally, include how this class is now being used to handle backfill.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
} | ||
/** Returns the lowest offset for the provided index group. */ | ||
private IndexOffset getExistingOffset(Collection<FieldIndex> fieldIndexes) { | ||
if (fieldIndexes.isEmpty()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to assertion b/c fieldIndexes should never be empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -281,4 +320,11 @@ void recalculateAndSaveOverlays(Set<DocumentKey> documentKeys) { | |||
|
|||
return results; | |||
} | |||
|
|||
/** Returns a base document that can be used to apply `overlay`. */ | |||
private MutableDocument createBaseDocument(DocumentKey key, @Nullable Overlay overlay) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consider renaming to getBaseDocument()
since we're getting the base doc from remote doc cache, and then creating an invalid one if it's not found
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done (this was also the original name)
|
||
IndexOffset newOffset = getNewOffset(documents, existingOffset); | ||
IndexOffset newOffset = getNewOffset(existingOffset, nextBatch); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, please add some tests to verify offset correctness when a new fieldindex is added to a collection group that has already been partially indexed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similarly, can we add a test to check that we call computeViews()
to properly fetch the base doc for a patch mutation in an overlay without a corresponding base doc?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added a couple of tests to cover all these scenarios.
* @param collectionGroup The collection group for the documents. | ||
* @param offset The offset to index into. | ||
* @param count The number of documents to return | ||
* @return A LocalDocumentsRResult with the documents that follow the provided offset and the last |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/RR/R
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@@ -281,4 +320,11 @@ void recalculateAndSaveOverlays(Set<DocumentKey> documentKeys) { | |||
|
|||
return results; | |||
} | |||
|
|||
/** Returns a base document that can be used to apply `overlay`. */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional reword: Returns the base document that corresponds to the provided overlay.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skipped as "corresponds" doesn't sound correct when we return an invalid document for a set() even though there is actually a valid document in the cache.
} | ||
|
||
public int getBatchId() { | ||
return batchId; | ||
public int getLargestBatchId() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed, the "largest" batch id here lacks the surrounding context that it's the largest batch id processed by the index backfiller for a collection group. Add comment for context or separate it out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed back to getBatchId().
@@ -141,7 +141,7 @@ public static IndexOffset create( | |||
/** | |||
* Creates an offset that matches all documents with a read time higher than {@code readTime}. | |||
*/ | |||
public static IndexOffset create(SnapshotVersion readTime) { | |||
public static IndexOffset create(SnapshotVersion readTime, int largestBatchId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
optional: rename to avoid unintentional usage where caller expects offset to be the exact provided readtime.
some quick examples: createForNextReadTime/createSucessor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
createSucessor() it is.
computeViews(docs, overlays, Collections.emptySet()); | ||
return new LocalDocumentsResult(largestBatchId, localDocs); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Trying to follow along for getDocumentsMatchingCollectionQuery()
.
If we get the overlays in L298, don't we want to run createBaseDocument()
to get the original remote base doc for the overlay rather than just use a newInvalidDocument()
?
} | ||
|
||
@Test | ||
public void testBackfillUpdatesToLatestReadTimeInCollection() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test is kind of useless now since we're already indexing a document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed. We have a similar test already (testBackfillWritesLatestReadTimeToFieldIndexOnCompletion)
@schmidt-sebastian: The following test failed, say
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
This is another version of #3202
It's a bit simpler:
I also added a new LocalStoreTestCase that verifies our query processing.