Commit Graph
581 Commits
Author SHA1 Message Date
Oleksii Kliukin 90c738d83a Address the code review by Alex. 2015-10-19 16:03:21 +02:00
Oleksii Kliukin 4e448015f3 Increase the test coverage. 2015-10-19 10:13:14 +02:00
Oleksii Kliukin 11073ac644 Merge branch 'master' into feature/clusterid 2015-10-19 09:37:51 +02:00
Oleksii Kliukin a10b7248a6 Fix a flake8 warning 2015-10-19 09:19:25 +02:00
Oleksii Kliukin 83662f71cb Exit right away if the node sysid is different from the cluster's one 2015-10-16 16:38:05 +02:00
Oleksii Kliukin a844920489 Store the cluster sysid in the initialize flag.
Make sure that the new PostgreSQL node will only
join the cluster if its sysid matches the one
stored in DCS.
2015-10-16 16:14:45 +02:00
Alexander Kukushkin 57ace2009c Merge pull request #66 from zalando/fix/tests
Fix/tests
2015-10-16 10:30:32 +02:00
Alexander Kukushkin 921e4fc323 psycopg2 should be not older than 2.6.1 2015-10-16 10:28:15 +02:00
Oleksii Kliukin 75e5901360 Merge pull request #63 from zalando/bugfix/leader_crash_readonly
Make sure patroni is not using stale connections.
2015-10-16 09:40:55 +02:00
Alexander Kukushkin 16a0a3481d fix pep8 formatting 2015-10-15 09:08:33 +02:00
Alexander Kukushkin 2f0cf1db06 Mock etcd client delete method 2015-10-15 09:08:16 +02:00
Oleksii Kliukin 5c86b60cd2 Fix an exception in the (rather unusual) case of attaching Patroni to an existing running replica. 2015-10-14 17:05:09 +02:00
Feike Steenbergen 98b59354a9 Exclude more files from git. 2015-10-14 14:37:05 +02:00
Oleksii Kliukin 5747f561c0 Merge pull request #64 from zalando/bugfix/pg_controldata_changes
Work around the differences in pg_controldata names.
v0.5
2015-10-14 12:14:07 +02:00
Oleksii Kliukin c7246e48d9 Work around the differences in pg_controldata names. 2015-10-14 09:46:20 +02:00
Oleksii Kliukin 953ea749bf Make sure patroni is not using stale connections.
After the PostgreSQL crash (i.e. with kill -9), the backend
patroni connects to may still exist. In this case, patroni
will get stale postgres role from this backend, preventing
a restarted node with a leader lock from being promoted.

Easily reproducible and also observed in a staging environment
after the postgres crash due to out of disk space.
2015-10-13 15:00:16 +02:00
Oleksii Kliukin 7b079067b9 Merge pull request #59 from zalando/feature/pg_rewind_unclean_shutdown
Feature/pg rewind unclean shutdown. Allow pg_rewind to rewind the former master if it was uncleanly shutdown or just lost the connection and advanced past the point where the new master had promoted. Add configuration block pg_rewind with username and password as mandatory parameters inside this block.
0.4 v0.4
2015-10-13 09:15:25 +02:00
Oleksii Kliukin 101082fa3b more tests. 2015-10-13 09:08:27 +02:00
Oleksii Kliukin 94aa6873f4 Add more tests for the new postgresql methods. 2015-10-13 08:19:44 +02:00
Oleksii Kliukin 46f4788c28 Do not try to run postgres -D during unit tests. 2015-10-12 17:06:13 +02:00
Oleksii Kliukin d7988384d3 Address the code review by Alex Kukushkin:
- check the link before checking the file when deciding to remove it,
  as isfile follows symlinks and, therefore, may return True on them.
- Remove append mode from write_pgpass, as it is always written anew
  before it is used.
- make pg_controldata return an empty hash in case of an error, and
  check for the empty value return by this function before using it.
 some other minior fixed and test updates.
2015-10-12 16:24:02 +02:00
Oleksii Kliukin ce7169f61d Add new tests ha and postgresql. 2015-10-12 15:29:47 +02:00
Oleksii Kliukin 42137e689b Merge remote-tracking branch 'origin/master' into feature/pg_rewind_unclean_shutdown
Modify HA tests to reflect the changes in HA::recover.
2015-10-12 09:22:38 +02:00
Oleksii Kliukin b629e0852f Call pg_rewind in case of the master's unclean shutdown.
If patroni detects the former master was killed, it runs
it first in a single-user mode and then shuts down normally,
to make sure pg_rewind will see a normal shut down status
in pg_controldata.

Add a flag need_rewind, since the point where it is detected
that rewind might be necessary is moved out the code that
runs rewind.
2015-10-12 08:34:08 +02:00
Alexander Kukushkin 2c863ce9a6 Merge pull request #56 from zalando/feature/manual-failover
Feature: manual failover
2015-10-09 16:23:45 +02:00
Alexander Kukushkin cf6be5f58e add missing tests for async_executor 2015-10-09 16:02:34 +02:00
Alexander Kukushkin a588ddc23c Merge branch 'master' of github.com:zalando/patroni into feature/manual-failover 2015-10-09 15:58:38 +02:00
Alexander Kukushkin a6603e8b48 bugfix in zookeeper module:
when master node was being attached to patroni/zookeeper (no cluster in
zookeeper yet) patroni has never tried to "refetch" cluster from DCS.
It was leeding to demote...
2015-10-08 13:07:38 +02:00
Oleksii Kliukin 52c4826569 Reflect the renaming of os-registry.stups.zalan.do to registry.opensource.zalan.do 2015-10-08 12:40:21 +02:00
Alexander Kukushkin 8a844285ff Set fetch_cluster flag to False when _inner_load_cluster called
Set the same flag to True if the cluster does not yet exists in
ZooKeeper
2015-10-07 16:48:39 +02:00
Alexander Kukushkin d48f8384ed leader variable should be None if the leader.name == my name.
This check has to be performed even check_recovery_conf call
2015-10-06 10:07:40 +02:00
Alexander Kukushkin 601ba7db8d Make work with dcs.cluster thread-safe 2015-10-05 14:30:47 +02:00
Alexander Kukushkin 4c444c943e tests for Api.do_GET method 2015-10-02 13:17:58 +02:00
Oleksii Kliukin bad37a5a21 Always check that cluster is configured correctly right before running pg_rewind. 2015-10-02 10:57:49 +02:00
Alexander Kukushkin d8f4b09478 use Event.wait instead of sleep
it makes possible to break "sleep" for example from API

plus small bugfix: catch ValueError exception from json.loads
2015-10-02 10:26:48 +02:00
Alexander Kukushkin d09875a056 refactoring:
1. run touch_member from the main loop
2. move code which takes care about long tasks into separate class
3. change format of data stored in a DCS: use json instead of url
4. change Member class: from now it deserialize everything into data property
5. rework API: from now it takes into account state of the current node in a dcs
2015-10-01 17:06:42 +02:00
Alexander Kukushkin a6cb7563e5 catch all exceptions in change_replication_slots method 2015-10-01 08:06:00 +02:00
Oleksii Kliukin ea910a8987 Make sure pgpass file name is also passed in the PGPASSFILE environment variable. 2015-09-30 18:02:07 +02:00
Oleksii Kliukin b223319183 use the PATH to get the python interpreter path for the scripts. 2015-09-30 18:00:28 +02:00
Oleksii Kliukin d7403f999d Merge branch 'feature/pg_rewind' of https://github.com/zalando/patroni into feature/pg_rewind 2015-09-30 17:13:16 +02:00
Oleksii Kliukin 316e4f8d74 Merge branch 'master' into feature/pg_rewind 2015-09-30 17:12:03 +02:00
Alexander Kukushkin 1997f15a7a Run long time operations asynchronously
i.e. restart, reinitialize, demote
2015-09-30 17:08:15 +02:00
Oleksii Kliukin b4a2ed874f Merge branch 'master' of https://github.com/zalando/patroni 2015-09-30 16:47:07 +02:00
Oleksii Kliukin 182a90973d Make sure tests work with the new pytest. 2015-09-30 16:46:53 +02:00
Alexander Kukushkin 2fdf02e0be Merge pull request #55 from pgexperts/scripts/init-scripts
Added Upstart job for running patroni under Ubuntu 14.04 or 12.04.
2015-09-30 16:39:07 +02:00
Oleksii Kliukin a500781b6d Mock remove_data_directory in the pg_rewind test. 2015-09-30 16:32:56 +02:00
Josh Berkus c4cc0be4fe Added Upstart job for running patroni under Ubuntu 14.04 or 12.04. 2015-09-29 17:35:45 -07:00
Alexander Kukushkin 0572fec6a3 remove leader lock after stop of postgres to speed up failover 2015-09-29 12:59:26 +02:00
Alexander Kukushkin a259764458 Suppress logging from API when postgres is being bootstrapped/initialized 2015-09-29 08:39:05 +02:00
Alexander Kukushkin c218054d05 Implement manual failover
Implementation is done on top of feature/is-healthiest-via-api and
feature/api branches.
In order to trigger manual failover one has to create 'failover' key in
a configuration store with the value in following format:
'leader_name:member_name'
leader_name can be empty or should match with the name of current leader
member_name can be empty or should match with the name one of cluster
nodes
Leader always checks that either desired member (if specified) or one of
the memners is accessible and healthy before demote.
After leader has deomted himself other nodes are performig checks that
desired node is healthy. If it is not they are participating in a leader
race. In some cases (when accidently there is no healthy nodes) former
leader can also participate in a leader race.

Current implementation does not provide REST API endpoint for a manual
failover.
2015-09-28 17:00:42 +02:00