-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Fix task bootstrapping & simplify segment load/drop flows #16475
Fix task bootstrapping & simplify segment load/drop flows #16475
Conversation
- The load drop handler code talks to the local cache manager via SegmentManager.
server/src/main/java/org/apache/druid/segment/loading/SegmentLocalCacheManager.java
Dismissed
Show dismissed
Hide dismissed
server/src/main/java/org/apache/druid/segment/loading/SegmentLocalCacheManager.java
Fixed
Show fixed
Hide fixed
server/src/main/java/org/apache/druid/segment/loading/SegmentLocalCacheManager.java
Dismissed
Show dismissed
Hide dismissed
server/src/main/java/org/apache/druid/segment/loading/SegmentLocalCacheManager.java
Dismissed
Show dismissed
Hide dismissed
be28082
to
aece4e6
Compare
aece4e6
to
6e563aa
Compare
server/src/main/java/org/apache/druid/segment/loading/SegmentLocalCacheManager.java
Fixed
Show fixed
Hide fixed
server/src/test/java/org/apache/druid/server/TestSegmentUtils.java
Dismissed
Show dismissed
Hide dismissed
server/src/test/java/org/apache/druid/server/TestSegmentUtils.java
Dismissed
Show dismissed
Hide dismissed
@abhishekrb19 , thanks for the detailed description. IIUC, this PR is basically doing the following:
Is there any other bug fix or feature included in this PR too? |
That's about right, except that we're not injecting storage locations into
There's no other bug fix or feature in this PR. I do have another related change that touches some of this code, but given the size of this PR, I will add it separately to make reviewing easier. 🙂 |
Makes sense. Thanks for the clarification, @abhishekrb19 ! |
server/src/test/java/org/apache/druid/server/TestSegmentUtils.java
Dismissed
Show dismissed
Hide dismissed
server/src/test/java/org/apache/druid/server/TestSegmentUtils.java
Dismissed
Show dismissed
Hide dismissed
19c00e4
to
16658e1
Compare
1e028cb
to
e02f5cb
Compare
The intellij-inspect tool doesn't seem to correctly inspect lambda usages. See ScheduledExecutors.
d2d1c2d
to
f11da12
Compare
…/incubator-druid into fixup_task_bootstrap_inject
c262ed4
to
f97d10f
Compare
Problems
The segment bootstrapping logic relies on the presence of configured storage locations. That is, only servers that have storage location configured will act like a "segment data server". Tasks on the other hand don't have this static configuration because tasks can dynamically run on any slot. The
CliPeon
injects a list of dynamicStorageLocation
s. ThisList<StorageLocation>
is not currently present inSegmentLoadDropHandler
, which does the bootstrapping of segments as part of itsstart()
lifecycle. Instead, this class directly usesconfig.getLocations()
, which isn't set by theTaskToolboxFactory
when it instantiatesSegmentCacheManager
.One of the overloaded constructors marked
@VisibleForTesting
inSegmentLocalCacheManager
is also being used by tasks viaSegmentCacheManagerFactory
. This "test constructor" also does not initialize the thread pool executors, so segments won't be loaded into the page cache even if loader config has the appropriate settings.Core changes
The core part of the fix in
SegmentLoadDropHandler
is to rely on the source of truth for the caching layer:SegmentCacheManager
. Currently, the various interactions of the classes are complex and have abstraction leaks in its implementation:SegmentManager
->SegmentCacheLoader
->SegmentCacheManager
SegmentLoadDropHandler
->SegmentManager
->SegmentCacheLoader
->SegmentCacheManager
SegmentLoadDropHandler
->SegmentCacheManager
The
SegmentLoadDropHandler
directly handles the segment info file creation and deletion. These low-level file operations should really be owned and handled by theSegmentCacheManager
and the classes that interact with should just operate at the granularity ofSegment
objects.With this patch, the updated interactions are as follows:
SegmentManager
->SegmentCacheManager
SegmentLoadDropHandler
->SegmentManager
->SegmentCacheManager
The addition and deletion of segment info files are handled by the
SegmentLocalCacheManager
class itself. TheSegmentLoadDropHandler
gets the set of cached segments from theSegmentManager
. To that effect, the dependencies inSegmentLoadDropHandler
have been cleaned up, and this class doesn't fiddle with the segment files directly.In order to simplify this, we did the following:
Removed the
SegmentLoader
interface and its concrete implementationSegmentLocalCacheLoader
. The implementation was acting as a simple factory of Segment objects from the underlying segment files, which has now been moved toSegmentLocalCacheManager
, still providing convenience for any test overrides for the factory.Added the following methods to
SegmentCacheManager
for callers to interact with:SegmentManager
is now responsible for callingstoreInfoFile(segment)
once the segment bookkeeping stuff is successful as part of the load segment flow.SegmentLoadDropHandler
, which is now moved to theSegmentLocalCacheManager
., along with the initialization of the segment download executor.SegmentManager
andSegmentLocalCacheManager
have bene broken down intoloadSegment()
andloadBootstrapSegment()
variants, because segment lazy loading and the fail callback are only applicable for the bootstrap segment flow. This cleanup ensures that callers don't pass unnecessary null arguments anymore and makes the intent clearer.VisibleForTesting
hooks, including the problematic "test constructor" inSegmentLocalCacheManager
noted in the problems section. Where possible, the test code uses the same initialization logic as the core code.Test changes
SegmentLocalCacheManagerTest
andSegmentManagerTest
.SegmentLoaderTest
toSegmentLocalCacheManagerTest
.TestSegmentUtils
for commonly used test utilities that has test implementation support for loadingDataSegment
,Segment
factory, etc.Future work
SegmentLoadDropHandler
toSegmentManager
such that the announcements moves to the manager layer itself. That'll entail a slightly larger refactor.SegmentLocalCacheManagerTest
Both of these require moderate to large refactoring changes, which can be tackled separately.
Release note
Fixed an issue in task bootstrapping that prevented tasks from accepting any segment assignments, including broadcast segments.
This PR has: