-
Notifications
You must be signed in to change notification settings - Fork 111
Online Indexer: replace the synchronized runner with a heartbeat #3530
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
base: main
Are you sure you want to change the base?
Conversation
89d0263
to
f318f65
Compare
a680857
to
83830c6
Compare
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.
I didn't get a chance to look at all of the code, we can discuss some of the things offline.
@@ -180,7 +178,6 @@ <M extends Message> void singleRebuild( | |||
if (!safeBuild) { |
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.
What does safeBuild
here mean in this context? Do we need to continue to prevent concurrency?
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.
The things that had left to non-safeBuild
, as it seems, are clearing and marking the index as write-only and setting constrains that, IIUIC, should not be happening after the previous clearing.
After so many changes in the code, maybe it is time to re-design (and possibly simplify) the singleRebuild
. Should that be a separate PR?
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.
changing and cleaning up safeBuild
should not be part of this PR.
...st/java/com/apple/foundationdb/record/provider/foundationdb/OnlineIndexerBuildIndexTest.java
Outdated
Show resolved
Hide resolved
...ain/java/com/apple/foundationdb/record/provider/foundationdb/OnlineIndexOperationConfig.java
Show resolved
Hide resolved
...ain/java/com/apple/foundationdb/record/provider/foundationdb/OnlineIndexOperationConfig.java
Show resolved
Hide resolved
...ain/java/com/apple/foundationdb/record/provider/foundationdb/OnlineIndexOperationConfig.java
Outdated
Show resolved
Hide resolved
...ore/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingHeartbeat.java
Outdated
Show resolved
Hide resolved
...st/java/com/apple/foundationdb/record/provider/foundationdb/OnlineIndexingHeartbeatTest.java
Show resolved
Hide resolved
...yer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingBase.java
Outdated
Show resolved
Hide resolved
...st/java/com/apple/foundationdb/record/provider/foundationdb/OnlineIndexingHeartbeatTest.java
Show resolved
Hide resolved
...er-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/OnlineIndexer.java
Outdated
Show resolved
Hide resolved
4cf86f4
to
97d02b6
Compare
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.
There were also two comments left on my previous review, that I want to followup on. I resolved everything else in that review, or answered in a (I hope) definitive way, so it should be easy to go back through.
...r-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/FDBRecordStore.java
Show resolved
Hide resolved
...yer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingBase.java
Outdated
Show resolved
Hide resolved
...yer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingBase.java
Outdated
Show resolved
Hide resolved
...yer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingBase.java
Outdated
Show resolved
Hide resolved
...yer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingBase.java
Outdated
Show resolved
Hide resolved
...st/java/com/apple/foundationdb/record/provider/foundationdb/OnlineIndexingHeartbeatTest.java
Show resolved
Hide resolved
...st/java/com/apple/foundationdb/record/provider/foundationdb/OnlineIndexingHeartbeatTest.java
Outdated
Show resolved
Hide resolved
...st/java/com/apple/foundationdb/record/provider/foundationdb/OnlineIndexingHeartbeatTest.java
Outdated
Show resolved
Hide resolved
import java.util.concurrent.CompletableFuture; | ||
import java.util.concurrent.atomic.AtomicInteger; | ||
|
||
public class IndexingHeartbeat { |
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.
We discussed offline, and decided to take a balanced approach of changing the method to info
, so that this is, on disk, future-proofed for being upgraded to be more generic if we want to use it elsewhere. There would still need to be some substantial changes to the code, but it would need to take a subspace instead of a store
and an index
.
.../java/com/apple/foundationdb/record/provider/foundationdb/IndexingHeartbeatLowLevelTest.java
Outdated
Show resolved
Hide resolved
86ad032
to
2a9f7e5
Compare
Each indexing session, for each index, will create a key-value heartbeat of the format: [prefix, xid] -> [indexing-type, genesis time, heartbeat time] Indexing session that are expected to be exclusive will throw an exception if another, active, session exists. Motivation: 1. Represent the heartbeat in every index during multi target indexing (currently - only the master index has a sync lock) 2. Keep a heartbeat during mutual indexing, which can allow better automatic decision making 3. Decide about exclusiveness according to the indexing method (currently - user input) Resolve FoundationDB#3529
...yer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingBase.java
Show resolved
Hide resolved
...yer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingBase.java
Outdated
Show resolved
Hide resolved
...yer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingBase.java
Outdated
Show resolved
Hide resolved
...yer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingBase.java
Outdated
Show resolved
Hide resolved
...yer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingBase.java
Outdated
Show resolved
Hide resolved
...ore/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingHeartbeat.java
Outdated
Show resolved
Hide resolved
.../java/com/apple/foundationdb/record/provider/foundationdb/IndexingHeartbeatLowLevelTest.java
Outdated
Show resolved
Hide resolved
.../java/com/apple/foundationdb/record/provider/foundationdb/IndexingHeartbeatLowLevelTest.java
Outdated
Show resolved
Hide resolved
.../java/com/apple/foundationdb/record/provider/foundationdb/IndexingHeartbeatLowLevelTest.java
Outdated
Show resolved
Hide resolved
...st/java/com/apple/foundationdb/record/provider/foundationdb/OnlineIndexingHeartbeatTest.java
Outdated
Show resolved
Hide resolved
2a9f7e5
to
d3b4baa
Compare
921fd82
to
a8eff82
Compare
...yer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingBase.java
Show resolved
Hide resolved
...yer-core/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingBase.java
Show resolved
Hide resolved
@@ -1259,11 +1214,11 @@ protected static <T> T findException(@Nullable Throwable ex, Class<T> classT) { | |||
return null; | |||
} | |||
|
|||
protected static boolean shouldLessenWork(@Nullable FDBException ex) { | |||
protected static boolean doNotLessenWork(@Nullable FDBException ex) { |
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.
Why are you inverting this method, this seems completely unrelated to the change at hand.
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.
Tried to please an idea warning. But you are right, it is unreadable. Converting back...
...ore/src/main/java/com/apple/foundationdb/record/provider/foundationdb/IndexingHeartbeat.java
Outdated
Show resolved
Hide resolved
FDBRecordStoreTestBase.RecordMetaDataHook hook = myHook(sourceIndex, tgtIndex); | ||
openSimpleMetaData(hook); | ||
|
||
Semaphore pauseMutualBuildSemaphore = new Semaphore(1); |
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.
Doing it in a followup PR sounds good. I think you could make it a little better by making a class ConfigLoaderThatPausesAfterOnePass
that could then store all of these semaphores, and have some more helpful.
There might be something even better, but we're probably getting diminishing returns here, and trying to clean this up more isn't worth it.
To be clear, looking to see if some other tests could take advantage of pauseAfterOnePass
in a followup PR sounds good, but it's probably not worth creating something more full-featured.
...st/java/com/apple/foundationdb/record/provider/foundationdb/OnlineIndexerBuildIndexTest.java
Show resolved
Hide resolved
...ain/java/com/apple/foundationdb/record/provider/foundationdb/OnlineIndexOperationConfig.java
Show resolved
Hide resolved
...ain/java/com/apple/foundationdb/record/provider/foundationdb/OnlineIndexOperationConfig.java
Show resolved
Hide resolved
...c/test/java/com/apple/foundationdb/record/provider/foundationdb/OnlineIndexerSimpleTest.java
Outdated
Show resolved
Hide resolved
...c/test/java/com/apple/foundationdb/record/provider/foundationdb/OnlineIndexerSimpleTest.java
Show resolved
Hide resolved
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.
Teamscale is complaining about two test gaps, these seem easy enough to add coverage in the test you already have.
There's also a few test methods that are beyond the length, or nesting depth threshold, probably worth addressing those.
…ions and tests length
Each indexing session, for each index, will create a key-value heartbeat of the format:
[prefix, xid] -> [indexing-type, genesis time, heartbeat time]
Indexing session that are expected to be exclusive will throw an exception if another, active, session exists.
Motivation:
1. Represent the heartbeat in every index during multi target indexing (currently - only the master index has a sync lock)
2. Keep a heartbeat during mutual indexing, which can allow better automatic decision making
3. Decide about exclusiveness according to the indexing method (currently - user input)
With this change, the equivalent of a sync lock will be determined by the indexing type and cannot be set by the users. The index configuration function
setUseSynchronizedSession
will have no effect on the indexing process.During graduate code upgrade on multiple servers, there may be a situation where one server is indexing with a synchronized session lock, while another server builds the same index with an exclusive heartbeat "lock". If that happens:
a) There will be no more than two concurrent active sessions
b) The indexing sessions will conflict each other until one of the indexers will give up. While this may be not optimal, the generated index will be valid.
Resolve #3529