-
Notifications
You must be signed in to change notification settings - Fork 5k
Fix/driver pass change #35254
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Fix/driver pass change #35254
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -197,6 +197,7 @@ TAOS_DEFINE_ERROR(TSDB_CODE_NOT_SUPPORTTED_IN_WINDOWS, "Operation not support | |||||
| TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_TOTP_CODE, "Invalid TOTP code") | ||||||
| TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INVALID_TOKEN, "Invalid token") | ||||||
| TAOS_DEFINE_ERROR(TSDB_CODE_TSC_INSTANCE_API_RATE_LIMIT, "instance register/list API rate limit exceeded") | ||||||
| TAOS_DEFINE_ERROR(TSDB_CODE_TSC_PASS_CHANGED, "Password has been changed from another session, please reconnect") | ||||||
|
||||||
| TAOS_DEFINE_ERROR(TSDB_CODE_TSC_PASS_CHANGED, "Password has been changed from another session, please reconnect") | |
| TAOS_DEFINE_ERROR(TSDB_CODE_TSC_PASS_CHANGED, "Password has been changed, please reconnect") |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -434,7 +434,33 @@ def do_user_manage(self): | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # self.subscribe_topic() # PRIV_TODO: topic | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| print("do user manager ............. [passed]") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # ------------------- test_pass_change_detect ---------------- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| def do_pass_change_detect(self): | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tdLog.info("=============== test: password change detection") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.execute("CREATE USER upasschk PASS 'AAbb1122'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| conn = taos.connect(user='upasschk', password='AAbb1122') | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cursor = conn.cursor() | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cursor.execute("SELECT SERVER_VERSION()") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tdLog.info("conn1 query before pass change: success") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tdSql.execute("ALTER USER upasschk PASS 'CCdd3344!!'") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tdLog.info("password changed via root conn, waiting for heartbeat...") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| time.sleep(5) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| cursor.execute("SELECT SERVER_VERSION()") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tdLog.exit("query should have failed after password change but succeeded") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| except Exception as e: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tdLog.info(f"query after pass change failed as expected: {e}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+450
to
+457
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| tdLog.info("password changed via root conn, waiting for heartbeat...") | |
| time.sleep(5) | |
| try: | |
| cursor.execute("SELECT SERVER_VERSION()") | |
| tdLog.exit("query should have failed after password change but succeeded") | |
| except Exception as e: | |
| tdLog.info(f"query after pass change failed as expected: {e}") | |
| tdLog.info("password changed via root conn, waiting for old connection to be rejected...") | |
| deadline = time.monotonic() + 5 | |
| last_error = None | |
| while time.monotonic() < deadline: | |
| try: | |
| cursor.execute("SELECT SERVER_VERSION()") | |
| except Exception as e: | |
| last_error = e | |
| break | |
| time.sleep(0.1) | |
| if last_error is None: | |
| tdLog.exit("query should have failed after password change but succeeded") | |
| else: | |
| tdLog.info(f"query after pass change failed as expected: {last_error}") |
Copilot
AI
Apr 29, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test creates a user/connection and only drops/closes them on the success path. If any assertion/exception occurs before the end, the user may be left behind and impact subsequent test runs. Wrap the body in try/finally (and/or drop the user defensively) to guarantee cursor/conn close and user cleanup.
| tdSql.execute("CREATE USER upasschk PASS 'AAbb1122'") | |
| conn = taos.connect(user='upasschk', password='AAbb1122') | |
| cursor = conn.cursor() | |
| cursor.execute("SELECT SERVER_VERSION()") | |
| tdLog.info("conn1 query before pass change: success") | |
| tdSql.execute("ALTER USER upasschk PASS 'CCdd3344!!'") | |
| tdLog.info("password changed via root conn, waiting for heartbeat...") | |
| time.sleep(5) | |
| try: | |
| cursor.execute("SELECT SERVER_VERSION()") | |
| tdLog.exit("query should have failed after password change but succeeded") | |
| except Exception as e: | |
| tdLog.info(f"query after pass change failed as expected: {e}") | |
| cursor.close() | |
| conn.close() | |
| tdSql.execute("DROP USER upasschk") | |
| print("do pass change detect ............. [passed]") | |
| conn = None | |
| cursor = None | |
| tdSql.execute("CREATE USER upasschk PASS 'AAbb1122'") | |
| try: | |
| conn = taos.connect(user='upasschk', password='AAbb1122') | |
| cursor = conn.cursor() | |
| cursor.execute("SELECT SERVER_VERSION()") | |
| tdLog.info("conn1 query before pass change: success") | |
| tdSql.execute("ALTER USER upasschk PASS 'CCdd3344!!'") | |
| tdLog.info("password changed via root conn, waiting for heartbeat...") | |
| time.sleep(5) | |
| try: | |
| cursor.execute("SELECT SERVER_VERSION()") | |
| tdLog.exit("query should have failed after password change but succeeded") | |
| except Exception as e: | |
| tdLog.info(f"query after pass change failed as expected: {e}") | |
| print("do pass change detect ............. [passed]") | |
| finally: | |
| if cursor is not None: | |
| cursor.close() | |
| if conn is not None: | |
| conn.close() | |
| try: | |
| tdSql.execute("DROP USER upasschk") | |
| except Exception as e: | |
| tdLog.info(f"cleanup drop user upasschk failed: {e}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
pRsppointer used here is declared outside thewhileloop (at line 131) and is not reset for each connection iteration. This creates a significant bug in multi-user scenarios: if a heartbeat response contains updates for multiple users, a connection for one user will incorrectly reuse thepRspdata from a previous user's connection processed in the same loop. This will lead to incorrect password change detection, session metric updates, and other auth-related logic for all subsequent connections in the loop. Although the declaration is outside this diff hunk, the new logic added here is directly affected by this issue.