Skip to content

Commit

Permalink
Merge pull request IQSS#190 from GlobalDataverseCommunityConsortium/1…
Browse files Browse the repository at this point in the history
…79_pg_log_statements

pg log statements
  • Loading branch information
donsizemore authored Dec 2, 2021
2 parents 056efbe + e445a9d commit af4f5f5
Show file tree
Hide file tree
Showing 9 changed files with 62 additions and 1 deletion.
1 change: 1 addition & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ db:
pass: dvnsecret
jdbcurl:
log_lock_waits: true
log_statements: none
version: 13
port: 5432
backups:
Expand Down
2 changes: 2 additions & 0 deletions ec2/ec2-create-instance.sh
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@ if [ ! -z "$LOCAL_LOG_PATH" ]; then
rsync -av -e "ssh -i $PEM_FILE" --ignore-missing-args $AWS_USER@$PUBLIC_DNS:/tmp/dataverse/src $LOCAL_LOG_PATH/
# 5 server.log*
rsync -av -e "ssh -i $PEM_FILE" --ignore-missing-args $AWS_USER@$PUBLIC_DNS:/usr/local/payara5/glassfish/domains/domain1/logs/server.log* $LOCAL_LOG_PATH/
# 6 query_count.out
rsync -av -e "ssh -i $PEM_FILE" --ignore-missing-args $AWS_USER@$PUBLIC_DNS:/tmp/query_count.out $LOCAL_LOG_PATH/
fi

# Port 8080 has been added because Ansible puts a redirect in place
Expand Down
12 changes: 12 additions & 0 deletions tasks/dataverse-api-testsuite.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@

- include: maven.yml

- include: postgresql_statements.yml
when:
- ansible_os_family == "RedHat"
- db.postgres.log_statements != 'none'
- not db.use_rds

- name: do we have a pom.xml
stat:
path: '{{ dataverse.srcdir }}/pom.xml'
Expand Down Expand Up @@ -105,3 +111,9 @@
args:
chdir: '{{ dataverse.srcdir }}'
when: maven.version != 'default'

- include: postgresql_perl_party.yml
when:
- ansible_os_family == "RedHat"
- db.postgres.log_statements != 'none'
- not db.use_rds
1 change: 0 additions & 1 deletion tasks/postgres.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
when: ansible_os_family == "Debian" and
db.use_rds == false


- name: install postgres client on RedHat / CentOS for RDS
yum:
name: 'postgresql{{ dataverse_pg_version_short }}'
Expand Down
32 changes: 32 additions & 0 deletions tasks/postgresql_perl_party.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---

- name: "Leonid's Postgres PERL Party requires PERL"
ansible.builtin.package:
name: perl
state: latest

# use Leonid's branch until merged into develop
- name: "place Leonid's PERL scripts"
ansible.builtin.get_url:
url: '{{ item }}'
dest: '/var/lib/pgsql/{{ db.postgres.version }}/data/log/'
mode: '0755'
loop:
- https://raw.githubusercontent.com/IQSS/dataverse/develop/scripts/database/querycount/parse.pl
- https://raw.githubusercontent.com/IQSS/dataverse/develop/scripts/database/querycount/count.pl

- name: get name of Postgres logfile
ansible.builtin.find:
paths: '/var/lib/pgsql/{{ db.postgres.version }}/data/log/'
file_type: file
patterns: '*.log'
register: postgres_logs

- name: there should be only one
set_fact:
postgres_log: "{{ postgres_logs.files | map(attribute='path') | list }}"

- name: fire at will
ansible.builtin.shell:
cmd: '/usr/bin/perl count.pl --non-interactive {{ postgres_log[0] }} > /tmp/query_count.out'
chdir: '/var/lib/pgsql/{{ db.postgres.version }}/data/log/'
12 changes: 12 additions & 0 deletions tasks/postgresql_statements.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---

- name: log_statements for testing
lineinfile:
path: '/var/lib/pgsql/{{ db.postgres.version }}/data/postgresql.conf'
regexp: '^#log_statement\ '
line: 'log_statement = {{ db.postgres.log_statements }}'

- name: reload Postgres
ansible.builtin.systemd:
name: 'postgresql-{{ db.postgres.version }}'
state: reloaded
1 change: 1 addition & 0 deletions tests/group_vars/jenkins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ db:
pass: dvnsecret
jdbcurl:
log_lock_waits: true
log_statements: all
version: 13
port: 5432
backups:
Expand Down
1 change: 1 addition & 0 deletions tests/group_vars/memorytests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ db:
pass: dvnsecret
jdbcurl:
log_lock_waits: true
log_statements: none
version: 13
port: 5432
backups:
Expand Down
1 change: 1 addition & 0 deletions tests/group_vars/vagrant.yml
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ db:
pass: vagrantsekret
jdbcurl:
log_lock_waits: true
log_statements: none
version: 13
port: 5432
backups:
Expand Down

0 comments on commit af4f5f5

Please sign in to comment.