
Security News
Open Source Maintainers Demand Ability to Block Copilot-Generated Issues and PRs
Open source maintainers are urging GitHub to let them block Copilot from submitting AI-generated issues and pull requests to their repositories.
Distributed locking using mysql get_lock()
. Unlike distributed locking using redis, this ensures releasing orphaned lock.
This gem uses MySQL get_lock().
Simple ruby codes which describes how it works are as follows:
mysql.query(%Q[select get_lock('db_name.key', -1)])
puts 'get lock'
begin
# do a job
ensure
mysql.query(%Q[select release_lock('db_name.key')])
end
MySQL get_lock()
has a characteristic that the lock is implicitly released when your session terminates (either normally or abnormally). Safe!
Note that
get_lock()
releases any existing lock.MysqlGetlock::Error
at #lock
if another get_lock()
for another key is issued in a session to prevent accidental releases of existing lock.db_name.str
or app_name.environment.str
Add this line to your application's Gemfile:
gem 'mysql_getlock'
And then execute:
$ bundle
Or install it yourself as:
$ gem install mysql_getlock
Similarly with ruby standard library mutex, following methods are available:
MysqlGetlock::LockError
if failed to acquire a lockOptions of MysqlGetlock.new
are:
require 'mysql2'
require 'mysql_getlock'
mysql2 = Mysql2::Client.new # Mysql2::Client.new(options)
mutex = MysqlGetlock.new(mysql2: mysql2, key: 'db_name.lock_key')
mutex.lock
begin
puts 'get lock'
ensure
mutex.unlock
end
mutex.synchronize do
puts 'get lock'
end
Bug reports and pull requests are welcome on GitHub at https://github.com/sonots/mysql_getlock. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that mysql_getlock demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Open source maintainers are urging GitHub to let them block Copilot from submitting AI-generated issues and pull requests to their repositories.
Research
Security News
Malicious Koishi plugin silently exfiltrates messages with hex strings to a hardcoded QQ account, exposing secrets in chatbots across platforms.
Research
Security News
Malicious PyPI checkers validate stolen emails against TikTok and Instagram APIs, enabling targeted account attacks and dark web credential sales.