Breaking changes
Changing the locking mechanism
This new version of TaskTiger uses a new locking mechanism: the Lock
provided by redis-py. It is incompatible with the old locking mechanism we were using, and several core functions in TaskTiger depends on locking to work correctly, so this warrants a careful migration process.
You can perform this migration in two ways: via a live migration, or via a downtime migration. After the migration, there's an optional cleanup step.
The live migration
-
Update your environment to TaskTiger 0.12 as usual.
-
Deploy TaskTiger as it is in the commit SHA
cf600449d594ac22e6d8393dc1009a84b52be0c1
. Inpip
parlance, it would be:-e git+ssh://git@github.com/closeio/tasktiger.git@cf600449d594ac22e6d8393dc1009a84b52be0c1#egg=tasktiger
-
Wait at least 2-3 minutes with it running in production in all your TaskTiger workers. This is to give time for the old locks to expire, and after that the new locks will be fully in effect.
-
Deploy TaskTiger 0.13. Your system is migrated.
The downtime migration
- Update your environment to TaskTiger 0.12 as usual.
- Scale your TaskTiger workers down to zero.
- Deploy TaskTiger 0.13. Your system is migrated.
The cleanup step
Run the script in scripts/redis_scan.py
to delete the old lock keys from your Redis instance:
./scripts/redis_scan.py --host HOST --port PORT --db DB --print --match "t:lock:*" --ttl 300
The flags:
--host
: The Redis host. Required.--port
: The port the Redis instance is listening on. Defaults to6379
.--db
: The Redis database. Defaults to0
.--print
: If you want the script to print which keys it is modifying, use this.--match
: What pattern to look for. If you didn't change the default prefix TaskTiger uses for keys, this will bet:lock:*
, otherwise it will bePREFIX:lock:*
. By default, scans all keys.--ttl
: A TTL to set. A TTL of 300 will give you time to undo if you want to halt the migration for whatever reason. (Just call this command again with--ttl -1
.) By default, does not change keys' TTLs.
Plus, there is:
--file
: A log file that will receive the changes made. Defaults toredis-stats.log
in the current working directory.--delay
: How long, in seconds, to wait betweenSCAN
iterations. Defaults to0.1
.