How to delay the directory sync on startup in Confluence
プラットフォームについて: Data Center - この記事は、Data Center プラットフォームのアトラシアン製品に適用されます。
このナレッジベース記事は製品の Data Center バージョン用に作成されています。Data Center 固有ではない機能の Data Center ナレッジベースは、製品のサーバー バージョンでも動作する可能性はありますが、テストは行われていません。サーバー*製品のサポートは 2024 年 2 月 15 日に終了しました。サーバー製品を利用している場合は、アトラシアンのサーバー製品のサポート終了のお知らせページにて移行オプションをご確認ください。
*Fisheye および Crucible は除く
目的
In larger environments with over 1000 LDAP groups, or over 10,000 users, the LDAP sync on Confluence startup can take a long time to complete. This occurs on startup and in some cases can prevent users from logging into the product until the sync is complete.
This article explains how to delay this sync, which will allow for Confluence to complete startup in a reasonable amount of time and allow users to login. The sync can be scheduled to run during off-peak hours to minimize the impact.
This article will serve the purpose of a workaround until this feature request is implemented: CONFSERVER-22326 - Getting issue details... STATUS
Solution - Dynamic Sync Start Time
To delay the directory sync on startup of Confluence, set a value in milliseconds for which the sync should be delayed.
Add the following jvm parameter to <confluence-install>/bin/setenv.sh (or setenv.bat in Windows), or your custom startup script:
-Dcrowd.polling.startdelay=<delay_value_in_milliseconds>
For example, if you wish to delay the sync by 12 hours:
-Dcrowd.polling.startdelay=43200000
- 変更内容を反映するには、 Confluence を再起動します。
This will start the sync 12 hours after Confluence starts, effectively allowing Confluence to be fully up and running and not waiting on a sync to complete before becoming available to users.
Solution - Fixed Sync Start Time
If you wish to use a fixed time, such as 3am to perform the syncs, you can define the number of milliseconds at startup dynamically by creating a variable:
Add the following to your <confluence-install>/bin/setenv.sh file:
TIME_TO_3AM_IN_MS=$(($(($((86400+$(($(date -d "03:00" +%s)-$(date +%s)))))%86400))*1000)) echo "On startup, initial crowd sync will be delayed up to 3AM, which is in $TIME_TO_3AM_IN_MS ms." CATALINA_OPTS="-Dcrowd.polling.startdelay=$TIME_TO_3AM_IN_MS $CATALINA_OPTS"
Or, 7pm for example:
TIME_TO_7PM_IN_MS=$(($(($((86400+$(($(date -d "19:00" +%s)-$(date +%s)))))%86400))*1000)) echo "On startup, initial crowd sync will be delayed up to 7PM, which is in $TIME_TO_7PM_IN_MS ms." CATALINA_OPTS="-Dcrowd.polling.startdelay=$TIME_TO_7PM_IN_MS ${CATALINA_OPTS}"
- 変更内容を反映するには、 Confluence を再起動します。
Breakdown of each step above
# 3am in seconds
3AM_IN_SECONDS=$(date -d "03:00" +%s)
# current time in seconds
CURRENT_TIME_IN_SECONDS=$(date +%s)
# difference between the above
TIME_DIFF=$(($3AM_IN_SECONDS - $CURRENT_TIME_IN_SECONDS))
# add 1 day, modulo 1 day, in case the date command retrieved 3am in the past, causing a negative time difference
# Note that modulo of a negative number *should* be positive according to mathematics but shell script doesn't do this correctly, which is why the day has to be added first
ADJUSTED_TIME_DIFF=$(($((86400 + $TIME_DIFF)) % 86400))
# multiply by 1000 to get ms instead of seconds
TIME_TO_3AM_IN_MS=$(($ADJUSTED_TIME_DIFF * 1000))
注意
- While this KB article was written for Confluence, this JVM parameter can also be applied in other applications.
- Please note that this parameter is currently not working in newer versions of Crowd. See the following Crowd bug for more details CWD-5437 - Getting issue details... STATUS
- On Confluence Data Center the directory synchronization schedule works on different way and the parameter described in this KB doesn't work out of the box. See the following Confluence bug for more details CONFSERVER-60516 - Getting issue details... STATUS