Merge pull request #27213 from taosdata/fix/xftan/TD-31438
fix: check transactions and reset query cache before running the example
This commit is contained in:
commit
37e820c865
|
@ -2,6 +2,32 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
check_transactions() {
|
||||||
|
for i in {1..30}
|
||||||
|
do
|
||||||
|
output=$(taos -s "show transactions;")
|
||||||
|
if [[ $output == *"Query OK, 0 row(s)"* ]]; then
|
||||||
|
echo "Success: No transactions are in progress."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
sleep 1
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "Error: Transactions are still in progress after 30 attempts."
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
reset_cache() {
|
||||||
|
response=$(curl --location -uroot:taosdata 'http://127.0.0.1:6041/rest/sql' --data 'reset query cache')
|
||||||
|
|
||||||
|
if [[ $response == \{\"code\":0* ]]; then
|
||||||
|
echo "Success: Query cache reset successfully."
|
||||||
|
else
|
||||||
|
echo "Error: Failed to reset query cache. Response: $response"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
pgrep taosd || taosd >> /dev/null 2>&1 &
|
pgrep taosd || taosd >> /dev/null 2>&1 &
|
||||||
pgrep taosadapter || taosadapter >> /dev/null 2>&1 &
|
pgrep taosadapter || taosadapter >> /dev/null 2>&1 &
|
||||||
cd ../../docs/examples/csharp
|
cd ../../docs/examples/csharp
|
||||||
|
@ -10,56 +36,69 @@ dotnet run --project connect/connect.csproj
|
||||||
dotnet run --project wsConnect/wsConnect.csproj
|
dotnet run --project wsConnect/wsConnect.csproj
|
||||||
|
|
||||||
taos -s "drop database if exists test"
|
taos -s "drop database if exists test"
|
||||||
sleep 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
dotnet run --project influxdbLine/influxdbline.csproj
|
dotnet run --project influxdbLine/influxdbline.csproj
|
||||||
|
|
||||||
taos -s "drop database if exists test"
|
taos -s "drop database if exists test"
|
||||||
sleep 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
dotnet run --project optsTelnet/optstelnet.csproj
|
dotnet run --project optsTelnet/optstelnet.csproj
|
||||||
|
|
||||||
taos -s "drop database if exists test"
|
taos -s "drop database if exists test"
|
||||||
sleep 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
dotnet run --project optsJSON/optsJSON.csproj
|
dotnet run --project optsJSON/optsJSON.csproj
|
||||||
|
|
||||||
# query
|
# query
|
||||||
taos -s "drop database if exists power"
|
taos -s "drop database if exists power"
|
||||||
sleep 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
dotnet run --project wsInsert/wsInsert.csproj
|
dotnet run --project wsInsert/wsInsert.csproj
|
||||||
dotnet run --project wsQuery/wsQuery.csproj
|
dotnet run --project wsQuery/wsQuery.csproj
|
||||||
|
|
||||||
taos -s "drop database if exists power"
|
taos -s "drop database if exists power"
|
||||||
sleep 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
dotnet run --project sqlInsert/sqlinsert.csproj
|
dotnet run --project sqlInsert/sqlinsert.csproj
|
||||||
dotnet run --project query/query.csproj
|
dotnet run --project query/query.csproj
|
||||||
|
|
||||||
|
|
||||||
# stmt
|
# stmt
|
||||||
taos -s "drop database if exists power"
|
taos -s "drop database if exists power"
|
||||||
sleep 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
dotnet run --project wsStmt/wsStmt.csproj
|
dotnet run --project wsStmt/wsStmt.csproj
|
||||||
|
|
||||||
taos -s "drop database if exists power"
|
taos -s "drop database if exists power"
|
||||||
sleep 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
dotnet run --project stmtInsert/stmtinsert.csproj
|
dotnet run --project stmtInsert/stmtinsert.csproj
|
||||||
|
|
||||||
# schemaless
|
# schemaless
|
||||||
taos -s "drop database if exists power"
|
taos -s "drop database if exists power"
|
||||||
sleep 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
dotnet run --project wssml/wssml.csproj
|
dotnet run --project wssml/wssml.csproj
|
||||||
|
|
||||||
taos -s "drop database if exists power"
|
taos -s "drop database if exists power"
|
||||||
sleep 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
dotnet run --project nativesml/nativesml.csproj
|
dotnet run --project nativesml/nativesml.csproj
|
||||||
|
|
||||||
# subscribe
|
# subscribe
|
||||||
taos -s "drop topic if exists topic_meters"
|
taos -s "drop topic if exists topic_meters"
|
||||||
sleep 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
taos -s "drop database if exists power"
|
taos -s "drop database if exists power"
|
||||||
sleep 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
dotnet run --project wssubscribe/wssubscribe.csproj
|
dotnet run --project wssubscribe/wssubscribe.csproj
|
||||||
|
|
||||||
taos -s "drop topic if exists topic_meters"
|
taos -s "drop topic if exists topic_meters"
|
||||||
sleep 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
taos -s "drop database if exists power"
|
taos -s "drop database if exists power"
|
||||||
sleep 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
dotnet run --project subscribe/subscribe.csproj
|
dotnet run --project subscribe/subscribe.csproj
|
||||||
|
|
|
@ -17,6 +17,17 @@ check_transactions() {
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reset_cache() {
|
||||||
|
response=$(curl --location -uroot:taosdata 'http://127.0.0.1:6041/rest/sql' --data 'reset query cache')
|
||||||
|
|
||||||
|
if [[ $response == \{\"code\":0* ]]; then
|
||||||
|
echo "Success: Query cache reset successfully."
|
||||||
|
else
|
||||||
|
echo "Error: Failed to reset query cache. Response: $response"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
taosd >>/dev/null 2>&1 &
|
taosd >>/dev/null 2>&1 &
|
||||||
taosadapter >>/dev/null 2>&1 &
|
taosadapter >>/dev/null 2>&1 &
|
||||||
sleep 1
|
sleep 1
|
||||||
|
@ -31,64 +42,83 @@ go run ./connect/connpool/main.go
|
||||||
go run ./connect/wsexample/main.go
|
go run ./connect/wsexample/main.go
|
||||||
|
|
||||||
taos -s "drop database if exists power"
|
taos -s "drop database if exists power"
|
||||||
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
go run ./sqlquery/main.go
|
go run ./sqlquery/main.go
|
||||||
|
|
||||||
taos -s "drop database if exists power"
|
taos -s "drop database if exists power"
|
||||||
check_transactions || exit 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
go run ./queryreqid/main.go
|
go run ./queryreqid/main.go
|
||||||
|
|
||||||
taos -s "drop database if exists power"
|
taos -s "drop database if exists power"
|
||||||
check_transactions || exit 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
go run ./stmt/native/main.go
|
go run ./stmt/native/main.go
|
||||||
|
|
||||||
taos -s "drop database if exists power"
|
taos -s "drop database if exists power"
|
||||||
check_transactions || exit 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
go run ./stmt/ws/main.go
|
go run ./stmt/ws/main.go
|
||||||
|
|
||||||
taos -s "drop database if exists power"
|
taos -s "drop database if exists power"
|
||||||
check_transactions || exit 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
sleep 3
|
sleep 3
|
||||||
go run ./schemaless/native/main.go
|
go run ./schemaless/native/main.go
|
||||||
|
|
||||||
taos -s "drop database if exists power"
|
taos -s "drop database if exists power"
|
||||||
check_transactions || exit 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
go run ./schemaless/ws/main.go
|
go run ./schemaless/ws/main.go
|
||||||
|
|
||||||
taos -s "drop topic if exists topic_meters"
|
taos -s "drop topic if exists topic_meters"
|
||||||
check_transactions || exit 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
taos -s "drop database if exists power"
|
taos -s "drop database if exists power"
|
||||||
check_transactions || exit 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
go run ./tmq/native/main.go
|
go run ./tmq/native/main.go
|
||||||
|
|
||||||
taos -s "drop topic if exists topic_meters"
|
taos -s "drop topic if exists topic_meters"
|
||||||
check_transactions || exit 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
taos -s "drop database if exists power"
|
taos -s "drop database if exists power"
|
||||||
check_transactions || exit 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
go run ./tmq/ws/main.go
|
go run ./tmq/ws/main.go
|
||||||
|
|
||||||
|
|
||||||
taos -s "drop database if exists test"
|
taos -s "drop database if exists test"
|
||||||
check_transactions || exit 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
go run ./insert/json/main.go
|
go run ./insert/json/main.go
|
||||||
taos -s "drop database if exists test"
|
taos -s "drop database if exists test"
|
||||||
check_transactions || exit 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
go run ./insert/line/main.go
|
go run ./insert/line/main.go
|
||||||
taos -s "drop topic if exists topic_meters"
|
taos -s "drop topic if exists topic_meters"
|
||||||
check_transactions || exit 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
taos -s "drop database if exists power"
|
taos -s "drop database if exists power"
|
||||||
check_transactions || exit 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
go run ./insert/sql/main.go
|
go run ./insert/sql/main.go
|
||||||
taos -s "drop database if exists power"
|
taos -s "drop database if exists power"
|
||||||
check_transactions || exit 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
go run ./insert/stmt/main.go
|
go run ./insert/stmt/main.go
|
||||||
taos -s "drop database if exists test"
|
taos -s "drop database if exists test"
|
||||||
check_transactions || exit 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
go run ./insert/telnet/main.go
|
go run ./insert/telnet/main.go
|
||||||
|
|
||||||
go run ./query/sync/main.go
|
go run ./query/sync/main.go
|
||||||
|
|
||||||
taos -s "drop topic if exists example_tmq_topic"
|
taos -s "drop topic if exists example_tmq_topic"
|
||||||
check_transactions || exit 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
taos -s "drop database if exists example_tmq"
|
taos -s "drop database if exists example_tmq"
|
||||||
check_transactions || exit 1
|
check_transactions || exit 1
|
||||||
|
reset_cache || exit 1
|
||||||
go run ./sub/main.go
|
go run ./sub/main.go
|
||||||
|
|
Loading…
Reference in New Issue