-
Notifications
You must be signed in to change notification settings - Fork 215
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
log long running sqls executed from a stored procedure
Signed-off-by: Aakash Arayambeth <[email protected]>
- Loading branch information
Aakash Arayambeth
committed
Oct 11, 2024
1 parent
52a2268
commit e554cb0
Showing
8 changed files
with
102 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
ifeq ($(TESTSROOTDIR),) | ||
include ../testcase.mk | ||
else | ||
include $(TESTSROOTDIR)/testcase.mk | ||
endif | ||
ifeq ($(TEST_TIMEOUT),) | ||
export TEST_TIMEOUT=3m | ||
endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
DROP PROCEDURE dormant '1' | ||
DROP LUA TRIGGER dormant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
setattr REP_WORKERS 0 | ||
setattr REP_PROCESSORS 0 | ||
decoupled_logputs off |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/usr/bin/env bash | ||
bash -n "$0" | exit 1 | ||
set -x | ||
. ${TESTSROOTDIR}/tools/cluster_utils.sh | ||
. ${TESTSROOTDIR}/tools/runit_common.sh | ||
|
||
function setup_longreq | ||
{ | ||
for node in $CLUSTER ; do | ||
cdb2sql ${CDB2_OPTIONS} --host $node $DBNAME "EXEC PROCEDURE sys.cmd.send('reql longreqfile <stdout>')" | ||
cdb2sql ${CDB2_OPTIONS} --host $node $DBNAME "EXEC PROCEDURE sys.cmd.send('reql longrequest 0')" | ||
cdb2sql ${CDB2_OPTIONS} --host $node $DBNAME "EXEC PROCEDURE sys.cmd.send('reql longsqlrequest 0')" | ||
done | ||
} | ||
|
||
function test_logic | ||
{ | ||
$CDB2SQL_EXE $CDB2_OPTIONS $DBNAME default "insert into t values(1)" | ||
} | ||
|
||
function check_logs | ||
{ | ||
logfile= | ||
found=0 | ||
sleep 20 # give time for .db file to flush | ||
for node in $CLUSTER ; do | ||
logfile="$TESTDIR/logs/$DBNAME.$node.db" | ||
grep 'trigger->dormant' $logfile | ||
if [[ $? == 0 ]]; then | ||
found=1 | ||
break | ||
fi | ||
done | ||
[[ "$found" -ne "1" ]] && failexit "longrequest log not found" | ||
} | ||
|
||
function create_tables_sp_trigger | ||
{ | ||
cdb2sql ${CDB2_OPTIONS} $DBNAME default -f ./tables.sql | ||
cdb2sql ${CDB2_OPTIONS} $DBNAME default -f ./dropsptrigger.sql | ||
cdb2sql ${CDB2_OPTIONS} $DBNAME default -f ./sp.sql | ||
cdb2sql ${CDB2_OPTIONS} $DBNAME default -f ./trigger.sql | ||
} | ||
|
||
function run_test | ||
{ | ||
create_tables_sp_trigger | ||
setup_longreq | ||
test_logic | ||
check_logs | ||
} | ||
|
||
run_test | ||
echo "Success" | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CREATE PROCEDURE dormant version '1'{ | ||
local function main(event) | ||
db:sleep(2) | ||
db:exec("INSERT INTO triggered select * from generate_series(1,49999)") | ||
return 0 | ||
end | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
DROP TABLE IF EXISTS t; | ||
DROP TABLE IF EXISTS triggered; | ||
CREATE TABLE t(a int primary key)$$ | ||
CREATE TABLE triggered(b int)$$ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
CREATE LUA TRIGGER dormant on (TABLE t for INSERT); |