Flush memcached whenever we drop the databases.

This fixes some issues that we've had where commands will fail is
confusing ways after the database is rebuilt because data from before
the database was dropped is still in the memcached cache.
This commit is contained in:
Tim Abbott
2015-09-28 10:57:40 -07:00
parent 32aea4c9dd
commit bf694fa832
5 changed files with 12 additions and 0 deletions

4
scripts/setup/flush-memcached Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/sh -xe
# Flush memcached
echo 'flush_all' | nc localhost 11211

View File

@@ -15,5 +15,7 @@ CREATE SCHEMA zulip AUTHORIZATION zulip;
CREATE EXTENSION tsearch_extras SCHEMA zulip; CREATE EXTENSION tsearch_extras SCHEMA zulip;
EOF EOF
sh "$(dirname "$0")/flush-memcached"
echo "Database created" echo "Database created"

View File

@@ -5,6 +5,8 @@ DROP DATABASE IF EXISTS zulip;
CREATE DATABASE zulip TEMPLATE zulip_base; CREATE DATABASE zulip TEMPLATE zulip_base;
EOF EOF
sh "$(dirname "$0")/../scripts/setup/flush-memcached"
python manage.py migrate --noinput python manage.py migrate --noinput
python manage.py createcachetable third_party_api_results python manage.py createcachetable third_party_api_results
python manage.py populate_db -n100 --threads=1 python manage.py populate_db -n100 --threads=1

View File

@@ -15,6 +15,7 @@ if [ "$template_grep_error_code" == "0" ]; then
DROP DATABASE IF EXISTS zulip_test; DROP DATABASE IF EXISTS zulip_test;
CREATE DATABASE zulip_test TEMPLATE zulip_test_template; CREATE DATABASE zulip_test TEMPLATE zulip_test_template;
EOF EOF
sh "$(dirname "$0")/../scripts/setup/flush-memcached"
exit 0 exit 0
fi fi
fi fi
@@ -25,6 +26,7 @@ psql -h localhost postgres zulip_test <<EOF
DROP DATABASE IF EXISTS zulip_test; DROP DATABASE IF EXISTS zulip_test;
CREATE DATABASE zulip_test TEMPLATE zulip_test_base; CREATE DATABASE zulip_test TEMPLATE zulip_test_base;
EOF EOF
sh "$(dirname "$0")/../scripts/setup/flush-memcached"
python manage.py migrate --noinput --settings=zproject.test_settings python manage.py migrate --noinput --settings=zproject.test_settings
migration_status "zerver/fixtures/migration-status" migration_status "zerver/fixtures/migration-status"

View File

@@ -67,5 +67,7 @@ psql -h localhost postgres "$USERNAME" <<EOF
CREATE DATABASE $DBNAME TEMPLATE $DBNAME_BASE; CREATE DATABASE $DBNAME TEMPLATE $DBNAME_BASE;
EOF EOF
sh "$(dirname "$0")/../scripts/setup/flush-memcached"
echo "Database created" echo "Database created"