-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
TierBasedSegmentDirectoryLoader to keep segments in multi-datadir #9306
TierBasedSegmentDirectoryLoader to keep segments in multi-datadir #9306
Conversation
Codecov Report
@@ Coverage Diff @@
## master #9306 +/- ##
=============================================
+ Coverage 26.03% 68.77% +42.73%
- Complexity 44 5285 +5241
=============================================
Files 1922 1936 +14
Lines 102937 103474 +537
Branches 15657 15714 +57
=============================================
+ Hits 26796 71160 +44364
+ Misses 73435 27228 -46207
- Partials 2706 5086 +2380
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
pinot-common/src/main/java/org/apache/pinot/common/utils/config/TierConfigUtils.java
Outdated
Show resolved
Hide resolved
...ent-spi/src/main/java/org/apache/pinot/segment/spi/loader/SegmentDirectoryLoaderContext.java
Outdated
Show resolved
Hide resolved
...ocal/src/main/java/org/apache/pinot/segment/local/loader/MultiDirSegmentDirectoryLoader.java
Outdated
Show resolved
Hide resolved
...ocal/src/main/java/org/apache/pinot/segment/local/loader/MultiDirSegmentDirectoryLoader.java
Outdated
Show resolved
Hide resolved
pinot-core/src/main/java/org/apache/pinot/core/data/manager/BaseTableDataManager.java
Show resolved
Hide resolved
pinot-core/src/main/java/org/apache/pinot/core/data/manager/BaseTableDataManager.java
Outdated
Show resolved
Hide resolved
pinot-core/src/main/java/org/apache/pinot/core/data/manager/BaseTableDataManager.java
Show resolved
Hide resolved
pinot-core/src/main/java/org/apache/pinot/core/data/manager/BaseTableDataManager.java
Show resolved
Hide resolved
cafb4e3
to
698813c
Compare
698813c
to
e74b9a6
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'm still confused on how the current tier and target tier is stored.
IIUC, the target tier is stored in ZK metadata, which can be modified by the controller periodic task (not implemented yet). Where is the current tier stored? When server restarts, it needs to be able to find the current tier (not from ZK metadata because that is the target tier), then find the local segment.
pinot-common/src/main/java/org/apache/pinot/common/utils/config/TierConfigUtils.java
Outdated
Show resolved
Hide resolved
pinot-common/src/main/java/org/apache/pinot/common/utils/config/TierConfigUtils.java
Outdated
Show resolved
Hide resolved
It's set when immutable segment is loaded. TieredStorageLoader sets it after loading the segment.
When addOrReplaceSegment() is called, as there is no segment loaded yet, the segmentZKMetadata.tier is used to load the segment for the first time on server. When reloadSegment() is called, as the segment is loaded by server (and we're reloading it), the current tier tracked by the ImmutableSegment object is compared with segmentZKMetadata.tier to decide if there is need to move indexDir to a new dir before reloading the segment. |
What will happen if the tier is updated when server is restarting? Server won't be able to find the old local segment, and the old segment will left as orphan and never be cleaned up. |
Good question. Although will add a cleanup mechanism for orphan segments as part of this work, it's still good to find and reuse the existing segment on disk under such race condition, to avoid orphan segment and downloading raw segment. But as to the ideas |
I thought about the problem of changing data dir, which is a destructive operation anyway (think of the case of server changing its root data dir). That leads me start thinking whether we should store the tier data dir in the table config. IMO that should be a server config because each server might have disk mounted under different path (not likely happen but just an example why it should be part of the server config). Basically the mapping from tier name to data dir should be within the server config, and the table config should only specify the tier name to use. Persisting local tier requires more management overhead such as where to store this meta, when the update it, clean it up when segment is removed etc. That's why checking all previous tiers might be easier. Segment deletion is another problem we need to think of. When segment is deleted, the ZK metadata is already gone. How do we find the local segment to remove? |
e512c4a
to
737caca
Compare
Using a tier track file kept in the default segment dir to help find local segment and reuse them as much as possible. pls help take a look @Jackie-Jiang . I'm thinking to put the track file into |
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.
(MAJOR) the segment delete logic won't work with tier data dir. Please take a look at SegmentOnlineOfflineStateModelFactory.onBecomeDroppedFromOffline()
As for the tracking file management, I'm thinking to keep a file of name <segment>.tier
under the table data dir. IMO it is easier to track than adding it into the segment data dir (think of the case when the segment dir is moved). When deleting the segment from the server, we should also delete the tier tracking file
pinot-core/src/main/java/org/apache/pinot/core/data/manager/BaseTableDataManager.java
Show resolved
Hide resolved
pinot-core/src/main/java/org/apache/pinot/core/data/manager/BaseTableDataManager.java
Outdated
Show resolved
Hide resolved
pinot-core/src/main/java/org/apache/pinot/core/data/manager/BaseTableDataManager.java
Outdated
Show resolved
Hide resolved
|
737caca
to
cfdd876
Compare
cfdd876
to
c986805
Compare
416ec66
to
8d91f3f
Compare
This PR is part of the work to support multi-datadir for Pinot server as tracked by issue.
TierBasedSegmentDirectoryLoader is added in this PR. It implements SegmentDirectoryLoader interface. It checks the target storage tier for the segment and move it from current tier to the target tier. The tier config is extended to include dataDir, so that one can define multi-tier for a table to use multiple datadirs to store segments.
TierBasedSegmentDirectoryLoader is not used unless set
pinot.server.instance.segment.directory.loader
totierBased
.Following PRs will add Controller periodic task to compare segment current/target tiers and trigger segment reloading to move them to target tiers (datadirs) on Pinot servers.