-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
UCP: Support get_lock
and release_lock
functions
#14994
Comments
release_lock
functionsget_lock
and release_lock
functions
@qw4990 Do we always need to consider all lock related function? GET_LOCK() | Get a named lock
IS_FREE_LOCK() | Whether the named lock is free
IS_USED_LOCK() | Whether the named lock is in use; return connection identifier if true
RELEASE_ALL_LOCKS() | Release all current named locks
RELEASE_LOCK() | Release the named lock
|
/pick-up-challenge |
"easy" issue is not available since you have got 200 score in this repo. Please pickup "medium" or "hard" directly. Or you can pick up "easy" Issue in other repos. Thank you. |
@AndrewDi try again please. |
/pick-up-challenge |
@AndrewDi pick up issue success |
/give-up-challenge |
@AndrewDi give up issue success |
It is important to clarify that this can cause correctness issues for applications. They depend on |
I correct my previous statement. It looks like at some point mysql> SELECT get_lock('abcd');
ERROR 1235 (42000): function get_lock has only noop implementation in tidb now, use tidb_enable_noop_functions to enable these functions
mysql> SELECT tidb_version()\G
*************************** 1. row ***************************
tidb_version(): Release Version: v4.0.0-beta.2-932-g8978773f5
Edition: Community
Git Commit Hash: 8978773f5e3d43a100550e6babea9904a99e5938
Git Branch: master
UTC Build Time: 2020-08-10 12:35:53
GoVersion: go1.13
Race Enabled: false
TiKV Min Version: v3.0.0-60965b006877ca7234adaced7890d7b029ed1306
Check Table Before Drop: false
1 row in set (0.00 sec) Thus, I have removed the correctness label. I still think this feature is very useful since Ruby on Rails, Flyway use it for migrations. But the current behavior is no longer high-risk. |
@realxujiang For Flyway, please use 7.11 and above. It uses an alternative implementation of lock: flyway/flyway@77b50ee |
2.1 prisma version
2.2
|
@yahonda Yes. This feature is needed for prisma as well. Waiting tidb to support it. For now I have solved it by enabling noop functions in tidb. SET GLOBAL tidb_enable_noop_functions=1; After that I was able to execute prisma client, which created all tables but got I haven't checked any queries as it a new database for my new project. |
Thanks for the info and I was aware setting |
While I was preparing pingcap/docs-appdev#71 I've found
setting |
Here is the code which runs transaction(meta, opts, fn ->
lock_name = "\"ecto_#{inspect(repo)}\""
try do
{:ok, _} = Ecto.Adapters.SQL.query(meta, "SELECT GET_LOCK(#{lock_name}, -1)", [], opts)
fun.()
after
{:ok, _} = Ecto.Adapters.SQL.query(meta, "SELECT RELEASE_LOCK(#{lock_name})", [], opts)
end
end) |
This is the Ruby on Rails code which is making use of def get_advisory_lock(lock_name, timeout = 0) # :nodoc:
query_value("SELECT GET_LOCK(#{quote(lock_name.to_s)}, #{timeout})") == 1
end
def release_advisory_lock(lock_name) # :nodoc:
query_value("SELECT RELEASE_LOCK(#{quote(lock_name.to_s)})") == 1
end |
Description
Support the
get_lock
andrelease_lock
function, which can be used to implement application locks or to simulate record locks.Score
Mentor(s)
Contact the mentors: #tidb-challenge-program channel in TiDB Community Slack Workspace
Recommended Skills
Learning Materials
The text was updated successfully, but these errors were encountered: