Configuration of Crowd for Postgres DR setup
Platform Notice: Data Center Only - This article only applies to Atlassian apps on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
Configuration of Postgres DR(active/standby) setup in Confluence or Crowd
Environment
Crowd
Diagnosis
In Crowd, we can't configure active,standby database servers through standard C3po. It adds an extra backslash when we start the crowd after changes
Cause
The reason is Crowd adds the parameter manually reWriteBatchedInserts=true on detecting the Postgres database thus causing the URL to break
e.g If the following URL is configured in crowd.cfg.xml
jdbc:postgresql://172.16.158.177:5432,172.16.158.178:5432/crowd?targetServerType=master&reWriteBatchedInserts=trueIt will be modified into the following that is not valid
dbc:postgresql://172.16.158.177:5432/,172.16.158.178:5432/crowd?targetServerType=master&reWriteBatchedInserts=trueSolution
The solution is to use a JNDI Datasource connection rather than C3P0.
Step 1: Configure the JNDI Resource
You can define the resource in one of two locations. Note that an explicit <Context> defined in server.xml takes precedence over a separate context file.
Option A: Using crowd.xml
Add the resource to <CROWD_INSTALL>/apache-tomcat/conf/Catalina/localhost/crowd.xml. Ensure the <Resource> is placed inside the <Context> tags:
<Context docBase="../../crowd-webapp" useHttpOnly="true">
<Resource name="jdbc/crowdDS"
auth="Container"
type="javax.sql.DataSource"
username="postgres"
password=""
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://<host-01>:<port>,<host-02>:<port>/<database_name>?targetServerType=master"
maxTotal="60"
maxIdle="20"
validationQuery="select 1" />
</Context>Option B: Using server.xml (If crowd.xml is ignored)
If Tomcat is not loading crowd.xml, define the datasource directly in <CROWD_INSTALL>/apache-tomcat/conf/server.xml inside the <Host> element:
<Context path="/crowd" docBase="../../crowd-webapp">
<Resource name="jdbc/crowdDS"
auth="Container"
type="javax.sql.DataSource"
username="postgres"
password=""
driverClassName="org.postgresql.Driver"
url="jdbc:postgresql://<host-01>:<port>,<host-02>:<port>/<database_name>?targetServerType=master"
maxTotal="60"
maxIdle="20"
validationQuery="select 1" />
<Manager pathname="" />
</Context>Step 2: Update crowd.cfg.xml
Update your crowd.cfg.xml to reference the JNDI datasource and restart Crowd. Ensure you remove any existing hibernate.connection.url, username, password, or c3p0 properties.
<application-configuration>
<properties>
<property name="hibernate.connection.datasource">java:comp/env/jdbc/crowdDS</property>
<property name="hibernate.dialect">org.hibernate.dialect.PostgreSQLDialect</property>
<property name="hibernate.setup">true</property>
<!-- Keep other existing properties like crowd.server.id and license -->
</properties>
</application-configuration>Note:
Due to targetServerType=master, the standby node must be promoted to master before Crowd can connect to it.
Removing reWriteBatchedInserts can decrease the performance of the application.
If you encounter a javax.naming.NameNotFoundException, verify which configuration file Tomcat is deploying by checking catalina.out for the HostConfig.deployDescriptor line.
Was this helpful?