Skip to content

Commit 2436ee5

Browse files
authored
Merge pull request #7501 from frappe/fix/mariadb-nofile-dropin
fix(mariadb): Fix the file limit and the replica TLS error on 11.8
2 parents 781ba6e + cefc635 commit 2436ee5

7 files changed

Lines changed: 99 additions & 44 deletions

File tree

‎press/playbooks/roles/mariadb/tasks/main.yml‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,19 @@
5757
path: /etc/mysql/my.cnf
5858
line: '!includedir /etc/mysql/conf.d/'
5959

60+
- name: Create MariaDB Systemd Drop-In Directory
61+
file:
62+
path: /etc/systemd/system/mariadb.service.d
63+
state: directory
64+
mode: 0755
65+
66+
# A drop-in survives package upgrades, which rewrite the unit file.
6067
- name: Set Open Files Count Limit for MariaDB
61-
lineinfile:
62-
dest: /lib/systemd/system/mariadb.service
63-
regexp: '^LimitNOFILE(\s*)=(\s*)\d+'
64-
line: 'LimitNOFILE = infinity'
65-
insertafter: '\[Service\]'
66-
state: present
68+
copy:
69+
dest: /etc/systemd/system/mariadb.service.d/limits.conf
70+
content: |
71+
[Service]
72+
LimitNOFILE=infinity
6773
6874
- name: Set MariaDB to depend on Mounts
6975
template:

‎press/playbooks/roles/mariadb_10_11_to_10_6/tasks/main.yml‎

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,13 +118,20 @@
118118
poll: 15
119119
when: mariadb_10_11_to_10_6_requires_change | bool
120120

121+
- name: Create MariaDB Systemd Drop-In Directory
122+
ansible.builtin.file:
123+
path: /etc/systemd/system/mariadb.service.d
124+
state: directory
125+
mode: 0755
126+
when: mariadb_10_11_to_10_6_requires_change | bool
127+
128+
# A drop-in survives package upgrades, which rewrite the unit file.
121129
- name: Set open files count limit for MariaDB
122-
ansible.builtin.lineinfile:
123-
dest: /lib/systemd/system/mariadb.service
124-
regexp: '^LimitNOFILE(\s*)=(\s*)\d+'
125-
line: 'LimitNOFILE = infinity'
126-
insertafter: '\[Service\]'
127-
state: present
130+
ansible.builtin.copy:
131+
dest: /etc/systemd/system/mariadb.service.d/limits.conf
132+
content: |
133+
[Service]
134+
LimitNOFILE=infinity
128135
when: mariadb_10_11_to_10_6_requires_change | bool
129136

130137
- name: Start MariaDB service

‎press/playbooks/roles/mariadb_10_4_to_10_6/tasks/main.yml‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,19 @@
7676
path: /etc/mysql/my.cnf
7777
line: '!includedir /etc/mysql/conf.d/'
7878

79+
- name: Create MariaDB Systemd Drop-In Directory
80+
file:
81+
path: /etc/systemd/system/mariadb.service.d
82+
state: directory
83+
mode: 0755
84+
85+
# A drop-in survives package upgrades, which rewrite the unit file.
7986
- name: Set Open Files Count Limit for MariaDB
80-
lineinfile:
81-
dest: /lib/systemd/system/mariadb.service
82-
regexp: '^LimitNOFILE(\s*)=(\s*)\d+'
83-
line: 'LimitNOFILE = infinity'
84-
insertafter: '\[Service\]'
85-
state: present
87+
copy:
88+
dest: /etc/systemd/system/mariadb.service.d/limits.conf
89+
content: |
90+
[Service]
91+
LimitNOFILE=infinity
8692
8793
- name: Start MariaDB Service
8894
systemd:

‎press/playbooks/roles/mariadb_10_6/tasks/main.yml‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,13 +40,19 @@
4040
- libmariadbclient18
4141
state: latest
4242

43+
- name: Create MariaDB Systemd Drop-In Directory
44+
file:
45+
path: /etc/systemd/system/mariadb.service.d
46+
state: directory
47+
mode: 0755
48+
49+
# A drop-in survives package upgrades, which rewrite the unit file.
4350
- name: Set Open Files Count Limit for MariaDB
44-
lineinfile:
45-
dest: /lib/systemd/system/mariadb.service
46-
regexp: '^LimitNOFILE(\s*)=(\s*)\d+'
47-
line: 'LimitNOFILE = infinity'
48-
insertafter: '\[Service\]'
49-
state: present
51+
copy:
52+
dest: /etc/systemd/system/mariadb.service.d/limits.conf
53+
content: |
54+
[Service]
55+
LimitNOFILE=infinity
5056
5157
- name: Restart MariaDB Service
5258
systemd:

‎press/playbooks/roles/mariadb_10_6_16_frappe/tasks/main.yml‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,19 @@
4242
- libmariadbclient18
4343
state: latest
4444

45+
- name: Create MariaDB Systemd Drop-In Directory
46+
file:
47+
path: /etc/systemd/system/mariadb.service.d
48+
state: directory
49+
mode: 0755
50+
51+
# A drop-in survives package upgrades, which rewrite the unit file.
4552
- name: Set Open Files Count Limit for MariaDB
46-
lineinfile:
47-
dest: /lib/systemd/system/mariadb.service
48-
regexp: '^LimitNOFILE(\s*)=(\s*)\d+'
49-
line: 'LimitNOFILE = infinity'
50-
insertafter: '\[Service\]'
51-
state: present
53+
copy:
54+
dest: /etc/systemd/system/mariadb.service.d/limits.conf
55+
content: |
56+
[Service]
57+
LimitNOFILE=infinity
5258
5359
- name: Restart MariaDB Service
5460
systemd:

‎press/playbooks/roles/mariadb_10_6_to_11_8/tasks/main.yml‎

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838

3939
- name: Add MariaDB Repository
4040
ansible.builtin.apt_repository:
41-
repo: deb https://mirror.rackspace.com/mariadb/repo/11.8/ubuntu {{ ansible_distribution_release }} main
41+
repo: deb https://archive.mariadb.org/repo/11.8/ubuntu {{ ansible_distribution_release }} main
4242
state: present
4343
update_cache: true
4444
when: mariadb_10_6_to_11_8_current_version is version('11.8.0', '<')
@@ -76,14 +76,24 @@
7676
delay: 120
7777
when: mariadb_10_6_to_11_8_current_version is version('11.8.0', '<')
7878

79+
- name: Create MariaDB Systemd Drop-In Directory
80+
file:
81+
path: /etc/systemd/system/mariadb.service.d
82+
state: directory
83+
mode: 0755
84+
85+
# A drop-in survives package upgrades, which rewrite the unit file.
7986
- name: Set Open Files Count Limit for MariaDB
80-
ansible.builtin.lineinfile:
81-
dest: /lib/systemd/system/mariadb.service
82-
regexp: '^LimitNOFILE(\s*)=(\s*)\d+'
83-
line: 'LimitNOFILE = infinity'
84-
insertafter: '\[Service\]'
85-
state: present
86-
when: mariadb_10_6_to_11_8_current_version is version('11.8.0', '<')
87+
copy:
88+
dest: /etc/systemd/system/mariadb.service.d/limits.conf
89+
content: |
90+
[Service]
91+
LimitNOFILE=infinity
92+
93+
# Unguarded: an already-upgraded host still needs systemd to read the repaired drop-in.
94+
- name: Reload Systemd Configuration
95+
ansible.builtin.systemd:
96+
daemon_reload: true
8797

8898
- name: Start MariaDB Service
8999
ansible.builtin.systemd:

‎press/playbooks/roles/secondary/tasks/main.yml‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,19 @@
5656
path: /var/lib/mysql
5757
mode: 0755
5858

59+
- name: Create MariaDB Systemd Drop-In Directory
60+
file:
61+
path: /etc/systemd/system/mariadb.service.d
62+
state: directory
63+
mode: 0755
64+
65+
# A drop-in survives package upgrades, which rewrite the unit file.
5966
- name: Set Open Files Count Limit for MariaDB
60-
lineinfile:
61-
dest: /lib/systemd/system/mariadb.service
62-
regexp: '^LimitNOFILE(\s*)=(\s*)\d+'
63-
line: "LimitNOFILE = infinity"
64-
insertafter: '\[Service\]'
65-
state: present
67+
copy:
68+
dest: /etc/systemd/system/mariadb.service.d/limits.conf
69+
content: |
70+
[Service]
71+
LimitNOFILE=infinity
6672
6773
- name: Force Systemd to Reread Configuration
6874
systemd:
@@ -111,6 +117,14 @@
111117
master_password: "{{ mariadb_root_password }}"
112118
master_use_gtid: slave_pos
113119

120+
# MariaDB 11.4+ verifies the primary's TLS cert by default. Our primaries have no TLS.
121+
- name: Disable TLS on the replication connection
122+
mysql_query:
123+
login_user: root
124+
login_password: "{{ mariadb_root_password }}"
125+
login_port: "{{ db_port }}"
126+
query: CHANGE MASTER TO MASTER_SSL=0, MASTER_SSL_VERIFY_SERVER_CERT=0
127+
114128
- name: Start MariaDB Secondary Thread
115129
mysql_replication:
116130
mode: startslave

0 commit comments

Comments
 (0)