echo off rem Setlocal enabledelayedexpansion rem counter of no records to delete, to stop deletion rem then inserting the search index synchronizer job SET NO_RECORDS_COUNT=15 ::set tabServPath=%TABLEAU_SERVER_INSTALL_DIR%\packages set tabServPath=%TABLEAU_SERVER_INSTALL_DIR%\packages set psqlPath=%tabServPath%\pgsql.%TABLEAU_SERVER_DATA_DIR_VERSION%\bin\psql.exe set psqlBinPath=%tabServPath%\pgsql.%TABLEAU_SERVER_DATA_DIR_VERSION%\bin\ set binPath=%tabServPath%\bin.%TABLEAU_SERVER_DATA_DIR_VERSION% rem In case that active PG node is not co-located with controller node, uncomment the command below, and change its value to reflect system parameters, and comment the other set getPGPassCmd command. rem set getPGPassCmd=tsm configuration get -k jdbc.password -s https://:8850 -u -p set getPGPassCmd=tsm configuration get -k jdbc.password rem **************** rem sql commands rem **************** set killConnectionsInUsersTable="SELECT pg_terminate_backend(a.pid) FROM pg_stat_activity a INNER JOIN pg_locks l ON a.pid = l.pid WHERE a.state <> 'idle' AND a.pid <> pg_backend_pid() AND a.leader_pid IS DISTINCT FROM pg_backend_pid() AND (l.relation = 'public.users'::regclass::oid);" set disableDuplicateUsersRemovalJob="UPDATE schedules SET run_next_at = run_next_at + interval '100 years' WHERE name = 'Delete duplicate site users Schedule';" set queryDuplicateUsersRemovalJob="SELECT run_next_at,* FROM schedules WHERE name = 'Delete duplicate site users Schedule';" :getPsqlPasssword echo off SET /A i=0 echo -- Path to Tablau Server \bin: %binPath% echo -- Path to psql.exe: %psqlPath% echo # %date% %time%: Verifying paths to psql.exe and Tableau Server \bin... if exist "%binPath%" echo -- \bin path verified. if not exist "%binPath%" ( echo. echo # %date% %time%: *** ERROR : Tableau Server \bin path not found. echo *** Verify Tableau Server is installed, and the path exists. echo *** Use a manual install path overrides if Tableau Server is installed, but the server version in the path doesn't match. echo. goto eof ) if exist "%psqlPath%" echo -- psql.exe path verified. if not exist "%binPath%" ( echo. echo # %date% %time%: *** ERROR : psql.exe path not found. echo # *** Verify Tableau Server is installed, and the path exists. echo # *** Use a manual install path overrides if Tableau Server is installed, but the 10.X version in the path doesn't match. echo. goto eof ) echo. :: Retrieving DB password for rails user. Tabadmin will decrypt it for us. echo # %date% %time%: Preparing DB queries... :: Retrieve the password via 'tabadmin get'. :: This is all we need to do in 10.2/10.3 because 'tabadmin get' only returns "". :: PROD for /f "delims=" %%x in ('tsm configuration get -k jdbc.password') do set pass=%%x for /f "delims=" %%x in ('%getPGPassCmd%') do set pass=%%x if ERRORLEVEL 1 goto getPsqlPassswordFailed if not defined pass goto getPsqlPassswordFailed :: More string parsing for 10.0/10.1 because 'tabamin get' returns "===== the value for key '' is: " if "%pass:~0,5%" EQU "=====" for /f "tokens=2 delims=:" %%a in ("%pass%") do set pass=%%a set pass=%pass: =% set PGPASSWORD=%pass% :RUN_QUERIES killConnectionsInUsersTable "%psqlPath%" -h localhost -p 8060 -U rails -d workgroup -c%killConnectionsInUsersTable% echo. "%psqlPath%" -h localhost -p 8060 -U rails -d workgroup -c%disableDuplicateUsersRemovalJob% echo. "%psqlPath%" -h localhost -p 8060 -U rails -d workgroup -c%queryDuplicateUsersRemovalJob% echo. echo Make sure run_next_at for the schedule is set to 100 years :END