|
package swosync |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const txInProgressLock = ` |
|
do $$ |
|
declare |
|
begin |
|
set local idle_in_transaction_session_timeout = 60000; |
|
set local lock_timeout = 60000; |
|
assert (select pg_try_advisory_xact_lock_shared(4919)), 'failed to get shared migration lock'; |
|
assert (select pg_try_advisory_xact_lock(4370)), 'failed to get exec lock'; |
|
assert (select current_state = 'in_progress' from switchover_state), 'switchover state is not in_progress'; |
|
end $$; |
|
` |
|
|
|
|
|
const txStopTheWorld = ` |
|
do $$ |
|
declare |
|
begin |
|
set local idle_in_transaction_session_timeout = 5000; |
|
set local lock_timeout = 10000; |
|
assert (select pg_try_advisory_xact_lock_shared(4919)), 'failed to get shared migration lock'; |
|
perform pg_advisory_xact_lock(4369); |
|
assert (select current_state = 'in_progress' from switchover_state), 'switchover state is not in_progress'; |
|
end $$; |
|
` |
|
|
|
|
|
|
|
const ConnLockQuery = ` |
|
do $$ |
|
declare |
|
begin |
|
set idle_in_transaction_session_timeout = 60000; |
|
set lock_timeout = 60000; |
|
assert (select pg_try_advisory_lock_shared(4919)), 'failed to get shared migration lock'; |
|
assert (select pg_try_advisory_lock(4370)), 'failed to get exec lock'; |
|
assert (select current_state != 'use_next_db' from switchover_state), 'switchover state is use_next_db'; |
|
end $$; |
|
` |
|
|
|
|
|
|
|
const ConnWaitLockQuery = ` |
|
do $$ |
|
declare |
|
begin |
|
set idle_in_transaction_session_timeout = 60000; |
|
set lock_timeout = 60000; |
|
assert (select pg_try_advisory_lock_shared(4919)), 'failed to get shared migration lock'; |
|
perform pg_advisory_lock(4370); |
|
assert (select current_state != 'use_next_db' from switchover_state), 'switchover state is use_next_db'; |
|
end $$; |
|
` |
|
|