Skip to content

refactor(timezone): standardize checkTime initialization to local timezone offset across dnode and mnode#35057

Open
Tony2h wants to merge 4 commits intomainfrom
fix/main/tz
Open

refactor(timezone): standardize checkTime initialization to local timezone offset across dnode and mnode#35057
Tony2h wants to merge 4 commits intomainfrom
fix/main/tz

Conversation

@Tony2h
Copy link
Copy Markdown
Member

@Tony2h Tony2h commented Apr 3, 2026

… ms across dnode and mnode implementations

Description

Issue(s)

  • Close/close/Fix/fix/Resolve/resolve: Issue Link

Checklist

Please check the items in the checklist if applicable.

  • Is the user manual updated?
  • Are the test cases passed and automated?
  • Is there no significant decrease in test coverage?

Copilot AI review requested due to automatic review settings April 3, 2026 07:34
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors how checkTime is initialized in both mnode and dnode status/cluster-config paths, aiming to standardize the value (now set to 0) and updates inline documentation for the field.

Changes:

  • Replace taosParseTime("1970-01-01 00:00:00.00", ...) with direct checkTime = 0 initialization in mnode open logic and dnode status request population.
  • Add/replace struct field comments describing checkTime semantics in internal mnode state and the cluster config message struct.
  • Minor cleanup from removing parsing/error-handling blocks (but introduces a duplicate assignment site in dmSendStatusReq).

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
source/dnode/mnode/impl/src/mndMain.c Sets pMnode->checkTime directly to 0 during mndOpen() initialization.
source/dnode/mnode/impl/inc/mndInt.h Adds a block comment documenting SMnode::checkTime.
source/dnode/mgmt/mgmt_dnode/src/dmHandle.c Sets req.clusterCfg.checkTime = 0 when building status request (now twice in the function).
include/common/tmsg.h Updates SClusterCfg::checkTime comment to a block comment and removes the old “1970...” note.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

terrno = code;
return NULL;
}
pMnode->checkTime = 0;
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting pMnode->checkTime to 0 makes the timezone consistency check in mndCheckClusterCfgPara ineffective: the check only errors when both timezone strings differ and checkTime differs. With both sides now using 0, a real timezone mismatch will not be detected. Consider keeping checkTime as a deterministic value derived from the node’s configured timezone (e.g., parse a fixed local datetime using the global/default timezone or store an explicit tz offset) or update the check logic accordingly.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

0) {
dError("failed to parse time since %s", tstrerror(code));
}
req.clusterCfg.checkTime = 0;
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

req.clusterCfg.checkTime is assigned twice in this function (earlier and again here). The second assignment is redundant and can mask future edits (e.g., if the first assignment is later changed to a computed value). Keep a single initialization for checkTime in one place.

Suggested change
req.clusterCfg.checkTime = 0;

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines 287 to 288
req.clusterCfg.checkTime = 0;
memcpy(req.clusterCfg.timezone, tsTimezoneStr, TD_TIMEZONE_LEN);
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing checkTime to a constant 0 disables the intended semantic comparison used by mnode when validating dnode timezone (it checks timezone string mismatch but allows equivalent timezones when the derived checkTime matches). If the goal is to avoid environment-dependent parsing, compute a stable value that still reflects the configured timezone (e.g., derived offset) or adjust the validation logic to continue catching genuine mismatches.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines +2714 to +2715
Unix epoch in ms (conventionally 0).
Dnode/mnode must agree; paired with timezone in cluster cfg check.
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new comment describes checkTime as “Unix epoch in ms (conventionally 0)”, but current usage in mndCheckClusterCfgPara treats checkTime as a derived value to help validate timezone equivalence. Please update this comment to reflect the actual purpose/meaning of checkTime (or, if semantics are intentionally changing to constant 0, update the validation logic and any other documentation accordingly).

Suggested change
Unix epoch in ms (conventionally 0).
Dnode/mnode must agree; paired with timezone in cluster cfg check.
Reference timestamp in ms used together with timezone during cluster
configuration checks to verify timezone equivalence across dnode/mnode.
This is a derived comparison value, not a field that is conventionally 0.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已补全

Comment on lines +130 to +131
Unix epoch in ms (conventionally 0).
Dnode/mnode must agree; paired with timezone in cluster cfg check.
Copy link

Copilot AI Apr 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment implies checkTime is always the Unix epoch (0), but the field is used in cluster cfg validation to disambiguate timezone equivalence. Please align this comment with the field’s real semantics (or change the validation logic if checkTime is meant to be constant).

Suggested change
Unix epoch in ms (conventionally 0).
Dnode/mnode must agree; paired with timezone in cluster cfg check.
Reference timestamp in ms used together with timezone during
cluster cfg validation to disambiguate timezone equivalence.
Dnode/mnode must agree on this value.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已补全

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request simplifies the initialization of checkTime by replacing the parsing of a hardcoded date string with a direct assignment of 0, representing the Unix epoch. It also adds descriptive comments to the checkTime field in several header files to clarify its purpose and synchronization requirements. Feedback suggests using a named constant instead of the literal 0 to enhance code readability and maintainability.

0) {
dError("failed to parse time since %s", tstrerror(code));
}
req.clusterCfg.checkTime = 0;

This comment was marked as duplicate.

terrno = code;
return NULL;
}
pMnode->checkTime = 0;

This comment was marked as duplicate.

Copilot AI review requested due to automatic review settings April 7, 2026 02:40
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +884 to 889
pMnode->checkTime = (int64_t)taosGetLocalTimezoneOffset(&code);
if (code != 0) {
taosMemoryFree(pMnode);
mError("failed to get local timezone offset, since %s", tstrerror(code));
terrno = code;
return NULL;
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On failure, this path frees pMnode without destroying the rwlock initialized just above. The previous code called taosThreadRwlockDestroy(&pMnode->lock) on error; the new code should do the same before freeing to avoid leaking OS lock resources.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

Comment on lines +2713 to 2721
/*
Local timezone UTC offset in seconds (east-positive, e.g. +28800 for
Asia/Shanghai). Derived from taosGetLocalTimezoneOffset() on each
status report. Paired with the timezone string in
mndCheckClusterCfgPara: a mismatch is reported only when both the
timezone string AND this offset differ.
*/
int64_t checkTime;
char timezone[TD_TIMEZONE_LEN]; // tsTimezone
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR title/description says checkTime is standardized to initialization "0", but the code now sets it to the local timezone UTC offset (seconds) via taosGetLocalTimezoneOffset(). Please update the PR title/description (or rename the field) so reviewers/users aren’t misled about the semantics change.

Copilot uses AI. Check for mistakes.
@Tony2h Tony2h changed the title refactor(timezone): standardize checkTime initialization to 0 across dnode and mnode implementations refactor(timezone): standardize checkTime initialization to local timezone offset across dnode and mnode Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants