mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-10-15 10:38:35 +02:00
fix: address review comments on admin_script seeding
- Replace TOCTOU race (separate Load+Save) with atomic SaveJobTypeConfigIfNotExists on ConfigStore and Plugin - Replace ineffective polling loop with single GetMaster call using 30s context timeout, since GetMaster respects context cancellation - Add unit tests for SaveJobTypeConfigIfNotExists (in-memory + on-disk) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
5432c03ba5
commit
4b2a231913
4 files changed
+146
-18
No files matched your search
@@ -402,6 +402,19 @@ func (r *Plugin) SaveJobTypeConfig(config *plugin_pb.PersistedJobTypeConfig) err
|
||||
return nil
|
||||
}
|
||||
|
||||
// SaveJobTypeConfigIfNotExists atomically saves config only if no config
|
||||
// exists yet for the job type. Returns true if saved, false if already exists.
|
||||
func (r *Plugin) SaveJobTypeConfigIfNotExists(config *plugin_pb.PersistedJobTypeConfig) (bool, error) {
|
||||
saved, err := r.store.SaveJobTypeConfigIfNotExists(config)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
if saved {
|
||||
r.wakeScheduler()
|
||||
}
|
||||
return saved, nil
|
||||
}
|
||||
|
||||
func (r *Plugin) LoadDescriptor(jobType string) (*plugin_pb.JobTypeDescriptor, error) {
|
||||
return r.store.LoadDescriptor(jobType)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user