diff --git a/packaging/deb/nginxd b/packaging/deb/nginxd new file mode 100644 index 0000000000000000000000000000000000000000..bdc50fb0464df504977249182857f06c2ec2ccbf --- /dev/null +++ b/packaging/deb/nginxd @@ -0,0 +1,46 @@ +#!/bin/bash +#Startup script for the nginx Web Server +# chkconfig: 2345 99 01 +# description: Nginx For TDengine Service. +# +# +### BEGIN INIT INFO +# Provides: nginx +# Required-Start: $local_fs $network $syslog +# Required-Stop: $local_fs $network $syslog +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Starts nginx +# Description: Starts nginx. +### END INIT INFO + +nginx=/usr/local/nginxd/sbin/nginx +case $1 in + start) + echo -n "Starting Nginx" + $nginx + echo " done." + ;; + stop) + echo -n "Stopping Nginx" + $nginx -s stop + echo " done." + ;; + test) + $nginx -t + echo "Success." + ;; + reload) + echo -n "Reloading Nginx" + $nginx -s reload + echo " done." + ;; + restart) + $nginx -s reload + echo "reload done." + ;; + *) + echo "Usage: $0 {start|restart|reload|stop|test|show}" + ;; +esac + diff --git a/packaging/rpm/nginxd b/packaging/rpm/nginxd new file mode 100644 index 0000000000000000000000000000000000000000..fc6593992b297f7fcad03d04051a030dc1898d5e --- /dev/null +++ b/packaging/rpm/nginxd @@ -0,0 +1,44 @@ +#!/bin/bash +#Startup script for the nginx Web Server +# chkconfig: 2345 99 01 +# +# +### BEGIN INIT INFO +# Provides: nginx +# Provides: nginx +# Required-Start: $local_fs $network $syslog +# Required-Stop: $local_fs $network $syslog +# Short-Description: Starts nginx +# Description: Starts nginx. +### END INIT INFO + +nginx=/usr/local/nginxd/sbin/nginx +case $1 in + start) + echo -n "Starting Nginx" + $nginx + echo " done." + ;; + stop) + echo -n "Stopping Nginx" + $nginx -s stop + echo " done." + ;; + test) + $nginx -t + echo "Success." + ;; + reload) + echo -n "Reloading Nginx" + $nginx -s reload + echo " done." + ;; + restart) + $nginx -s reload + echo "reload done." + ;; + *) + echo "Usage: $0 {start|restart|reload|stop|test|show}" + ;; +esac + diff --git a/packaging/tools/install.sh b/packaging/tools/install.sh index 0d7a7dd9442fd635fce56792dc37c3276d1b955d..3930433b96166c8beb0bddca17aa73ab11c0ebc5 100755 --- a/packaging/tools/install.sh +++ b/packaging/tools/install.sh @@ -582,6 +582,26 @@ function clean_service_on_sysvinit() { ${csudo} rm -f ${service_config_dir}/taosd || : ${csudo} rm -f ${service_config_dir}/tarbitratord || : + if [ "$verMode" == "cluster" ]; then\ + if pidof nginxd ; then + ${csudo} service nginxd stop || : + fi + if ((${initd_mod}==1)); then + if [ -e ${service_config_dir}/nginxd ]; then + ${csudo} chkconfig --del nginxd || : + fi + elif ((${initd_mod}==2)); then + if [ -e ${service_config_dir}/nginxd ]; then + ${csudo} insserv -r nginxd || : + fi + elif ((${initd_mod}==3)); then + if [ -e ${service_config_dir}/nginxd ]; then + ${csudo} update-rc.d -f nginxd remove || : + fi + fi + ${csudo} rm -f ${service_config_dir}/nginxd || : + fi + if $(which init &> /dev/null); then ${csudo} init q || : fi @@ -598,11 +618,19 @@ function install_service_on_sysvinit() { ${csudo} cp ${script_dir}/init.d/taosd.deb ${service_config_dir}/taosd && ${csudo} chmod a+x ${service_config_dir}/taosd ${csudo} cp -f ${script_dir}/init.d/tarbitratord.deb ${install_main_dir}/init.d/tarbitratord ${csudo} cp ${script_dir}/init.d/tarbitratord.deb ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + if [ "$verMode" == "cluster" ]; then + ${csudo} cp -f ${script_dir}/init.d/nginxd.deb ${install_main_dir}/init.d/nginxd + ${csudo} cp ${script_dir}/init.d/nginxd.deb ${service_config_dir}/nginxd && ${csudo} chmod a+x ${service_config_dir}/nginxd + fi elif ((${os_type}==2)); then ${csudo} cp -f ${script_dir}/init.d/taosd.rpm ${install_main_dir}/init.d/taosd ${csudo} cp ${script_dir}/init.d/taosd.rpm ${service_config_dir}/taosd && ${csudo} chmod a+x ${service_config_dir}/taosd ${csudo} cp -f ${script_dir}/init.d/tarbitratord.rpm ${install_main_dir}/init.d/tarbitratord ${csudo} cp ${script_dir}/init.d/tarbitratord.rpm ${service_config_dir}/tarbitratord && ${csudo} chmod a+x ${service_config_dir}/tarbitratord + if [ "$verMode" == "cluster" ]; then + ${csudo} cp -f ${script_dir}/init.d/nginxd.rpm ${install_main_dir}/init.d/nginxd + ${csudo} cp ${script_dir}/init.d/nginxd.rpm ${service_config_dir}/nginxd && ${csudo} chmod a+x ${service_config_dir}/nginxd + fi fi #restart_config_str="taos:2345:respawn:${service_config_dir}/taosd start" @@ -613,14 +641,26 @@ function install_service_on_sysvinit() { ${csudo} chkconfig --level 2345 taosd on || : ${csudo} chkconfig --add tarbitratord || : ${csudo} chkconfig --level 2345 tarbitratord on || : + if [ "$verMode" == "cluster" ]; then + ${csudo} chkconfig --add nginxd || : + ${csudo} chkconfig --level 0123456 nginxd on || : + ${csudo} service nginxd start + fi elif ((${initd_mod}==2)); then ${csudo} insserv taosd || : ${csudo} insserv -d taosd || : ${csudo} insserv tarbitratord || : ${csudo} insserv -d tarbitratord || : + if [ "$verMode" == "cluster" ]; then + ${csudo} insserv nginxd || : + ${csudo} insserv -d nginxd || : + fi elif ((${initd_mod}==3)); then ${csudo} update-rc.d taosd defaults || : ${csudo} update-rc.d tarbitratord defaults || : + if [ "$verMode" == "cluster" ]; then + ${csudo} update-rc.d nginxd defaults || : + fi fi } @@ -779,7 +819,7 @@ vercomp () { function is_version_compatible() { - curr_version=`ls ${script_dir}/driver/libtaos.so* |cut -d '.' -f 3-6` + curr_version=`ls ${script_dir}/driver/libtaos.so* | awk -F 'libtaos.so.' '{print $2}'` if [ -f ${script_dir}/driver/vercomp.txt ]; then min_compatible_version=`cat ${script_dir}/driver/vercomp.txt` diff --git a/packaging/tools/makepkg.sh b/packaging/tools/makepkg.sh index 39918325992ba140db6db656c6946ec40dd84435..1b11973e3c232f3b00cd0f1d1db8c903e8046da6 100755 --- a/packaging/tools/makepkg.sh +++ b/packaging/tools/makepkg.sh @@ -63,6 +63,8 @@ init_file_deb=${script_dir}/../deb/taosd init_file_rpm=${script_dir}/../rpm/taosd init_file_tarbitrator_deb=${script_dir}/../deb/tarbitratord init_file_tarbitrator_rpm=${script_dir}/../rpm/tarbitratord +init_file_nginx_deb=${script_dir}/../deb/nginxd +init_file_nginx_rpm=${script_dir}/../rpm/nginxd # make directories. mkdir -p ${install_dir} @@ -73,6 +75,8 @@ mkdir -p ${install_dir}/init.d && cp ${init_file_deb} ${install_dir}/init.d/taos mkdir -p ${install_dir}/init.d && cp ${init_file_rpm} ${install_dir}/init.d/taosd.rpm mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_deb} ${install_dir}/init.d/tarbitratord.deb || : mkdir -p ${install_dir}/init.d && cp ${init_file_tarbitrator_rpm} ${install_dir}/init.d/tarbitratord.rpm || : +mkdir -p ${install_dir}/init.d && cp ${init_file_nginx_deb} ${install_dir}/init.d/nginxd.deb || : +mkdir -p ${install_dir}/init.d && cp ${init_file_nginx_rpm} ${install_dir}/init.d/nginxd.rpm || : if [ -f ${build_dir}/bin/jemalloc-config ]; then mkdir -p ${install_dir}/jemalloc/{bin,lib,lib/pkgconfig,include/jemalloc,share/doc/jemalloc,share/man/man3} diff --git a/src/client/src/tscServer.c b/src/client/src/tscServer.c index 4d4667e135d04b28a3b94952f1c165b5dd16a784..5fbe756b3bd63b0b22bda703ff5b02d4daf82052 100644 --- a/src/client/src/tscServer.c +++ b/src/client/src/tscServer.c @@ -3142,15 +3142,19 @@ int tscRenewTableMeta(SSqlObj *pSql, int32_t tableIndex) { SSqlCmd* pCmd2 = &pSql->rootObj->cmd; pCmd2->pTableMetaMap = tscCleanupTableMetaMap(pCmd2->pTableMetaMap); pCmd2->pTableMetaMap = taosHashInit(4, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BINARY), false, HASH_NO_LOCK); - + pSql->rootObj->retryReason = pSql->retryReason; + SSqlObj *tmpSql = pSql->rootObj; + tscFreeSubobj(pSql->rootObj); + tfree(tmpSql->pSubs); + SArray* pNameList = taosArrayInit(1, POINTER_BYTES); SArray* vgroupList = taosArrayInit(1, POINTER_BYTES); char* n = strdup(name); taosArrayPush(pNameList, &n); - code = getMultiTableMetaFromMnode(pSql, pNameList, vgroupList, NULL, tscTableMetaCallBack, true); + code = getMultiTableMetaFromMnode(tmpSql, pNameList, vgroupList, NULL, tscTableMetaCallBack, true); taosArrayDestroyEx(pNameList, freeElem); taosArrayDestroyEx(vgroupList, freeElem); diff --git a/tests/script/unique/dnode/alternativeRole.sim b/tests/script/unique/dnode/alternativeRole.sim index 955b757f06df22c884565d0fac350456e79cb73a..7e647925d1d3d66d21f279ace852e3fc12496510 100644 --- a/tests/script/unique/dnode/alternativeRole.sim +++ b/tests/script/unique/dnode/alternativeRole.sim @@ -32,33 +32,48 @@ sql create dnode $hostname3 system sh/exec.sh -n dnode3 -s start sleep 3000 +$x = 0 +show1: + $x = $x + 1 + sleep 1000 + if $x == 30 then + return -1 + endi + sql show dnodes print dnode1 $data5_1 -print dnode1 $data5_2 -print dnode1 $data5_3 +print dnode2 $data5_2 +print dnode3 $data5_3 if $data5_1 != mnode then - return -1 + goto show1 endi if $data5_2 != vnode then - return -1 + goto show1 endi if $data5_3 != any then - return -1 + goto show1 endi +show2: + $x = $x + 1 + sleep 1000 + if $x == 30 then + return -1 + endi + sql show mnodes print dnode1 ==> $data2_1 print dnode2 ==> $data2_2 print dnode3 ==> $data2_3 if $data2_1 != master then - return -1 + goto show2 endi if $data2_2 != null then - return -1 + goto show2 endi if $data2_3 != slave then - return -1 + goto show2 endi print ========== step2 @@ -72,26 +87,28 @@ sql create table d1.t6 (ts timestamp, i int) sql create table d1.t7 (ts timestamp, i int) sql create table d1.t8 (ts timestamp, i int) +show3: + $x = $x + 1 + sleep 1000 + if $x == 30 then + return -1 + endi + sql show dnodes print dnode1 $data2_1 print dnode2 $data2_2 print dnode3 $data2_3 if $data2_1 != 0 then - return -1 + goto show3 endi if $data2_2 != 1 then - return -1 + goto show3 endi if $data2_3 != 1 then - return -1 + goto show3 endi system sh/exec.sh -n dnode1 -s stop -x SIGINT system sh/exec.sh -n dnode2 -s stop -x SIGINT -system sh/exec.sh -n dnode3 -s stop -x SIGINT -system sh/exec.sh -n dnode4 -s stop -x SIGINT -system sh/exec.sh -n dnode5 -s stop -x SIGINT -system sh/exec.sh -n dnode6 -s stop -x SIGINT -system sh/exec.sh -n dnode7 -s stop -x SIGINT -system sh/exec.sh -n dnode8 -s stop -x SIGINT \ No newline at end of file +system sh/exec.sh -n dnode3 -s stop -x SIGINT \ No newline at end of file