Commit Graph

496 Commits

Author SHA1 Message Date
Greg Price a099e698e2 py3: Switch almost all shebang lines to use `python3`.
This causes `upgrade-zulip-from-git`, as well as a no-option run of
`tools/build-release-tarball`, to produce a Zulip install running
Python 3, rather than Python 2.  In particular this means that the
virtualenv we create, in which all application code runs, is Python 3.

One shebang line, on `zulip-ec2-configure-interfaces`, explicitly
keeps Python 2, and at least one external ops script, `wal-e`, also
still runs on Python 2.  See discussion on the respective previous
commits that made those explicit.  There may also be some other
third-party scripts we use, outside of this source tree and running
outside our virtualenv, that still run on Python 2.
2017-08-16 17:54:43 -07:00
Tim Abbott d43f5ceeec database: Add database index for wildcard mentions. 2017-08-16 13:28:04 -07:00
Tim Abbott 8bb812c8a9 database: Add database index for alert words. 2017-08-16 12:39:01 -07:00
Steve Howell 3a825ef22c Add create_large_indexes management command.
This management command creates the same indexes as migrations
82, 83, and 95, which are all indexes on the huge UserMessage
table. (*)

This command quickly no-ops with clear messaging when the
indexes already exist, so it's idempotent in that regard. (If
somebody somehow creates an index by the same name incorrectly,
they can always drop it in dbshell and re-run this command.)

If any of the migrations have not been run, which we detect simply
by the existence of the indexes, then we create them using a
`CREATE INDEX CONCURRENTLY` command.  This functionality in
postgres allows you to create indexes against large tables
without disrupting queries against those tables.  The tradeoff
here is that creating indexes concurrently takes significantly
longer than doing them non-concurrently.

Since most tables are small, we typically just use regular
Django migrations and run them during a brief interval while
the app is down.

For indexes on big tables, we will want to run this command
as part of the upgrade process, and we will want to run
it while the app is still up, otherwise it's pointless.

All the code in create_indexes() is literally copy/pasted
from the relevant migrations, and that scheme should work
going forward.  (It uses a different implementation of
create_index_if_not_exist than the migrations use, but the
code is identical lexically in the function.)

If we ever do major restructuring of our large tables, such
as UserMessage, and we end up droppping some of these indexes,
then we will need to make this command migrations-aware.  For
now it's safe to assume that indexes are generally additive in
nature, and the sooner we create them during the upgrade process,
the better.

(*) UserMessage is huge for large installations, of course.
2017-08-16 12:38:51 -07:00
Aditya Bansal 0716702558 management: Log number of soft deactivated/reactivated users. 2017-08-15 22:05:19 -07:00
Aditya Bansal 5f5d99550e soft-deactivation/management: Raise exception for non existant emails. 2017-08-15 22:05:19 -07:00
Aditya Bansal cd11cbea14 soft-deactivation/management: Rename variable to make more sense.
We rename variable user_ids_to_deactivate to users_to_deactivate
since it was storing UserProfiles anyway.
2017-08-15 22:05:19 -07:00
Aditya Bansal a33790946b management: Add soft_deactivate_users command. 2017-08-15 08:33:16 -07:00
Vishnu Ks f0bb11ef40 management: Use self.get_user in convert_bot_to_outgoing_webhook. 2017-08-08 14:13:19 -07:00
Vishnu Ks d1bece2ec2 management: Use self.get_realm in create_stream. 2017-08-08 14:13:19 -07:00
Vishnu Ks 9fb5381acb management: Use self.get_realm in set_default_streams. 2017-08-08 14:13:19 -07:00
Vishnu Ks 3bc475d04f management: Use self.get_realm in rename_stream. 2017-08-08 14:13:19 -07:00
Vishnu Ks 4e7dbff197 management: Use self.get_realm in realm_filters. 2017-08-08 14:13:19 -07:00
Vishnu Ks 7859ec76cf management: Use self.get_realm in realm_emoji. 2017-08-08 14:13:19 -07:00
Vishnu Ks af1c1861da management: Use self.get_realm in realm_domain. 2017-08-08 14:13:19 -07:00
Vishnu Ks 1b0b135bfc management: Remove unused imports from process_queue. 2017-08-08 14:13:19 -07:00
Vishnu Ks 0532b35c43 management: Remove unused imports from print_email_delivery_backlog. 2017-08-08 14:13:19 -07:00
Vishnu Ks 164badde13 management: Use self.get_realm in merge_streams.
The variable encoding is removed becuase it is not used
anywhere.
2017-08-08 14:13:19 -07:00
Vishnu Ks 27936fcfd4 management: Remove unused imports from makemessages. 2017-08-08 14:13:19 -07:00
Vishnu Ks cf61349563 management: Use self.get_realm in logout_all_users. 2017-08-08 14:13:19 -07:00
Vishnu Ks e28a007487 management: Use self.get_user in knight command. 2017-08-08 14:13:19 -07:00
Vishnu Ks 3a2edc66f1 management: Use get_system_bot in initialize_voyager_db. 2017-08-08 14:13:19 -07:00
Vishnu Ks f45b80aafe management: Remove unused imports from initialize_voyager. 2017-08-08 14:13:19 -07:00
Vishnu Ks 05af206392 management: Remove unused imports from import command. 2017-08-08 14:13:19 -07:00
Vishnu Ks f58efdc3cb management: Remove unused imports from export_usermessage_batch. 2017-08-08 14:13:19 -07:00
Vishnu Ks 28e76c990a management: Remove unused imports from email_mirror command. 2017-08-08 14:13:19 -07:00
Vishnu Ks 6687b236bf management: Remove unused imports from deliver_email command. 2017-08-08 14:13:19 -07:00
Vishnu Ks b8dacf9bf6 management: Remove unused import from checkconfig command. 2017-08-08 14:13:19 -07:00
Vishnu Ks 5ce0d85ccf management: Remove unused import from check_redis command. 2017-08-08 14:13:19 -07:00
Vishnu Ks 19f8da4995 management: Use self.get_realm in export command. 2017-08-08 14:13:19 -07:00
Vishnu Ks 4e9dff09fd management: Use self.get_realm in dump_messages. 2017-08-08 14:13:19 -07:00
Vishnu Ks bc48c68c09 management: Use self.get_realm in reactivate_realm command. 2017-08-08 14:13:19 -07:00
Vishnu Ks 279af33ea2 management: Use self.get_realm in deactivate_realm. 2017-08-08 14:13:19 -07:00
Vishnu Ks 349d604ad5 management: Use self.get_realm in create_user. 2017-08-08 14:13:19 -07:00
Rishi Gupta ddbf8b9c3c management: Remove create_realm.py.
This no longer does the correct thing (in terms of onboarding emails,
default streams, etc), and is tempting for new server admins to use.

Once we remove it we'll also have the invariant that we can't have a realm
without a user, which will simplify accounts_register a bit.
2017-08-05 10:17:14 -07:00
Vishnu Ks e7f5da83ac management: Create list realms command.
Fixes #5917.
2017-08-04 14:25:03 -07:00
Steve Howell bc6543a236 Use do_mark_all_as_read() in bankrupt_users command. 2017-08-04 14:10:46 -07:00
Steve Howell c5e4ce5278 Optimize show_unreads --fix approach.
This now breaks the process of cleaning up unread counts for
non-active streams into a three step process.

This allows us to use our unread message flags index, at least
in testing on dev.  Here is the relevant excerpt from explain
analyze:

    Bitmap Index Scan on zerver_usermessage_unread_message_id
2017-08-04 11:04:43 -07:00
Greg Price cc30226af0 deliver_email: When disabled, sleep forever rather than exit.
This makes supervisor see the service as cheerfully running
and let it alone, rather than constantly retry starting it.
Because the crash/restart loop means repeatedly spending a
couple of seconds loading Django and the app, separated by
brief periods while supervisor notices the crash and acts
on it, it was actually consuming about 30-50% CPU on the
zulipchat.com staging server.
2017-08-03 16:28:19 -07:00
Steve Howell e994ff36b5 Add option to fix unread messages for inactive streams. 2017-08-03 13:17:04 -07:00
Steve Howell dad1c9326e Add show_unreads management command.
This should help us troubleshoot anomalies with old unread
messages.
2017-08-03 13:17:04 -07:00
neiljp (Neil Pilgrim) 1c7d0c932a mypy: Ensure type of trim_func is consistent in check_redis.py. 2017-08-03 11:03:14 -07:00
Umair Khan 9e33917d25 rate_limiter: Upgrade max_api_calls to generic API. 2017-08-02 18:01:39 -07:00
Umair Khan ca9ac1948e rate_limiter: Upgrade max_api_window to generic API. 2017-08-02 18:01:39 -07:00
Umair Khan 9c08b62448 rate_limiter: Upgrade unblock_user to generic API.
Change name to unblock_access as well.
2017-08-02 18:01:39 -07:00
Umair Khan 23be0875a1 rate_limiter: Upgrade block_user to generic API.
Change name to block_access as well.
2017-08-02 18:01:39 -07:00
rht ca960da58f create_user: Receive password input from a file instead of shell arg.
This is to be used for the case of container orchestration instead of
shell arg to prevent snooping by any user account on the server via `ps
-ef` or any superuser with read access to the user\'s bash history.
2017-07-27 18:08:52 -07:00
Umair Khan 758dbec9e2 tornado: Move setup_tornado_rabbitmq to application.py 2017-07-21 09:55:25 +05:00
Tim Abbott 240f37e8c4 management: Add script to merge two streams.
This is intended to be used occasionally when there's a really good
reason to do so.  While it does work, it hasn't been extensively tested.
2017-07-18 21:08:24 -07:00
Rishi Gupta 0f4b71b766 confirmation: Liberate get_link_for_object from ConfirmationManager. 2017-07-17 23:18:47 -07:00