compose/governor

error in helpers/etcd.py

tvb opened this issue · 6 comments

tvb commented

Found a typo in helpers/etcd.py:

            self.put_client_path("/optime/leader", {"value": state_handler.last_operation()})

Line should read:

            self.put_client_path("/optime/leader", {"value": state_handler.last_leader_operation()})

@tvb, Good catch! This will probably be a catalyst for a test suite, which I've been pondering on.

Actually, I reverted that change because it wasn't a typo, it was just confusing code.

The call to last_operation at https://github.com/compose/governor/blob/master/helpers/etcd.py#L85 is calling the last_operation method on the state_handler(), which retrieves an xlog location from Postgres.

The last_leader_operation method at https://github.com/compose/governor/blob/master/helpers/etcd.py#L90 is a call to etcd, which retrieves the last recorded xlog location stored in etcd.

The method names should be refactored to avoid confusion.

tvb commented

Hmmm then I have another issue:

Traceback (most recent call last):
  File "./governor.py", line 61, in <module>
    logging.info(ha.run_cycle())
  File "/var/lib/postgresql/governor/helpers/ha.py", line 70, in run_cycle
    self.update_lock()
  File "/var/lib/postgresql/governor/helpers/ha.py", line 25, in update_lock
    return self.etcd.update_leader(self.state_handler)
  File "/var/lib/postgresql/governor/helpers/etcd.py", line 85, in update_leader
    self.put_client_path("/optime/leader", {"value": state_handler.last_operation()})
AttributeError: Postgresql instance has no attribute 'last_operation'
LOG:  received fast shutdown request
waiting for server to shut down....LOG:  aborting any active transactions
LOG:  autovacuum launcher shutting down
LOG:  shutting down
LOG:  database system is shut down
 done
server stopped

Changed that line and now I get:

Traceback (most recent call last):
  File "./governor.py", line 57, in <module>
    postgresql.follow_no_leader()
AttributeError: Postgresql instance has no attribute 'follow_no_leader'
pg_ctl: PID file "data/postgres/postmaster.pid" does not exist
Is server running?

Create a new master branch, and see if the problem persists.

git fetch origin && git checkout origin/master -b new_master

I force pushed to erase the change. I'll quit doing that.

tvb commented

I have not pulled the latest changes you made today.