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 3 次提交
    • T
      Close short lived connections · bc35b6b2
      Tyler Ramer 提交于
      Due to refactor of dbconn and newer versions of pygresql, using
      `with dbconn.connect() as conn` no longer attempts to close a
      connection, even if it did prior. Instead, this syntax uses the
      connection itself as context and, as noted in execSQL, overrides the
      autocommit functionality of execSQL.
      
      Therefore, close the connection manually to ensure that execSQL is
      auto-commited, and the connection is closed.
      Co-authored-by: NTyler Ramer <tramer@pivotal.io>
      Co-authored-by: NJamie McAtamney <jmcatamney@pivotal.io>
      bc35b6b2
    • T
      Refactor dbconn · 330db230
      Tyler Ramer 提交于
      One reason pygresql was previously modified was that it did not handle
      closing a connection very gracefully. In the process of updating
      pygresql, we've wrapped the connection it provides with a
      ClosingConnection function, which should handle gracefully closing the
      connection when the "with dbconn.connect as conn" syntax is used.
      
      This did, however, illustrate issues where a cursor might have been
      created as the result of a dbconn.execSQL() call, which seems to hold
      the connection open if not specifically closed.
      
      It is therefore necessary to remove the ability to get a cursor from
      dbconn.execSQL(). To highlight this difference, and to ensure that
      future calls to this library is easy to use, I've cleaned up and
      clarified the dbconn execution code, to include the following features.
      
      - dbconn.execSQL() closes the cursor as part of the function. It returns
        no rows
      - functions dbconn.query() is added, which behaves like dbconn.execSQL()
        except that it now returns a cursor
      - function dbconn.execQueryforSingleton() is renamed
        dconn.querySingleton()
      - function dbconn.execQueryforSingletonRow() is renamed
        dconn.queryRow()
      Authored-by: NTyler Ramer <tramer@pivotal.io>
      330db230
    • 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. 08 6月, 2020 1 次提交
    • P
      Retire guc gp_session_role (#9396) · f6297b96
      Paul Guo 提交于
      Use guc gp_role only now and replace the functionality of guc gp_session_role with it
      also. Previously we have both gucs. The difference of the two gucs are (copied
      from code comment):
      
       * gp_session_role
       *
       * - does not affect the operation of the backend, and
       * - does not change during the lifetime of PostgreSQL session.
       *
       * gp_role
       *
       * - determines the operating role of the backend, and
       * - may be changed by a superuser via the SET command.
      
      This is not friendly for coding. For example, You could find Gp_role and
      Gp_session_role are set as GP_ROLE_DISPATCH on Postmaster & many aux processes
      on all nodes (even QE nodes) in a cluster, so you can see that to differ from
      QD postmaster and QE postmaster, current gpdb uses an additional -E option in
      postmaster arguments. These makes developers confusing when writing role branch
      related code given we have three related variables.  Also some related code is
      even buggy now (e.g. 'set gp_role' even FATAL quits).
      
      With this patch we just have gp_role now. Some changes which might be
      interesting in the patch are:
      
      1. For postmaster, we should specify '-c gp_role=' (e.g. via pg_ctl argument) to
         determine the role else we assume the utility role.
      
      2. For stand-alone backend, utility role is enforced (no need to specify by
         users).
      
      3. Could still connect QE/QD nodes using utility mode with PGOPTIONS, etc as
         before.
      
      4. Remove the '-E' gpdb hacking and align the '-E' usage with upstream.
      
      5. Move pm_launch_walreceiver out of the fts related shmem given the later is
         not used on QE.
      Reviewed-by: NBhuvnesh Chaudhary <bchaudhary@pivotal.io>
      Reviewed-by: NGang Xiong <gxiong@pivotal.io>
      Reviewed-by: NHao Wu <gfphoenix78@gmail.com>
      Reviewed-by: NYandong Yao <yyao@pivotal.io>
      f6297b96
  4. 29 5月, 2020 1 次提交
    • H
      Using gp_add_segment to register mirror in catalog. (#9974) · f7965d48
      Hubert Zhang 提交于
      When introducing a new mirror, we need two steps:
      1. start mirror segment
      2. update gp_segment_configuration catalog
      
      Previously gp_add_segment_mirror will be called to update
      the catalog, but dbid is chosen by get_availableDbId() which
      cannot ensure to be the same dbid in internal.auto.conf.
      Reported by issue9837 
      Reviewed-by: NPaul Guo <pguo@pivotal.io>
      f7965d48
  5. 18 5月, 2020 3 次提交
  6. 14 5月, 2020 4 次提交
    • N
      Retire the disableSystemIndexes option of SegmentStart · bebc77af
      Ning Yu 提交于
      It is no loner needed, the correct approach is to install meta-only
      index files on the new segments.
      bebc77af
    • N
      Exclude files with the --exclude-from option · b0b0b958
      Ning Yu 提交于
      Which was introduced to exclude a large amount of paths.
      
      Also changed the excluding logic of './db_dumps' and './promote'.  They
      were excluded only when an empty 'excludePaths' was specified by the
      caller, this is weird, so I changed the logic to always exclude these
      two paths.
      b0b0b958
    • N
      gpexpand: exclude master-only tables from the template · 1d04cab0
      Ning Yu 提交于
      Gpexpand creates new primary segments by first creating a template from
      the master datadir and then copying it to the new segments.  Some
      catalog tables are only meaningful on master, such as
      gp_segment_configuration, their content are then cleared on each new
      segment with the "delete from ..." commands.
      
      This works but is slow because we have to include the content of the
      master-only tables in the archive, distribute them via network, and
      clear them via the slow "delete from ..." commands -- the "truncate"
      command is fast but it is disallowed on catalog tables as filenode must
      not be changed for catalog tables.
      
      To make it faster we now exclude these tables from the template
      directly, so less data are transferred and there is no need to "delete
      from" them explicitly.
      1d04cab0
    • N
      gppylib: remove duplicated entries in MASTER_ONLY_TABLES · c0b05f8d
      Ning Yu 提交于
      Removed the duplicated 'gp_segment_configuration' entry in the
      MASTER_ONLY_TABLES list.  Also sort the list in alphabetic order to
      prevent dulicates in the future.
      c0b05f8d
  7. 20 3月, 2020 1 次提交
    • (
      Enable external table's error log to be persistent for ETL. (#9757) · 04fdd0a6
      (Jerome)Junfeng Yang 提交于
      For ETL user scenarios, there are some cases that may frequently create
      and drop the same external table. And once the external table gets dropped.
      All errors stored in the error log will lose.
      
      To enable error log persistent for external with the same
      "dbname"."namespace"."table".
      Bring in "error_log_persistent" external table option. If create the
      external table with `OPTIONS (error_log_persistent 'true')` and `LOG ERROR`,
      the external's error log will be name as "dbid_namespaceid_tablename"
      under "errlogpersistent" directory.
      And drop external table will ignore to delete the error log.
      
      Since GPDB 5, 6 still use pg_exttable's options to mark
      LOG ERRORS PERSISTENTLY, so keep the ability for loading from
      OPTIONS(error_log_persistent 'true').
      
      Create separate `gp_read_persistent_error_log` function to read
      persistent error log.
      If the external table gets deleted, only the namespace owner
      has permission to delete the error log.
      
      Create separate `gp_truncate_persistent_error_log` function to delete
      persistent error log.
      If the external table gets deleted. Only the namespace owner has
      permission to delete the error log.
      It also supports wildcard input to delete error logs
      belong to a database or whole cluster.
      
      If drop an external table create with `error_log_persistent`. And then
      create the same "dbname"."namespace"."table" external table without
      persistent error log. It'll write errors to the normal error log.
      The persistent error log still exists.
      Reviewed-by: NHaozhouWang <hawang@pivotal.io>
      Reviewed-by: NAdam Lee <ali@pivotal.io>
      04fdd0a6
  8. 10 3月, 2020 1 次提交
    • H
      Remove gp_elog() function. · 4f0a5ced
      Heikki Linnakangas 提交于
      It was only used for one message in gprecoverseg, and it doesn't seem
      important.
      
      The second argument to the function didn't do anything, since the removal
      of email and SNMP alerts in commit 65822b80. And the NULL checks for the
      arguments were pointless, because the function was marked as strict. But
      rather than clean those up, let's just remove it altogether.
      Reviewed-by: NAsim R P <apraveen@pivotal.io>
      Reviewed-by: NJimmy Yih <jyih@pivotal.io>
      4f0a5ced
  9. 17 2月, 2020 1 次提交
    • H
      Fix dependencies issue in GPPKG utility · 497305b7
      Haozhou Wang 提交于
      1. When two gppkg packages have the same dependencies, gppkg utility
         will refuse to install the second gppkg package and throw an error.
         This patch fixes this issue and the second gppkg package can install
         successfully.
      
      2. Fix install/uninstall issue if the master and standby master use the
         same node address.
      497305b7
  10. 13 2月, 2020 1 次提交
  11. 12 2月, 2020 1 次提交
  12. 11 2月, 2020 3 次提交
    • A
      Incremental recovery and rebalance should run pg_rewind in parallel · 43ad9d05
      Asim R P 提交于
      Incremental recovery and rebalance operations involve running
      pg_rewind against failed primaries.  This patch changes gprecoverseg
      such that pg_rewind is invoked in parallel, using the WorkerPool
      interface, for each affected segment in the cluster.  There is no
      reason to rewind segments one after the other.
      
      Fixes Github issue #9466
      
      Reviewed by: Mark Sliva and Paul Guo
      43ad9d05
    • A
      Remove the gpperfmon (#9553) · dcd8390b
      Adam Lee 提交于
      Remove the gpperfmon since we have the alternative metrics collector.
      
      1, remove all gpperfmon codes, including gpmon, gpsmon, gpmmon,
      gpperfmon and alert_log.
      2, remove all gpperfmon GUCs, `gp_enable_gpperfmon`, `gp_perfmon_segment_interval`,
      `gp_perfmon_print_packet_info`, `gpperfmon_port` and `gpperfmon_log_alert_level`.
      3, remove the `perfmon` and `stats sender` processes/bgworkers.
      4, remove the `apu` and `libsigar` dependencies.
      dcd8390b
    • J
      Allow cluster to start when standby host is down · 3e69d787
      Jamie McAtamney 提交于
      Previously, gpstart could not start the cluster if a standby master host
      was configured but currently down.  In order to check whether the
      standby was supposed to be the acting master (and prevent the master
      from being started if that was the case), gpstart needed to access the
      standby host to retrieve the TimeLineID of the standby, and if the
      standby host was down the master would not start.
      
      This commit modifies gpstart to assume that the master host is the
      acting master if the standby is unreachable, so that it never gets into
      a state where neither the master nor the standby can be started.
      Co-authored-by: NKalen Krempely <kkrempely@pivotal.io>
      Co-authored-by: NMark Sliva <msliva@pivotal.io>
      Co-authored-by: NAdam Berlin <aberlin@pivotal.io>
      3e69d787
  13. 08 2月, 2020 1 次提交
    • A
      Make gpcheckcat independent of master dbid · d1f19ca9
      Ashwin Agrawal 提交于
      gpcheckcat hard-coded master dbid to 1 for various queries. This
      assumption is flawed. There is no restriction master can only have dbid
      1, it can be any value. For example, failover to standby and gpcheckat
      is not usable with that assumption.
      
      Hence, run-time find the value of master's dbid using the info that
      it's content-id is always -1 and use the same.
      Co-authored-by: NAlexandra Wang <lewang@pivotal.io>
      d1f19ca9
  14. 23 1月, 2020 4 次提交
  15. 03 1月, 2020 1 次提交
    • A
      GpDirsExist check for directories only · c7060f84
      Ashwin Agrawal 提交于
      gpdeletesystem uses GpDirsExist() to check if dump directories are
      present to warn and avoid deleting the cluster. Only if "-f" option is
      used allowed to delete the cluster with dump directories
      present. Though this function incorrectly checks for files and
      directories with name "*dump*" and not just directories.
      
      So, gpdeletesystem started failing after commit eb036ac1. FTS writes
      file with name of file as `gpsegconfig_dump`. GpDirsExist()
      incorrectly reports this as backup directory present and fails. Fix
      the same by only checking for directories and not files.
      
      Fixes https://github.com/greenplum-db/gpdb/issues/8442Reviewed-by: NAsim R P <apraveen@pivotal.io>
      c7060f84
  16. 31 12月, 2019 1 次提交
  17. 06 12月, 2019 1 次提交
  18. 20 9月, 2019 2 次提交
    • P
      Fix pipeline failures caused by the previous commit. · da724e8d
      Paul Guo 提交于
      da724e8d
    • P
      Ship subprocess32 and replace subprocess with it in python code (#8658) · 9c4a885b
      Paul Guo 提交于
      * Ship modified python module subprocess32 again
      
      subprocess32 is preferred over subprocess according to python documentation.
      In addition we long ago modified the code to use vfork() against fork() to
      avoid some "Cannot allocate memory" kind of error (false alarm though - memory
      is actually sufficient) on gpdb product environment that is usually with memory
      overcommit disabled.  And we compiled and shipped it also but later it was just
      compiled but not shipped somehow due to makefile change (maybe a regression).
      Let's ship it again.
      
      * Replace subprocess with our own subprocess32 in python code.
      9c4a885b
  19. 19 9月, 2019 1 次提交
  20. 16 9月, 2019 1 次提交
  21. 14 9月, 2019 2 次提交
  22. 26 8月, 2019 1 次提交
  23. 18 8月, 2019 1 次提交
  24. 07 8月, 2019 1 次提交
  25. 05 8月, 2019 1 次提交
    • D
      Assorted gpMgmt/bin Makefile fixups · 9f707e1e
      Daniel Gustafsson 提交于
      The tree I was working off clearly had stale files, which led me to
      include two utils which were removed some time ago: gpcheckutil.py
      and gpcheck.py. Remove these two from their respective Makefiles.
      
      Also fix a Bash error in the Stream symlink test, the logoical AND
      requires [[ .. ]]; rather than [ .. ];.
      
      Both of these spotted while repeatedly running make install with
      trees in various states.
      9f707e1e
  26. 01 8月, 2019 1 次提交