-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Add support for configuration-based workloads and resources #87093
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: master
Are you sure you want to change the base?
Conversation
@serxa 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs. I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review. |
|
Co-authored-by: serxa <[email protected]>
Co-authored-by: serxa <[email protected]>
Co-authored-by: serxa <[email protected]>
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.
Currently all WORKLOADs and RESOURCEs are managed by IWorkloadEntityStorage interface. Here is the class hierarchy:
/// Interface for a storage of workload entities (WORKLOAD and RESOURCE).
class IWorkloadEntityStorage
/// A common code for all storages
class WorkloadEntityStorageBase : public IWorkloadEntityStorage;
/// Loads workload entities from a specified folder.
class WorkloadEntityDiskStorage : public WorkloadEntityStorageBase
/// Loads RESOURCE and WORKLOAD sql objects from Keeper.
class WorkloadEntityKeeperStorage : public WorkloadEntityStorageBase
To make things consistent completely different approach is required. Both WorkloadEntityDiskStorage and WorkloadEntityKeeperStorage should use a new helper class WorkloadEnitityConfigStorage that loads WORKLOADs and RESOURCEs from config. WorkloadResourceManager should not be changed at all.
IWorkloadEntityStorage get a new method to process updates of a config:
virtual void updateConfiguration(const Poco::Util::AbstractConfiguration & config) {}
WorkloadEntityDiskStorage and WorkloadEntityKeeperStorage override this method and forward update to WorkloadEnitityConfigStorage (which is declared inside both classes as a field). Server.cpp calls updateConfiguration() from config reloader callback (to get the instance it uses global_context and Context::getWorkloadEntityStorage() method).
WorkloadEnitityConfigStorage inherits WorkloadEntityStorageBase. WorkloadEnitityConfigStorage stores currently loaded WORKLOADs and RESOURCEs and updates them on config reloading. The implemetation is very similar to WorkloadEntityKeeperStorage, but the data comes from config, not zookeeper. Check the WorkloadEntityKeeperStorage::refreshEntities() method. Similar WorkloadEnitityConfigStorage::refreshEntities() method should be used on config update. The difference between implementation is that WorkloadEntityKeeperStorage::processWatchQueue() with a dedicated thread is not needed, instead WorkloadEnitityConfigStorage::updateConfiguration() is triggering a refresh.
The entities loaded by WorkloadEnitityConfigStorage are tracked by WorkloadEntityDiskStorage and WorkloadEntityKeeperStorage with the help of subscription. Inspire from WorkloadResourceManager::subscription.
Entity merging logic. If the same workload or resource is present both in SQL and Config, then Config takes precedence. If conflict discovered a createOrUpdateWorkload()/createOrUpdateResource() should be issued to override SQL's entity by config's entity. There might be other kind of conflicts (e.g. cycles) is this case server should not crash, but config update must be ignored by WorkloadEntityDiskStorage or WorkloadEntityKeeperStorage.
To avoid repeating the logic for both WorkloadEntityDiskStorage and WorkloadEntityKeeperStorage classes use some new helper class or WorkloadEntityStorageBase.
Make sure that entities presented by WorkloadEnitityConfigStorage are never stored in disk (by WorkloadEntityDiskStorage) or zookeeper (by WorkloadEntityKeeperStorage).
tests/queries/0_stateless/03233_workload_config_loading.reference
Outdated
Show resolved
Hide resolved
@copilot please continue to iterate on this PR |
… review Co-authored-by: serxa <[email protected]>
Completed the architectural refactoring based on your detailed feedback. The implementation now properly separates concerns with Commit: dc3402e |
... I've implemented the complete architectural refactoring as requested. The changes include:
The implementation follows your exact specifications and maintains the existing workload entity storage architecture while adding the config-based functionality as a composable component. Commit: dc3402e |
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 requires a bit of rework. See review comments for details. @copilot Continue to iterate on this PR
I'll implement the architectural changes you've outlined in the review comments. The key changes are:
Working on these changes now. |
Co-authored-by: serxa <[email protected]>
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.
@copilot check the review comments and continue to iterate. Make sure config structure is defined as described in documentation (.md file). Take into account changes I proposed for documentation.
- Change config format to use `resources_and_workloads` with semicolon-separated SQL statements - Remove custom parsing logic and reuse shared `parseEntitiesFromString()` from base class - Fix config entity updates to work even after initial load in DiskStorage - Update integration test to use new config format Co-authored-by: serxa <[email protected]>
Addressed all review comments:
The implementation now follows the simplified format described in the documentation and uses consistent parsing logic throughout. Commit: dd5d05e |
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.
@copilot check the review comments and continue to iterate on this PR
…loaded flag, and update comments Co-authored-by: serxa <[email protected]>
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.
@copilot this looks good. Let's polish the tests. Check the review comments and continue to iterate.
…onflict Co-authored-by: serxa <[email protected]>
Workflow [PR], commit [aaecedc] Summary: ❌
|
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.
@copilot Make sure all added files end with a new line
Co-authored-by: serxa <[email protected]>
Okay, the code is good now. However, the build fails and the style check fails, so I must check out the branch and continue working on it myself. TBH, I spent some time thoroughly reviewing the generated code, and it's hard to say, but I think the invested time is around what I would have spent doing it myself from scratch.
The bottom line is:
|
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Adds a way to provide WORKLOAD and RESOURCE definitions in SQL using the server configuration "resources_and_workloads" section.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.