-
Notifications
You must be signed in to change notification settings - Fork 25.3k
Remove obsolete Metadata.FORMAT field and usages #129519
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
Remove obsolete Metadata.FORMAT field and usages #129519
Conversation
The only production usage is for cleaning up all global state files. It is replaced by directly calling the relevant method without creating the FORAMT instance. Test only usages are either replaced by equivalent method calls or dropped. Relates: elastic#114698
Pinging @elastic/es-distributed-coordination (Team:Distributed Coordination) |
* | ||
* @throws WriteStateException if exception when writing state occurs. See also {@link WriteStateException#isDirty()} | ||
*/ | ||
public static void writeManifestAndCleanup(NodeEnvironment nodeEnv, String reason, Manifest manifest) throws WriteStateException { |
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 method is not used before this PR. So I simply removing it here.
/** | ||
* Creates empty cluster state file on disk, deleting global metadata and unreferencing all index metadata | ||
* (only used for dangling indices at that point). | ||
*/ | ||
public void unreferenceAll() throws IOException { | ||
Manifest.FORMAT.writeAndCleanup(Manifest.empty(), nodeEnv.nodeDataPaths()); // write empty file so that indices become unreferenced | ||
Metadata.FORMAT.cleanupOldFiles(Long.MAX_VALUE, nodeEnv.nodeDataPaths()); | ||
MetadataStateFormat.cleanupOldFiles(GLOBAL_STATE_FILE_PREFIX, Long.MAX_VALUE, nodeEnv.nodeDataPaths(), NIOFSDirectory::new); |
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.
Should we just delete the global-*.st
blobs directly? No need to go via NIOFSDirectory
or anything.
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.
Sure pushed 9c301b9
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.
Just realised that the replies are posted as review comments and hence not visible till now.
logger.trace("cleanupOldFiles: cleaning up {} for global state files", location); | ||
final Path stateLocation = location.resolve(MetadataStateFormat.STATE_DIR_NAME); | ||
try (var paths = Files.list(stateLocation)) { | ||
paths.filter(file -> file.getFileName().toString().startsWith(GLOBAL_STATE_FILE_PREFIX)).forEach(file -> { |
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 no longer filters based on Long.MAX_VALUE
anymore. I think in practice, it is the same as deleting all global-*
files. But please let me know if you prefer to keep it.
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 prefer this, the Long.MAX_VALUE
filter was kind of a hack to make it delete everything.
/** | ||
* Creates empty cluster state file on disk, deleting global metadata and unreferencing all index metadata | ||
* (only used for dangling indices at that point). | ||
*/ | ||
public void unreferenceAll() throws IOException { | ||
Manifest.FORMAT.writeAndCleanup(Manifest.empty(), nodeEnv.nodeDataPaths()); // write empty file so that indices become unreferenced | ||
Metadata.FORMAT.cleanupOldFiles(Long.MAX_VALUE, nodeEnv.nodeDataPaths()); | ||
MetadataStateFormat.cleanupOldFiles(GLOBAL_STATE_FILE_PREFIX, Long.MAX_VALUE, nodeEnv.nodeDataPaths(), NIOFSDirectory::new); |
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.
Sure pushed 9c301b9
@elasticmachine update branch |
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.
LGTM
logger.trace("cleanupOldFiles: cleaning up {} for global state files", location); | ||
final Path stateLocation = location.resolve(MetadataStateFormat.STATE_DIR_NAME); | ||
try (var paths = Files.list(stateLocation)) { | ||
paths.filter(file -> file.getFileName().toString().startsWith(GLOBAL_STATE_FILE_PREFIX)).forEach(file -> { |
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 prefer this, the Long.MAX_VALUE
filter was kind of a hack to make it delete everything.
@elasticmachine update branch |
The only production usage is for cleaning up all global state files. It is replaced by directly calling the relevant method without creating the FORAMT instance. Test only usages are either replaced by equivalent method calls or dropped.
Relates: #114698