1. 24 6月, 2020 1 次提交
    • T
      Remove lockfile from mainUtils · 8190ed40
      Tyler Ramer 提交于
      [Lockfile](https://pypi.org/project/lockfile/) has not been maintained
      since around 2015. Further, the functionality it provided seems poor - a
      review of the code indicated that it used the presence of the PID file
      itself as the lock - in Unix, using a file's existence followed by a
      creation is not atomic, so a lock could be prone to race conditions.
      
      The lockfile package also did not clean up after itself - a process
      which was destroyed unexpectedly would not clear the created locks, so
      some faulty logic was added to mainUtils.py, which checked to see if a
      process with the same PID as the lockfile's creator was running. This
      is obviously failure prone, as a new process might be assigned the same
      PID as the old lockfile's owner, without actually being the same process.
      
      (Of note, the SIG_DFL argument to os.kill() is not a signal at all, but
      rather of type signal.handler. It appears that the python cast this
      handler to the int 0, which, according to man 2 kill, leads to no signal
      being sent, but existance and permission checks are still performed. So
      it is a happy accident that this code worked at all)
      
      This commit removes lockfile from the codebase entirely.
      
      It also adds a "PIDLockFile" class which provides an atomic-guarenteed
      lock via the mkdir and rmdir commands on Unix - thus, it is not safely
      portable to Windows, but this should not be an issue as only Unix-based
      utilities use the "simple_main()" function.
      
      PIDLockFile provides API compatible classes to replace most of the
      functionality from lockfile.PidLockFile, but does remove any timeout
      logic as it was not used in any meaningful sense - a hard-coded timeout
      of 1 second was used, but an immediate result of if the lock is held is
      sufficient.
      
      PIDLockFile also includes appropriate __enter__, __exit__, and __del__
      attributes, so that, should we extend this class in the future, with
      syntax is functional, and __del__ calls release, so a process reaped
      unexpectedly should still clean its own locks as part of the garbage
      collection process.
      Authored-by: NTyler Ramer <tramer@pivotal.io>
      8190ed40
  2. 17 6月, 2020 1 次提交
    • T
      Update PyGreSQL from 4.0.0 to 5.1.2 · f5758021
      Tyler Ramer 提交于
      This commit updates pygresql from 4.0.0 to 5.1.2, which requires
      numerous changes to take advantages of the major result syntax change
      that pygresql5 implemented. Of note, cursors or query objects
      automatically cast returned values as appropriate python types - list of
      ints, for example, instead of a string like "{1,2}". This is the bulk of
      the changes.
      
      Updating to pygresql 5.1.2 provides numerous benfits, including the
      following:
      
      - CVE-2018-1058 was addressed in pygresql 5.1.1
      
      - We can save notices in the pgdb module, rather than relying on importing
      the pg module, thanks to the new "set_notices()"
      
      - pygresql 5 supports python3
      
      - Thanks to a change in the cursor, using a "with" syntax guarentees a
        "commit" on the close of the with block.
      
      This commit is a starting point for additional changes, including
      refactoring the dbconn module.
      
      Additionally, since isolation2 uses pygresql, some pl/python scripts
      were updated, and isolation2 SQL output is further decoupled from
      pygresql. The output of a psql command should be similar enough to
      isolation2's pg output that minimal or no modification is needed to
      ensure gpdiff can recognize the output.
      Co-Authored-by: NTyler Ramer <tramer@pivotal.io>
      Co-authored-by: NJamie McAtamney <jmcatamney@pivotal.io>
      f5758021
  3. 23 1月, 2020 1 次提交
    • M
      cross-subnet: fix replication on cross-subnet Greenplum Clusters · 79637980
      Mark Sliva 提交于
      The four CM utilities gpinitsystem, gpinitstandby, gpaddmirrors, and
      gpmovemirrors now have the relevant pg_hba.conf entries to allow WAL
      replication to mirrors from their respective primaries across subnets.
      
      There are two parts to this commit:
      1). modify the CM utilities to add the pg_hba.conf entries to
      allow WAL replication to mirrors across a subnet.
      2). test the relevant CM utilities across subnets
      
      The previous pg_hba.conf replication entry:
          'host replication $USER samenet trust'
      does not allow WAL replication connections across subnets. We keep this entry
      in order to support single-host development. We then add one replication line
      for each primary and mirror interface address to new primaries and mirrors to
      allow this. It looks like:
          'host replication $USER $IP_ADDRESS trust'
          or when HBA_HOSTNAMES=1
          'host replication $USER $HOSTNAME trust'
      Further, if there is ever a failover and subsequent promotion,
      replication connections can be made to the newly promoted primary from the host
      on which the previous primary failed, because those addresses get copied over
      to the new mirror during a pg_base_backup. We also add similar logic to support
      cross-subnet replication between the master and standby. This behavior is
      tested in the cross_subnet behave tests.
      
      The cross_subnet behave tests assert that the replication connection is valid
      by manually making the connection in addition to relying on segments being
      synchronized, as a way to ensure that the pg_hba.conf file is being used.
      Co-authored-by: NJacob Champion <pchampion@pivotal.io>
      Co-authored-by: NAdam Berlin <aberlin@pivotal.io>
      Co-authored-by: NBhuvnesh Chaudhary <bchaudhary@pivotal.io>
      Co-authored-by: NKalen Krempely <kkrempely@pivotal.io>
      Co-authored-by: NDavid Krieger <dkrieger@pivotal.io>
      Co-authored-by: NJamie McAtamney <jmcatamney@pivotal.io>
      79637980
  4. 19 9月, 2019 1 次提交
    • B
      Update pg_hba.conf with mirror information with gpmovemirrors · 97ae3611
      Bhuvnesh Chaudhary 提交于
      When a mirror is moved from one host to another, the pg_hba.conf of the
      corresponding primary should be updated with the entry for the new
      mirror host to allow connections from mirror to primary segment
      database. This is required by pg_rewind during gprecoverseg operations.
      
      Also, an additional minor change is the condition for removing the old
      directories, i think it was a typo error before, as the condition should have
      checked for numOfWorkers>0 instead of >1, because if there is one host
      only, we will not be removing the old directories otherwise.
      97ae3611
  5. 30 5月, 2019 1 次提交
    • D
      parseutils: cluster management input file refactoring · 66448a3c
      David Krieger 提交于
      We simplify and refactor the parsing for gpaddmirrors, gpmovemirrors,
      gprecoverseg and gpexpand.  This eliminates a few hundred lines of code.
      In addition, this commit changes the format of the input lines for the
      input files to these routines.  The separator is now '|' instead of ':'.
      
      <Co-Authored-By> Mark Sliva <msliva@pivotal.io>
      <Co-Authored-By> Jamie McCatamney <jmcatamney@pivotal.io>
      66448a3c
  6. 13 4月, 2019 2 次提交
  7. 21 3月, 2019 1 次提交
    • J
      add gpmovemirrors behave tests · fdf8b611
      Jamie McAtamney 提交于
      We add gpmovemirrors tests and add them to the pipeline as well.
      Using behave tags, some of the tests can run locally on a demo
      cluster.  We also introduce Behave tag logic to choose which
      tests to run.
      
      <Co-Authored-By> Kalen Krempely <kkrempely@pivotal.io>
      <Co-Authored-By> Mark Sliva <msliva@pivotal.io>
      fdf8b611
  8. 29 11月, 2018 1 次提交
    • D
      Compare with None using the is operator · e39047b5
      Daniel Gustafsson 提交于
      While == None works for comparison, it's a wasteful operation as it
      performs type conversion and expansion. Instead move to using the
      "is" operator which is the documented best practice for Python code.
      
      Reviewed-by: Jacob Champion
      e39047b5
  9. 13 1月, 2018 2 次提交
  10. 06 12月, 2017 1 次提交
  11. 01 9月, 2017 3 次提交
    • L
      WorkerPool: protect against batch size 0 · 29ad32b6
      Larry Hamel 提交于
      As part of a previous commit, the WorkerPool of threads will raise if
      the number of workers is set to 0. This prevents a coding error from
      resulting in no work, where work was expected.
      
      This commit reaches through code to protect against the numWorkers
      parameter being 0.
      
      In several cases, the number of workers is set to the number of segments
      or the number of databases. We do not protect those with the expectation
      that something is more significantly wrong if those sums are 0, and that
      an exception would be fitting in those cases.
      Signed-off-by: NMarbin Tan <mtan@pivotal.io>
      29ad32b6
    • M
      gpmovemirrors: fix compilation issues · efd41ea7
      Marbin Tan 提交于
      Signed-off-by: NNadeem Ghani <nghani@pivotal.io>
      efd41ea7
    • S
      unix.RemoveDirectories: optimize and isolate cases · 872c02b3
      Shoaib Lari 提交于
      Previously, RemoveDirectories and RemoveFiles used the unix command
      "rm -rf", but this is inefficient for huge numbers of files.
      Also, these functions accepted any globbed path.
      
      Instead, use "rsync" to optimize deletion of files in a directory.
      On a DCA using 1 million files, this increased speed by about 3x.
      
      Also, this commit breaks up the different use-cases of deletion into
      separate methods, adding methods RemoveDirectoryContents() and RemoveFile()
      and RemoveGlob() to help isolate the assumptions of each case and
      optimize for them.
      Signed-off-by: NLarry Hamel <lhamel@pivotal.io>
      Signed-off-by: NShoaib Lari <slari@pivotal.io>
      872c02b3
  12. 04 5月, 2017 2 次提交
  13. 02 5月, 2017 1 次提交
    • D
      Remove dead code from catalog.py · 2c8a44fc
      Daniel Gustafsson 提交于
      While looking at other things, spotted that there were quite a few
      functions in catalog.py that were unused. Remove these, and also
      remove imports of gppylib.db.catalog when unused.
      2c8a44fc
  14. 28 10月, 2015 1 次提交