Skip to content

Conversation

@everfid-ever
Copy link
Contributor

Please provide a description of this PR:

To help us figure out who should review this PR, please put an X in all the areas that this PR affects.

  • Docs
  • Installation
  • User Experience
  • Dubboctl
  • Console
  • Core Component

Please check any characteristics that apply to this pull request.

Copilot AI review requested due to automatic review settings December 10, 2025 02:09
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR implements a distributed locking mechanism using GORM as the backend storage for lock coordination. The implementation provides a Lock interface with methods for acquiring, releasing, renewing, and checking locks, along with a convenience WithLock method for executing functions while holding a lock. The feature integrates with the existing runtime component system and is used to prevent concurrent modifications of configuration rules in the console service layer.

Key Changes

  • New distributed lock abstraction with GORM-based implementation using database-backed lock records with TTL and ownership tracking
  • Component lifecycle integration with automatic expired lock cleanup every 5 minutes
  • Lock protection added to tag route, dynamic config, and condition route operations in console services

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 17 comments.

Show a summary per file
File Description
pkg/core/lock/lock.go Defines the Lock interface with methods for acquiring, releasing, and managing distributed locks
pkg/core/lock/lock_model.go Database model for lock records with unique key constraint and expiration tracking
pkg/core/lock/gorm_lock.go GORM-based implementation of the Lock interface with transaction support and auto-renewal
pkg/core/lock/errors.go Custom error definitions for lock-related failures
pkg/core/lock/component.go Runtime component integration with store dependency and cleanup task
pkg/core/lock/init.go Component registration in the runtime registry
pkg/core/bootstrap/bootstrap.go Adds distributed lock initialization step in the bootstrap sequence
pkg/console/context/context.go Extends console context to provide access to the lock manager
pkg/console/service/tag_rule.go Adds lock protection to tag route create, update, and delete operations
pkg/console/service/configurator_rule.go Adds lock protection to configurator create, update, and delete operations
pkg/console/service/condition_rule.go Adds lock protection to condition route create, update, and delete operations

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Contributor

@robocanic robocanic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! I left some tips, you can discuss it with me through wechat: robocanic

Copy link
Contributor

@robocanic robocanic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work! The implementation of Gorm is very comprehensive. There are some issues about the retrieval of store. I left some comments and if you come across any problems, you can discuss it with me.

GetDataStore() any
}

provider, ok := storeComp.(DataStoreProvider)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: The ResourceStore is designed for Resource, the usage here may not work correctly. How about distinguishing from the bottom layer, that is to say, using the store config to build a new connection pool just for lock.

@sonarqubecloud
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants