Merge remote-tracking branch 'origin/3.0' into HEAD

This commit is contained in:
Pengrongkun 2024-12-16 16:14:53 +08:00
commit 7037caa7cb
160 changed files with 8751 additions and 2758 deletions

View File

@ -28,71 +28,70 @@ After modifying configuration file parameters, you need to restart the *taosd* s
### Connection Related
|Parameter Name |Supported Version |Description|
|-----------------------|-------------------------|------------|
|firstEp | |Endpoint of the first dnode in the cluster that taosd actively connects to at startup, default value localhost:6030|
|secondEp | |Endpoint of the second dnode in the cluster that taosd tries to connect to if the firstEp is unreachable, no default value|
|fqdn | |The service address that taosd listens on, default is the first hostname configured on the server|
|serverPort | |The port that taosd listens on, default value 6030|
|compressMsgSize | |Whether to compress RPC messages; -1: do not compress any messages; 0: compress all messages; N (N>0): only compress messages larger than N bytes; default value -1|
|shellActivityTimer | |Duration in seconds for the client to send heartbeat to mnode, range 1-120, default value 3 |
|numOfRpcSessions | |Maximum number of connections supported by RPC, range 100-100000, default value 30000|
|numOfRpcThreads | |Number of threads for receiving and sending RPC data, range 1-50, default value is half of the CPU cores|
|numOfTaskQueueThreads | |Number of threads for client to process RPC messages, range 4-16, default value is half of the CPU cores|
|rpcQueueMemoryAllowed | |Maximum memory allowed for received RPC messages in dnode, in bytes, range 104857600-INT64_MAX, default value is 1/10 of server memory |
|resolveFQDNRetryTime | Cancelled after 3.x |Number of retries when FQDN resolution fails|
|Parameter Name |Supported Version |Dynamic Modification|Description|
|-----------------------|-------------------------|--------------------|------------|
|firstEp | |Not supported |Endpoint of the first dnode in the cluster that taosd actively connects to at startup, default value localhost:6030|
|secondEp | |Not supported |Endpoint of the second dnode in the cluster that taosd tries to connect to if the firstEp is unreachable, no default value|
|fqdn | |Not supported |The service address that taosd listens on, default is the first hostname configured on the server|
|serverPort | |Not supported |The port that taosd listens on, default value 6030|
|compressMsgSize | |Supported, effective after restart|Whether to compress RPC messages; -1: do not compress any messages; 0: compress all messages; N (N>0): only compress messages larger than N bytes; default value -1|
|shellActivityTimer | |Supported, effective immediately |Duration in seconds for the client to send heartbeat to mnode, range 1-120, default value 3 |
|numOfRpcSessions | |Supported, effective after restart|Maximum number of connections supported by RPC, range 100-100000, default value 30000|
|numOfRpcThreads | |Supported, effective after restart|Number of threads for receiving and sending RPC data, range 1-50, default value is half of the CPU cores|
|numOfTaskQueueThreads | |Supported, effective after restart|Number of threads for client to process RPC messages, range 4-16, default value is half of the CPU cores|
|rpcQueueMemoryAllowed | |Supported, effective immediately |Maximum memory allowed for received RPC messages in dnode, in bytes, range 104857600-INT64_MAX, default value is 1/10 of server memory |
|resolveFQDNRetryTime | Cancelled after 3.x |Not supported |Number of retries when FQDN resolution fails|
|timeToGetAvailableConn | Cancelled after 3.3.4.x |Maximum waiting time to get an available connection, range 10-50000000, in milliseconds, default value 500000|
|maxShellConns | Cancelled after 3.x |Maximum number of connections allowed|
|maxRetryWaitTime | |Maximum timeout for reconnection, default value is 10s|
|shareConnLimit |Added in 3.3.4.0 |Number of requests a connection can share, range 1-512, default value 10|
|readTimeout |Added in 3.3.4.0 |Minimum timeout for a single request, range 64-604800, in seconds, default value 900|
|maxShellConns | Cancelled after 3.x |Supported, effective after restart|Maximum number of connections allowed|
|maxRetryWaitTime | |Supported, effective after restart|Maximum timeout for reconnection, default value is 10s|
|shareConnLimit |Added in 3.3.4.0 |Supported, effective after restart|Number of requests a connection can share, range 1-512, default value 10|
|readTimeout |Added in 3.3.4.0 |Supported, effective after restart|Minimum timeout for a single request, range 64-604800, in seconds, default value 900|
### Monitoring Related
|Parameter Name|Supported Version|Description|
|-----------------------|----------|-|
|monitor | |Whether to collect and report monitoring data, 0: off; 1: on; default value 0|
|monitorFqdn | |The FQDN of the server where the taosKeeper service is located, default value none|
|monitorPort | |The port number listened to by the taosKeeper service, default value 6043|
|monitorInterval | |The time interval for recording system parameters (CPU/memory) in the monitoring database, in seconds, range 1-200000, default value 30|
|monitorMaxLogs | |Number of cached logs pending report|
|monitorComp | |Whether to use compression when reporting monitoring logs|
|monitorLogProtocol | |Whether to print monitoring logs|
|monitorForceV2 | |Whether to use V2 protocol for reporting|
|telemetryReporting | |Whether to upload telemetry, 0: do not upload, 1: upload, default value 1|
|telemetryServer | |Telemetry server address|
|telemetryPort | |Telemetry server port number|
|telemetryInterval | |Telemetry upload interval, in seconds, default 43200|
|crashReporting | |Whether to upload crash information; 0: do not upload, 1: upload; default value 1|
|Parameter Name |Supported Version |Dynamic Modification|Description|
|-----------------------|-------------------------|--------------------|------------|
|monitor | |Supported, effective immediately |Whether to collect and report monitoring data, 0: off; 1: on; default value 0|
|monitorFqdn | |Supported, effective after restart|The FQDN of the server where the taosKeeper service is located, default value none|
|monitorPort | |Supported, effective after restart|The port number listened to by the taosKeeper service, default value 6043|
|monitorInterval | |Supported, effective immediately |The time interval for recording system parameters (CPU/memory) in the monitoring database, in seconds, range 1-200000, default value 30|
|monitorMaxLogs | |Supported, effective immediately |Number of cached logs pending report|
|monitorComp | |Supported, effective after restart|Whether to use compression when reporting monitoring logs|
|monitorLogProtocol | |Supported, effective immediately |Whether to print monitoring logs|
|monitorForceV2 | |Supported, effective immediately |Whether to use V2 protocol for reporting|
|telemetryReporting | |Supported, effective immediately |Whether to upload telemetry, 0: do not upload, 1: upload, default value 1|
|telemetryServer | |Not supported |Telemetry server address|
|telemetryPort | |Not supported |Telemetry server port number|
|telemetryInterval | |Supported, effective immediately |Telemetry upload interval, in seconds, default 43200|
|crashReporting | |Supported, effective immediately |Whether to upload crash information; 0: do not upload, 1: upload; default value 1|
### Query Related
|Parameter Name|Supported Version|Description|
|------------------------|----------|-|
|countAlwaysReturnValue | |Whether count/hyperloglog functions return a value when input data is empty or NULL; 0: return empty row, 1: return; default value 1; When this parameter is set to 1, if the query contains an INTERVAL clause or the query uses TSMA, and the corresponding group or window has empty or NULL data, the corresponding group or window will not return a query result; Note that this parameter should be consistent between client and server|
|tagFilterCache | |Whether to cache tag filter results|
|maxNumOfDistinctRes | |Maximum number of distinct results allowed to return, default value 100,000, maximum allowed value 100 million|
|queryBufferSize | |Not effective yet|
|queryRspPolicy | |Query response strategy|
|queryUseMemoryPool | |Whether query will use memory pool to manage memory, default value: 1 (on); 0: off, 1: on|
|minReservedMemorySize | |The minimum reserved system available memory size, all memory except reserved can be used for queries, unit: MB, default reserved size is 20% of system physical memory, value range 1024-1000000000|
|singleQueryMaxMemorySize| |The memory limit that a single query can use on a single node (dnode), exceeding this limit will return an error, unit: MB, default value: 0 (no limit), value range 0-1000000000|
|filterScalarMode | |Force scalar filter mode, 0: off; 1: on, default value 0|
|queryPlannerTrace | |Internal parameter, whether the query plan outputs detailed logs|
|queryNodeChunkSize | |Internal parameter, chunk size of the query plan|
|queryUseNodeAllocator | |Internal parameter, allocation method of the query plan|
|queryMaxConcurrentTables| |Internal parameter, concurrency number of the query plan|
|queryRsmaTolerance | |Internal parameter, tolerance time for determining which level of rsma data to query, in milliseconds|
|enableQueryHb | |Internal parameter, whether to send query heartbeat messages|
|pqSortMemThreshold | |Internal parameter, memory threshold for sorting|
|Parameter Name |Supported Version |Dynamic Modification|Description|
|-----------------------|-------------------------|--------------------|------------|
|countAlwaysReturnValue | |Supported, effective immediately |Whether count/hyperloglog functions return a value when input data is empty or NULL; 0: return empty row, 1: return; default value 1; When this parameter is set to 1, if the query contains an INTERVAL clause or the query uses TSMA, and the corresponding group or window has empty or NULL data, the corresponding group or window will not return a query result; Note that this parameter should be consistent between client and server|
|tagFilterCache | |Not supported |Whether to cache tag filter results|
|queryBufferSize | |Supported, effective after restart|Not effective yet|
|queryRspPolicy | |Supported, effective immediately |Query response strategy|
|queryUseMemoryPool | |Not supported |Whether query will use memory pool to manage memory, default value: 1 (on); 0: off, 1: on|
|minReservedMemorySize | |Not supported |The minimum reserved system available memory size, all memory except reserved can be used for queries, unit: MB, default reserved size is 20% of system physical memory, value range 1024-1000000000|
|singleQueryMaxMemorySize| |Not supported |The memory limit that a single query can use on a single node (dnode), exceeding this limit will return an error, unit: MB, default value: 0 (no limit), value range 0-1000000000|
|filterScalarMode | |Not supported |Force scalar filter mode, 0: off; 1: on, default value 0|
|queryPlannerTrace | |Supported, effective immediately |Internal parameter, whether the query plan outputs detailed logs|
|queryNodeChunkSize | |Supported, effective immediately |Internal parameter, chunk size of the query plan|
|queryUseNodeAllocator | |Supported, effective immediately |Internal parameter, allocation method of the query plan|
|queryMaxConcurrentTables| |Not supported |Internal parameter, concurrency number of the query plan|
|queryRsmaTolerance | |Not supported |Internal parameter, tolerance time for determining which level of rsma data to query, in milliseconds|
|enableQueryHb | |Supported, effective immediately |Internal parameter, whether to send query heartbeat messages|
|pqSortMemThreshold | |Not supported |Internal parameter, memory threshold for sorting|
### Region Related
|Parameter Name|Supported Version|Description|
|-----------------|----------|-|
|timezone | |Time zone; defaults to dynamically obtaining the current time zone setting from the system|
|locale | |System locale information and encoding format, defaults to obtaining from the system|
|charset | |Character set encoding, defaults to obtaining from the system|
|Parameter Name |Supported Version |Dynamic Modification|Description|
|-----------------------|-------------------------|--------------------|------------|
|timezone | |Not supported |Time zone; defaults to dynamically obtaining the current time zone setting from the system|
|locale | |Not supported |System locale information and encoding format, defaults to obtaining from the system|
|charset | |Not supported |Character set encoding, defaults to obtaining from the system|
:::info
@ -170,152 +169,153 @@ The effective value of charset is UTF-8.
### Storage Related
|Parameter Name|Supported Version|Description|
|--------------------|----------|-|
|dataDir | |Directory for data files, all data files are written to this directory, default value /var/lib/taos|
|tempDir | |Specifies the directory for generating temporary files during system operation, default value /tmp|
|minimalDataDirGB | |Minimum space to be reserved in the time-series data storage directory specified by dataDir, in GB, default value 2|
|minimalTmpDirGB | |Minimum space to be reserved in the temporary file directory specified by tempDir, in GB, default value 1|
|minDiskFreeSize |After 3.1.1.0|When the available space on a disk is less than or equal to this threshold, the disk will no longer be selected for generating new data files, unit is bytes, range 52428800-1073741824, default value 52428800; Enterprise parameter|
|s3MigrateIntervalSec|After 3.3.4.3|Trigger cycle for automatic upload of local data files to S3, in seconds. Minimum: 600; Maximum: 100000. Default value 3600; Enterprise parameter|
|s3MigrateEnabled |After 3.3.4.3|Whether to automatically perform S3 migration, default value is 0, which means auto S3 migration is off, can be set to 1; Enterprise parameter|
|s3Accesskey |After 3.3.4.3|Colon-separated user SecretId:SecretKey, for example AKIDsQmwsfKxTo2A6nGVXZN0UlofKn6JRRSJ:lIdoy99ygEacU7iHfogaN2Xq0yumSm1E; Enterprise parameter|
|s3Endpoint |After 3.3.4.3|COS service domain name in the user's region, supports http and https, the region of the bucket must match the endpoint, otherwise it cannot be accessed; Enterprise parameter|
|s3BucketName |After 3.3.4.3|Bucket name, followed by a hyphen and the AppId of the user registered COS service, where AppId is unique to COS, not present in AWS and Alibaba Cloud, needs to be part of the bucket name, separated by a hyphen; parameter values are string type, but do not need quotes; for example test0711-1309024725; Enterprise parameter|
|s3PageCacheSize |After 3.3.4.3|Number of S3 page cache pages, range 4-1048576, unit is pages, default value 4096; Enterprise parameter|
|s3UploadDelaySec |After 3.3.4.3|How long a data file remains unchanged before being uploaded to S3, range 1-2592000 (30 days), in seconds, default value 60; Enterprise parameter|
|cacheLazyLoadThreshold| |Internal parameter, cache loading strategy|
|Parameter Name |Supported Version |Dynamic Modification|Description|
|-----------------------|-------------------------|--------------------|------------|
|dataDir | |Not supported |Directory for data files, all data files are written to this directory, default value /var/lib/taos|
|tempDir | |Not supported |Specifies the directory for generating temporary files during system operation, default value /tmp|
|minimalDataDirGB | |Not supported |Minimum space to be reserved in the time-series data storage directory specified by dataDir, in GB, default value 2|
|minimalTmpDirGB | |Not supported |Minimum space to be reserved in the temporary file directory specified by tempDir, in GB, default value 1|
|minDiskFreeSize |After 3.1.1.0|Supported, effective immediately |When the available space on a disk is less than or equal to this threshold, the disk will no longer be selected for generating new data files, unit is bytes, range 52428800-1073741824, default value 52428800; Enterprise parameter|
|s3MigrateIntervalSec|After 3.3.4.3|Supported, effective immediately |Trigger cycle for automatic upload of local data files to S3, in seconds. Minimum: 600; Maximum: 100000. Default value 3600; Enterprise parameter|
|s3MigrateEnabled |After 3.3.4.3|Supported, effective immediately |Whether to automatically perform S3 migration, default value is 0, which means auto S3 migration is off, can be set to 1; Enterprise parameter|
|s3Accesskey |After 3.3.4.3|Supported, effective after restart|Colon-separated user SecretId:SecretKey, for example AKIDsQmwsfKxTo2A6nGVXZN0UlofKn6JRRSJ:lIdoy99ygEacU7iHfogaN2Xq0yumSm1E; Enterprise parameter|
|s3Endpoint |After 3.3.4.3|Supported, effective after restart|COS service domain name in the user's region, supports http and https, the region of the bucket must match the endpoint, otherwise it cannot be accessed; Enterprise parameter|
|s3BucketName |After 3.3.4.3|Supported, effective after restart|Bucket name, followed by a hyphen and the AppId of the user registered COS service, where AppId is unique to COS, not present in AWS and Alibaba Cloud, needs to be part of the bucket name, separated by a hyphen; parameter values are string type, but do not need quotes; for example test0711-1309024725; Enterprise parameter|
|s3PageCacheSize |After 3.3.4.3|Supported, effective after restart|Number of S3 page cache pages, range 4-1048576, unit is pages, default value 4096; Enterprise parameter|
|s3UploadDelaySec |After 3.3.4.3|Supported, effective immediately |How long a data file remains unchanged before being uploaded to S3, range 1-2592000 (30 days), in seconds, default value 60; Enterprise parameter|
|cacheLazyLoadThreshold| |Supported, effective immediately |Internal parameter, cache loading strategy|
### Cluster Related
|Parameter Name|Supported Version|Description|
|--------------------------|----------|-|
|supportVnodes | |Maximum number of vnodes supported by a dnode, range 0-4096, default value is twice the number of CPU cores + 5|
|numOfCommitThreads | |Maximum number of commit threads, range 0-1024, default value 4|
|numOfMnodeReadThreads | |Number of Read threads for mnode, range 0-1024, default value is one quarter of the CPU cores (not exceeding 4)|
|numOfVnodeQueryThreads | |Number of Query threads for vnode, range 0-1024, default value is twice the number of CPU cores (not exceeding 16)|
|numOfVnodeFetchThreads | |Number of Fetch threads for vnode, range 0-1024, default value is one quarter of the CPU cores (not exceeding 4)|
|numOfVnodeRsmaThreads | |Number of Rsma threads for vnode, range 0-1024, default value is one quarter of the CPU cores (not exceeding 4)|
|numOfQnodeQueryThreads | |Number of Query threads for qnode, range 0-1024, default value is twice the number of CPU cores (not exceeding 16)|
|numOfSnodeSharedThreads | |Number of shared threads for snode, range 0-1024, default value is one quarter of the CPU cores (not less than 2, not exceeding 4)|
|numOfSnodeUniqueThreads | |Number of exclusive threads for snode, range 0-1024, default value is one quarter of the CPU cores (not less than 2, not exceeding 4)|
|ratioOfVnodeStreamThreads | |Ratio of stream computing using vnode threads, range 0.01-4, default value 4|
|ttlUnit | |Unit for ttl parameter, range 1-31572500, in seconds, default value 86400|
|ttlPushInterval | |Frequency of ttl timeout checks, range 1-100000, in seconds, default value 10|
|ttlChangeOnWrite | |Whether ttl expiration time changes with table modification; 0: no change, 1: change; default value 0|
|ttlBatchDropNum | |Number of subtables deleted in a batch for ttl, minimum value 0, default value 10000|
|retentionSpeedLimitMB | |Speed limit for data migration across different levels of disks, range 0-1024, in MB, default value 0, which means no limit|
|maxTsmaNum | |Maximum number of TSMAs that can be created in the cluster; range 0-3; default value 3|
|tmqMaxTopicNum | |Maximum number of topics that can be established for subscription; range 1-10000; default value 20|
|tmqRowSize | |Maximum number of records in a subscription data block, range 1-1000000, default value 4096|
|audit | |Audit feature switch; Enterprise parameter|
|auditInterval | |Time interval for reporting audit data; Enterprise parameter|
|auditCreateTable | |Whether to enable audit feature for creating subtables; Enterprise parameter|
|encryptAlgorithm | |Data encryption algorithm; Enterprise parameter|
|encryptScope | |Encryption scope; Enterprise parameter|
|enableWhiteList | |Switch for whitelist feature; Enterprise parameter|
|syncLogBufferMemoryAllowed| |Maximum memory allowed for sync log cache messages for a dnode, in bytes, range 104857600-INT64_MAX, default value is 1/10 of server memory, effective from versions 3.1.3.2/3.3.2.13|
|syncElectInterval | |Internal parameter, for debugging synchronization module|
|syncHeartbeatInterval | |Internal parameter, for debugging synchronization module|
|syncHeartbeatTimeout | |Internal parameter, for debugging synchronization module|
|syncSnapReplMaxWaitN | |Internal parameter, for debugging synchronization module|
|syncSnapReplMaxWaitN | |Internal parameter, for debugging synchronization module|
|arbHeartBeatIntervalSec | |Internal parameter, for debugging synchronization module|
|arbCheckSyncIntervalSec | |Internal parameter, for debugging synchronization module|
|arbSetAssignedTimeoutSec | |Internal parameter, for debugging synchronization module|
|mndSdbWriteDelta | |Internal parameter, for debugging mnode module|
|mndLogRetention | |Internal parameter, for debugging mnode module|
|skipGrant | |Internal parameter, for authorization checks|
|trimVDbIntervalSec | |Internal parameter, for deleting expired data|
|ttlFlushThreshold | |Internal parameter, frequency of ttl timer|
|compactPullupInterval | |Internal parameter, frequency of data reorganization timer|
|walFsyncDataSizeLimit | |Internal parameter, threshold for WAL to perform FSYNC|
|transPullupInterval | |Internal parameter, retry interval for mnode to execute transactions|
|mqRebalanceInterval | |Internal parameter, interval for consumer rebalancing|
|uptimeInterval | |Internal parameter, for recording system uptime|
|timeseriesThreshold | |Internal parameter, for usage statistics|
|udf | |Whether to start UDF service; 0: do not start, 1: start; default value 0 |
|udfdResFuncs | |Internal parameter, for setting UDF result sets|
|udfdLdLibPath | |Internal parameter, indicates the library path for loading UDF|
|Parameter Name |Supported Version |Dynamic Modification|Description|
|-----------------------|-------------------------|--------------------|------------|
|supportVnodes | |Supported, effective immediately |Maximum number of vnodes supported by a dnode, range 0-4096, default value is twice the number of CPU cores + 5|
|numOfCommitThreads | |Supported, effective after restart|Maximum number of commit threads, range 0-1024, default value 4|
|numOfMnodeReadThreads | |Supported, effective after restart|Number of Read threads for mnode, range 0-1024, default value is one quarter of the CPU cores (not exceeding 4)|
|numOfVnodeQueryThreads | |Supported, effective after restart|Number of Query threads for vnode, range 0-1024, default value is twice the number of CPU cores (not exceeding 16)|
|numOfVnodeFetchThreads | |Supported, effective after restart|Number of Fetch threads for vnode, range 0-1024, default value is one quarter of the CPU cores (not exceeding 4)|
|numOfVnodeRsmaThreads | |Supported, effective after restart|Number of Rsma threads for vnode, range 0-1024, default value is one quarter of the CPU cores (not exceeding 4)|
|numOfQnodeQueryThreads | |Supported, effective after restart|Number of Query threads for qnode, range 0-1024, default value is twice the number of CPU cores (not exceeding 16)|
|numOfSnodeSharedThreads | |Supported, effective after restart|Number of shared threads for snode, range 0-1024, default value is one quarter of the CPU cores (not less than 2, not exceeding 4)|
|numOfSnodeUniqueThreads | |Supported, effective after restart|Number of exclusive threads for snode, range 0-1024, default value is one quarter of the CPU cores (not less than 2, not exceeding 4)|
|ratioOfVnodeStreamThreads | |Supported, effective after restart|Ratio of stream computing using vnode threads, range 0.01-4, default value 4|
|ttlUnit | |Not supported |Unit for ttl parameter, range 1-31572500, in seconds, default value 86400|
|ttlPushInterval | |Supported, effective immediately |Frequency of ttl timeout checks, range 1-100000, in seconds, default value 10|
|ttlChangeOnWrite | |Supported, effective immediately |Whether ttl expiration time changes with table modification; 0: no change, 1: change; default value 0|
|ttlBatchDropNum | |Supported, effective immediately |Number of subtables deleted in a batch for ttl, minimum value 0, default value 10000|
|retentionSpeedLimitMB | |Supported, effective immediately |Speed limit for data migration across different levels of disks, range 0-1024, in MB, default value 0, which means no limit|
|maxTsmaNum | |Supported, effective immediately |Maximum number of TSMAs that can be created in the cluster; range 0-3; default value 3|
|tmqMaxTopicNum | |Supported, effective immediately |Maximum number of topics that can be established for subscription; range 1-10000; default value 20|
|tmqRowSize | |Supported, effective immediately |Maximum number of records in a subscription data block, range 1-1000000, default value 4096|
|audit | |Supported, effective immediately |Audit feature switch; Enterprise parameter|
|auditInterval | |Supported, effective immediately |Time interval for reporting audit data; Enterprise parameter|
|auditCreateTable | |Supported, effective immediately |Whether to enable audit feature for creating subtables; Enterprise parameter|
|encryptAlgorithm | |Not supported |Data encryption algorithm; Enterprise parameter|
|encryptScope | |Not supported |Encryption scope; Enterprise parameter|
|enableWhiteList | |Supported, effective immediately |Switch for whitelist feature; Enterprise parameter|
|syncLogBufferMemoryAllowed| |Supported, effective immediately |Maximum memory allowed for sync log cache messages for a dnode, in bytes, range 104857600-INT64_MAX, default value is 1/10 of server memory, effective from versions 3.1.3.2/3.3.2.13|
|syncElectInterval | |Not supported |Internal parameter, for debugging synchronization module|
|syncHeartbeatInterval | |Not supported |Internal parameter, for debugging synchronization module|
|syncHeartbeatTimeout | |Not supported |Internal parameter, for debugging synchronization module|
|syncSnapReplMaxWaitN | |Supported, effective immediately |Internal parameter, for debugging synchronization module|
|arbHeartBeatIntervalSec | |Supported, effective immediately |Internal parameter, for debugging synchronization module|
|arbCheckSyncIntervalSec | |Supported, effective immediately |Internal parameter, for debugging synchronization module|
|arbSetAssignedTimeoutSec | |Supported, effective immediately |Internal parameter, for debugging synchronization module|
|mndSdbWriteDelta | |Supported, effective immediately |Internal parameter, for debugging mnode module|
|mndLogRetention | |Supported, effective immediately |Internal parameter, for debugging mnode module|
|skipGrant | |Not supported |Internal parameter, for authorization checks|
|trimVDbIntervalSec | |Supported, effective immediately |Internal parameter, for deleting expired data|
|ttlFlushThreshold | |Supported, effective immediately |Internal parameter, frequency of ttl timer|
|compactPullupInterval | |Supported, effective immediately |Internal parameter, frequency of data reorganization timer|
|walFsyncDataSizeLimit | |Supported, effective immediately |Internal parameter, threshold for WAL to perform FSYNC|
|transPullupInterval | |Supported, effective immediately |Internal parameter, retry interval for mnode to execute transactions|
|mqRebalanceInterval | |Supported, effective immediately |Internal parameter, interval for consumer rebalancing|
|uptimeInterval | |Supported, effective immediately |Internal parameter, for recording system uptime|
|timeseriesThreshold | |Supported, effective immediately |Internal parameter, for usage statistics|
|udf | |Supported, effective after restart|Whether to start UDF service; 0: do not start, 1: start; default value 0 |
|udfdResFuncs | |Supported, effective after restart|Internal parameter, for setting UDF result sets|
|udfdLdLibPath | |Supported, effective after restart|Internal parameter, indicates the library path for loading UDF|
### Stream Computing Parameters
| Parameter Name | Supported Version | Description |
|-----------------------|----------|-|
| disableStream | | Switch to enable or disable stream computing |
| streamBufferSize | | Controls the size of the window state cache in memory, default value is 128MB |
| streamAggCnt | | Internal parameter, number of concurrent aggregation computations |
| checkpointInterval | | Internal parameter, checkpoint synchronization interval |
| concurrentCheckpoint | | Internal parameter, whether to check checkpoints concurrently |
| maxStreamBackendCache | | Internal parameter, maximum cache used by stream computing |
| streamSinkDataRate | | Internal parameter, used to control the write speed of stream computing results |
|Parameter Name |Supported Version |Dynamic Modification|Description|
|-----------------------|-------------------------|--------------------|------------|
| disableStream | |Supported, effective immediately | Switch to enable or disable stream computing |
| streamBufferSize | |Supported, effective immediately | Controls the size of the window state cache in memory, default value is 128MB |
| streamAggCnt | |Not supported | Internal parameter, number of concurrent aggregation computations |
| checkpointInterval | |Supported, effective after restart| Internal parameter, checkpoint synchronization interval |
| concurrentCheckpoint | |Supported, effective immediately | Internal parameter, whether to check checkpoints concurrently |
| maxStreamBackendCache | |Supported, effective immediately | Internal parameter, maximum cache used by stream computing |
| streamSinkDataRate | |Supported, effective after restart| Internal parameter, used to control the write speed of stream computing results |
### Log Related
| Parameter Name | Supported Version | Description |
|----------------|----------|-|
| logDir | | Log file directory, operational logs will be written to this directory, default value /var/log/taos |
| minimalLogDirGB | | Stops writing logs when the available space on the disk where the log folder is located is less than this value, unit GB, default value 1 |
| numOfLogLines | | Maximum number of lines allowed in a single log file, default value 10,000,000 |
| asyncLog | | Log writing mode, 0: synchronous, 1: asynchronous, default value 1 |
| logKeepDays | | Maximum retention time for log files, unit: days, default value 0, which means unlimited retention, log files will not be renamed, nor will new log files be rolled out, but the content of the log files may continue to roll depending on the log file size setting; when set to a value greater than 0, when the log file size reaches the set limit, it will be renamed to taosdlog.yyy, where yyy is the timestamp of the last modification of the log file, and a new log file will be rolled out |
| slowLogThreshold| 3.3.3.0 onwards | Slow query threshold, queries taking longer than or equal to this threshold are considered slow, unit seconds, default value 3 |
| slowLogMaxLen | 3.3.3.0 onwards | Maximum length of slow query logs, range 1-16384, default value 4096 |
| slowLogScope | 3.3.3.0 onwards | Type of slow query records, range ALL/QUERY/INSERT/OTHERS/NONE, default value QUERY |
| slowLogExceptDb | 3.3.3.0 onwards | Specifies the database that does not report slow queries, only supports configuring one database |
| debugFlag | | Log switch for running logs, 131 (outputs error and warning logs), 135 (outputs error, warning, and debug logs), 143 (outputs error, warning, debug, and trace logs); default value 131 or 135 (depending on the module) |
| tmrDebugFlag | | Log switch for the timer module, range as above |
| uDebugFlag | | Log switch for the utility module, range as above |
| rpcDebugFlag | | Log switch for the rpc module, range as above |
| qDebugFlag | | Log switch for the query module, range as above |
| dDebugFlag | | Log switch for the dnode module, range as above |
| vDebugFlag | | Log switch for the vnode module, range as above |
| mDebugFlag | | Log switch for the mnode module, range as above |
| azDebugFlag | 3.3.4.3 onwards | Log switch for the S3 module, range as above |
| sDebugFlag | | Log switch for the sync module, range as above |
| tsdbDebugFlag | | Log switch for the tsdb module, range as above |
| tqDebugFlag | | Log switch for the tq module, range as above |
| fsDebugFlag | | Log switch for the fs module, range as above |
| udfDebugFlag | | Log switch for the udf module, range as above |
| smaDebugFlag | | Log switch for the sma module, range as above |
| idxDebugFlag | | Log switch for the index module, range as above |
| tdbDebugFlag | | Log switch for the tdb module, range as above |
| metaDebugFlag | | Log switch for the meta module, range as above |
| stDebugFlag | | Log switch for the stream module, range as above |
| sndDebugFlag | | Log switch for the snode module, range as above |
|Parameter Name |Supported Version |Dynamic Modification|Description|
|-----------------------|-------------------------|--------------------|------------|
| logDir | |Not supported | Log file directory, operational logs will be written to this directory, default value /var/log/taos |
| minimalLogDirGB | |Not supported | Stops writing logs when the available space on the disk where the log folder is located is less than this value, unit GB, default value 1 |
| numOfLogLines | |Supported, effective immediately | Maximum number of lines allowed in a single log file, default value 10,000,000 |
| asyncLog | |Supported, effective immediately | Log writing mode, 0: synchronous, 1: asynchronous, default value 1 |
| logKeepDays | |Supported, effective immediately | Maximum retention time for log files, unit: days, default value 0, which means unlimited retention, log files will not be renamed, nor will new log files be rolled out, but the content of the log files may continue to roll depending on the log file size setting; when set to a value greater than 0, when the log file size reaches the set limit, it will be renamed to taosdlog.yyy, where yyy is the timestamp of the last modification of the log file, and a new log file will be rolled out |
| slowLogThreshold| 3.3.3.0 onwards |Supported, effective immediately | Slow query threshold, queries taking longer than or equal to this threshold are considered slow, unit seconds, default value 3 |
| slowLogMaxLen | 3.3.3.0 onwards |Supported, effective immediately | Maximum length of slow query logs, range 1-16384, default value 4096 |
| slowLogScope | 3.3.3.0 onwards |Supported, effective immediately | Type of slow query records, range ALL/QUERY/INSERT/OTHERS/NONE, default value QUERY |
| slowLogExceptDb | 3.3.3.0 onwards |Supported, effective immediately | Specifies the database that does not report slow queries, only supports configuring one database |
| debugFlag | |Supported, effective immediately | Log switch for running logs, 131 (outputs error and warning logs), 135 (outputs error, warning, and debug logs), 143 (outputs error, warning, debug, and trace logs); default value 131 or 135 (depending on the module) |
| tmrDebugFlag | |Supported, effective immediately | Log switch for the timer module, range as above |
| uDebugFlag | |Supported, effective immediately | Log switch for the utility module, range as above |
| rpcDebugFlag | |Supported, effective immediately | Log switch for the rpc module, range as above |
| qDebugFlag | |Supported, effective immediately | Log switch for the query module, range as above |
| dDebugFlag | |Supported, effective immediately | Log switch for the dnode module, range as above |
| vDebugFlag | |Supported, effective immediately | Log switch for the vnode module, range as above |
| mDebugFlag | |Supported, effective immediately | Log switch for the mnode module, range as above |
| azDebugFlag | 3.3.4.3 onwards |Supported, effective immediately | Log switch for the S3 module, range as above |
| sDebugFlag | |Supported, effective immediately | Log switch for the sync module, range as above |
| tsdbDebugFlag | |Supported, effective immediately | Log switch for the tsdb module, range as above |
| tqDebugFlag | |Supported, effective immediately | Log switch for the tq module, range as above |
| fsDebugFlag | |Supported, effective immediately | Log switch for the fs module, range as above |
| udfDebugFlag | |Supported, effective immediately | Log switch for the udf module, range as above |
| smaDebugFlag | |Supported, effective immediately | Log switch for the sma module, range as above |
| idxDebugFlag | |Supported, effective immediately | Log switch for the index module, range as above |
| tdbDebugFlag | |Supported, effective immediately | Log switch for the tdb module, range as above |
| metaDebugFlag | |Supported, effective immediately | Log switch for the meta module, range as above |
| stDebugFlag | |Supported, effective immediately | Log switch for the stream module, range as above |
| sndDebugFlag | |Supported, effective immediately | Log switch for the snode module, range as above |
### Debugging Related
| Parameter Name | Supported Version | Description |
|----------------------|-------------------|-------------|
| enableCoreFile | | Whether to generate a core file when crashing, 0: do not generate, 1: generate; default value is 1 |
| configDir | | Directory where the configuration files are located |
| scriptDir | | Directory for internal test tool scripts |
| assert | | Assertion control switch, default value is 0 |
| randErrorChance | | Internal parameter, used for random failure testing |
| randErrorDivisor | | Internal parameter, used for random failure testing |
| randErrorScope | | Internal parameter, used for random failure testing |
| safetyCheckLevel | | Internal parameter, used for random failure testing |
| experimental | | Internal parameter, used for some experimental features |
| simdEnable | After 3.3.4.3 | Internal parameter, used for testing SIMD acceleration |
| AVX512Enable | After 3.3.4.3 | Internal parameter, used for testing AVX512 acceleration |
| rsyncPort | | Internal parameter, used for debugging stream computing |
| snodeAddress | | Internal parameter, used for debugging stream computing |
| checkpointBackupDir | | Internal parameter, used for restoring snode data |
| enableAuditDelete | | Internal parameter, used for testing audit functions |
| slowLogThresholdTest | | Internal parameter, used for testing slow logs |
|Parameter Name |Supported Version |Dynamic Modification|Description|
|-----------------------|-------------------------|--------------------|------------|
| enableCoreFile | |Supported, effective immediately | Whether to generate a core file when crashing, 0: do not generate, 1: generate; default value is 1 |
| configDir | |Not supported | Directory where the configuration files are located |
|forceReadConfig | |Not supported ||Force the use of parameters from the configuration file,default value: 0|
| scriptDir | |Not supported | Directory for internal test tool scripts |
| assert | |Not supported | Assertion control switch, default value is 0 |
| randErrorChance | |Supported, effective immediately | Internal parameter, used for random failure testing |
| randErrorDivisor | |Supported, effective immediately | Internal parameter, used for random failure testing |
| randErrorScope | |Supported, effective immediately | Internal parameter, used for random failure testing |
| safetyCheckLevel | |Supported, effective immediately | Internal parameter, used for random failure testing |
| experimental | |Supported, effective immediately | Internal parameter, used for some experimental features |
| simdEnable | After 3.3.4.3 |Not supported | Internal parameter, used for testing SIMD acceleration |
| AVX512Enable | After 3.3.4.3 |Not supported | Internal parameter, used for testing AVX512 acceleration |
| rsyncPort | |Not supported | Internal parameter, used for debugging stream computing |
| snodeAddress | |Supported, effective immediately | Internal parameter, used for debugging stream computing |
| checkpointBackupDir | |Supported, effective immediately | Internal parameter, used for restoring snode data |
| enableAuditDelete | |Not supported | Internal parameter, used for testing audit functions |
| slowLogThresholdTest | |Not supported | Internal parameter, used for testing slow logs |
| bypassFlag |After 3.3.4.5 |Supported, effective immediately | Internal parameter, used for short-circuit testing|
### Compression Parameters
| Parameter Name | Supported Version | Description |
|----------------|-------------------|-------------|
| fPrecision | | Sets the compression precision for float type floating numbers, range 0.1 ~ 0.00000001, default value 0.00000001, floating numbers smaller than this value will have their mantissa truncated |
| dPrecision | | Sets the compression precision for double type floating numbers, range 0.1 ~ 0.0000000000000001, default value 0.0000000000000001, floating numbers smaller than this value will have their mantissa truncated |
| lossyColumn | Before 3.3.0.0 | Enables TSZ lossy compression for float and/or double types; range float/double/none; default value none, indicating lossless compression is off |
| ifAdtFse | | When TSZ lossy compression is enabled, use the FSE algorithm instead of the HUFFMAN algorithm, FSE algorithm is faster in compression but slightly slower in decompression, choose this for faster compression speed; 0: off, 1: on; default value is 0 |
| maxRange | | Internal parameter, used for setting lossy compression |
| curRange | | Internal parameter, used for setting lossy compression |
| compressor | | Internal parameter, used for setting lossy compression |
|Parameter Name |Supported Version |Dynamic Modification|Description|
|-----------------------|-------------------------|--------------------|------------|
| fPrecision | |Supported, effective immediately | Sets the compression precision for float type floating numbers, range 0.1 ~ 0.00000001, default value 0.00000001, floating numbers smaller than this value will have their mantissa truncated |
| dPrecision | |Supported, effective immediately | Sets the compression precision for double type floating numbers, range 0.1 ~ 0.0000000000000001, default value 0.0000000000000001, floating numbers smaller than this value will have their mantissa truncated |
| lossyColumn | Before 3.3.0.0 |Not supported | Enables TSZ lossy compression for float and/or double types; range float/double/none; default value none, indicating lossless compression is off |
| ifAdtFse | |Supported, effective after restart| When TSZ lossy compression is enabled, use the FSE algorithm instead of the HUFFMAN algorithm, FSE algorithm is faster in compression but slightly slower in decompression, choose this for faster compression speed; 0: off, 1: on; default value is 0 |
| maxRange | |Supported, effective after restart| Internal parameter, used for setting lossy compression |
| curRange | |Supported, effective after restart| Internal parameter, used for setting lossy compression |
| compressor | |Supported, effective after restart| Internal parameter, used for setting lossy compression |
**Additional Notes**

View File

@ -10,107 +10,109 @@ The TDengine client driver provides all the APIs needed for application programm
### Connection Related
|Parameter Name|Supported Version|Description|
|----------------------|----------|-------------|
|firstEp | |At startup, the endpoint of the first dnode in the cluster to actively connect to, default value: hostname:6030, if the server's hostname cannot be obtained, it is assigned to localhost|
|secondEp | |At startup, if the firstEp cannot be connected, try to connect to the endpoint of the second dnode in the cluster, no default value|
|compressMsgSize | |Whether to compress RPC messages; -1: no messages are compressed; 0: all messages are compressed; N (N>0): only messages larger than N bytes are compressed; default value -1|
|shellActivityTimer | |The duration in seconds for the client to send heartbeats to mnode, range 1-120, default value 3|
|numOfRpcSessions | |Maximum number of connections supported by RPC, range 100-100000, default value 30000|
|numOfRpcThreads | |Number of threads for RPC to send and receive data, range 1-50, default value is half of the CPU cores|
|numOfTaskQueueThreads | |Number of threads for the client to handle RPC messages, range 4-16, default value is half of the CPU cores|
|timeToGetAvailableConn| Cancelled after 3.3.4.* |The longest waiting time to get an available connection, range 10-50000000, in milliseconds, default value 500000|
|useAdapter | |Internal parameter, whether to use taosadapter, affects CSV file import|
|shareConnLimit |Added in 3.3.4.0|Internal parameter, the number of queries a link can share, range 1-256, default value 10|
|readTimeout |Added in 3.3.4.0|Internal parameter, minimum timeout, range 64-604800, in seconds, default value 900|
|Parameter Name|Supported Version|Dynamic Modification|Description|
|----------------------|----------|--------------------|-------------|
|firstEp | |Supported, effective immediately |At startup, the endpoint of the first dnode in the cluster to actively connect to, default value: hostname:6030, if the server's hostname cannot be obtained, it is assigned to localhost|
|secondEp | |Supported, effective immediately |At startup, if the firstEp cannot be connected, try to connect to the endpoint of the second dnode in the cluster, no default value|
|compressMsgSize | |Supported, effective immediately |Whether to compress RPC messages; -1: no messages are compressed; 0: all messages are compressed; N (N>0): only messages larger than N bytes are compressed; default value -1|
|shellActivityTimer | |Not supported |The duration in seconds for the client to send heartbeats to mnode, range 1-120, default value 3|
|numOfRpcSessions | |Supported, effective immediately |Maximum number of connections supported by RPC, range 100-100000, default value 30000|
|numOfRpcThreads | |Not supported |Number of threads for RPC to send and receive data, range 1-50, default value is half of the CPU cores|
|numOfTaskQueueThreads | |Not supported |Number of threads for the client to handle RPC messages, range 4-16, default value is half of the CPU cores|
|timeToGetAvailableConn| Cancelled after 3.3.4.* |Not supported |The longest waiting time to get an available connection, range 10-50000000, in milliseconds, default value 500000|
|useAdapter | |Supported, effective immediately |Internal parameter, whether to use taosadapter, affects CSV file import|
|shareConnLimit |Added in 3.3.4.0|Not supported |Internal parameter, the number of queries a link can share, range 1-256, default value 10|
|readTimeout |Added in 3.3.4.0|Not supported |Internal parameter, minimum timeout, range 64-604800, in seconds, default value 900|
### Query Related
|Parameter Name|Supported Version|Description|
|---------------------------------|---------|-|
|countAlwaysReturnValue | |Whether the count/hyperloglog function returns a value when the input data is empty or NULL; 0: returns an empty row, 1: returns; default value 1; when this parameter is set to 1, if the query contains an INTERVAL clause or the query uses TSMA, and the corresponding group or window has empty or NULL data, the corresponding group or window will not return a query result; note that this parameter should be consistent between client and server|
|keepColumnName | |Automatically sets the alias to the column name (excluding the function name) when querying with Last, First, LastRow functions without specifying an alias, thus the order by clause will automatically refer to the column corresponding to the function; 1: automatically sets the alias to the column name (excluding the function name), 0: does not automatically set an alias; default value: 0|
|multiResultFunctionStarReturnTags|After 3.3.3.0|When querying a supertable, whether last(\*)/last_row(\*)/first(\*) returns tag columns; when querying basic tables, subtables, it is not affected by this parameter; 0: does not return tag columns, 1: returns tag columns; default value: 0; when this parameter is set to 0, last(\*)/last_row(\*)/first(\*) only returns the ordinary columns of the supertable; when set to 1, it returns both the ordinary columns and tag columns of the supertable|
|metaCacheMaxSize | |Specifies the maximum size of metadata cache for a single client, in MB; default value -1, meaning unlimited|
|maxTsmaCalcDelay | |The allowable delay for tsma calculation by the client during query, range 600s - 86400s, i.e., 10 minutes - 1 day; default value: 600 seconds|
|tsmaDataDeleteMark | |The retention time for intermediate results of historical data calculated by TSMA, in milliseconds; range >= 3600000, i.e., at least 1h; default value: 86400000, i.e., 1d |
|queryPolicy | |Execution strategy for query statements, 1: only use vnode, do not use qnode; 2: subtasks without scan operators are executed on qnode, subtasks with scan operators are executed on vnode; 3: vnode only runs scan operators, all other operators are executed on qnode; default value: 1|
|queryTableNotExistAsEmpty | |Whether to return an empty result set when the queried table does not exist; false: returns an error; true: returns an empty result set; default value false|
|querySmaOptimize | |Optimization strategy for sma index, 0: do not use sma index, always query from original data; 1: use sma index, directly query from pre-calculated results for eligible statements; default value: 0|
|queryPlannerTrace | |Internal parameter, whether the query plan outputs detailed logs|
|queryNodeChunkSize | |Internal parameter, chunk size of the query plan|
|queryUseNodeAllocator | |Internal parameter, allocation method of the query plan|
|queryMaxConcurrentTables | |Internal parameter, concurrency number of the query plan|
|enableQueryHb | |Internal parameter, whether to send query heartbeat messages|
|minSlidingTime | |Internal parameter, minimum allowable value for sliding|
|minIntervalTime | |Internal parameter, minimum allowable value for interval|
|Parameter Name|Supported Version|Dynamic Modification|Description|
|----------------------|----------|--------------------|-------------|
|countAlwaysReturnValue | |Supported, effective immediately |Whether the count/hyperloglog function returns a value when the input data is empty or NULL; 0: returns an empty row, 1: returns; default value 1; when this parameter is set to 1, if the query contains an INTERVAL clause or the query uses TSMA, and the corresponding group or window has empty or NULL data, the corresponding group or window will not return a query result; note that this parameter should be consistent between client and server|
|keepColumnName | |Supported, effective immediately |Automatically sets the alias to the column name (excluding the function name) when querying with Last, First, LastRow functions without specifying an alias, thus the order by clause will automatically refer to the column corresponding to the function; 1: automatically sets the alias to the column name (excluding the function name), 0: does not automatically set an alias; default value: 0|
|multiResultFunctionStarReturnTags|After 3.3.3.0|Supported, effective immediately |When querying a supertable, whether last(\*)/last_row(\*)/first(\*) returns tag columns; when querying basic tables, subtables, it is not affected by this parameter; 0: does not return tag columns, 1: returns tag columns; default value: 0; when this parameter is set to 0, last(\*)/last_row(\*)/first(\*) only returns the ordinary columns of the supertable; when set to 1, it returns both the ordinary columns and tag columns of the supertable|
|metaCacheMaxSize | |Supported, effective immediately |Specifies the maximum size of metadata cache for a single client, in MB; default value -1, meaning unlimited|
|maxTsmaCalcDelay | |Supported, effective immediately |The allowable delay for tsma calculation by the client during query, range 600s - 86400s, i.e., 10 minutes - 1 day; default value: 600 seconds|
|tsmaDataDeleteMark | |Supported, effective immediately |The retention time for intermediate results of historical data calculated by TSMA, in milliseconds; range >= 3600000, i.e., at least 1h; default value: 86400000, i.e., 1d |
|queryPolicy | |Supported, effective immediately |Execution strategy for query statements, 1: only use vnode, do not use qnode; 2: subtasks without scan operators are executed on qnode, subtasks with scan operators are executed on vnode; 3: vnode only runs scan operators, all other operators are executed on qnode; default value: 1|
|queryTableNotExistAsEmpty | |Supported, effective immediately |Whether to return an empty result set when the queried table does not exist; false: returns an error; true: returns an empty result set; default value false|
|querySmaOptimize | |Supported, effective immediately |Optimization strategy for sma index, 0: do not use sma index, always query from original data; 1: use sma index, directly query from pre-calculated results for eligible statements; default value: 0|
|queryPlannerTrace | |Supported, effective immediately |Internal parameter, whether the query plan outputs detailed logs|
|queryNodeChunkSize | |Supported, effective immediately |Internal parameter, chunk size of the query plan|
|queryUseNodeAllocator | |Supported, effective immediately |Internal parameter, allocation method of the query plan|
|queryMaxConcurrentTables | |Not supported |Internal parameter, concurrency number of the query plan|
|enableQueryHb | |Supported, effective immediately |Internal parameter, whether to send query heartbeat messages|
|minSlidingTime | |Supported, effective immediately |Internal parameter, minimum allowable value for sliding|
|minIntervalTime | |Supported, effective immediately |Internal parameter, minimum allowable value for interval|
### Writing Related
| Parameter Name | Supported Version | Description |
|---------------------------------|-------------------|-------------|
| smlChildTableName | | Key for custom child table name in schemaless, no default value |
| smlAutoChildTableNameDelimiter | | Delimiter between schemaless tags, concatenated as the child table name, no default value |
| smlTagName | | Default tag name when schemaless tag is empty, default value "_tag_null" |
| smlTsDefaultName | | Configuration for setting the time column name in schemaless auto table creation, default value "_ts" |
| smlDot2Underline | | Converts dots in supertable names to underscores in schemaless |
| maxInsertBatchRows | | Internal parameter, maximum number of rows per batch insert |
|Parameter Name|Supported Version|Dynamic Modification|Description|
|----------------------|----------|--------------------|-------------|
| smlChildTableName | |Supported, effective immediately | Key for custom child table name in schemaless, no default value |
| smlAutoChildTableNameDelimiter | |Supported, effective immediately | Delimiter between schemaless tags, concatenated as the child table name, no default value |
| smlTagName | |Supported, effective immediately | Default tag name when schemaless tag is empty, default value "_tag_null" |
| smlTsDefaultName | |Supported, effective immediately | Configuration for setting the time column name in schemaless auto table creation, default value "_ts" |
| smlDot2Underline | |Supported, effective immediately | Converts dots in supertable names to underscores in schemaless |
| maxInsertBatchRows | |Supported, effective immediately | Internal parameter, maximum number of rows per batch insert |
### Region Related
| Parameter Name | Supported Version | Description |
|----------------|-------------------|-------------|
| timezone | | Time zone; defaults to dynamically obtaining the current system time zone setting |
| locale | | System locale and encoding format, defaults to system settings |
| charset | | Character set encoding, defaults to system settings |
|Parameter Name|Supported Version|Dynamic Modification|Description|
|----------------------|----------|--------------------|-------------|
| timezone | |Supported, effective immediately | Time zone; defaults to dynamically obtaining the current system time zone setting |
| locale | |Supported, effective immediately | System locale and encoding format, defaults to system settings |
| charset | |Supported, effective immediately | Character set encoding, defaults to system settings |
### Storage Related
| Parameter Name | Supported Version | Description |
|-----------------|-------------------|-------------|
| tempDir | | Specifies the directory for generating temporary files during operation, default on Linux platform is /tmp |
| minimalTmpDirGB | | Minimum space required to be reserved in the directory specified by tempDir, in GB, default value: 1 |
|Parameter Name|Supported Version|Dynamic Modification|Description|
|----------------------|----------|--------------------|-------------|
| tempDir | |Supported, effective immediately | Specifies the directory for generating temporary files during operation, default on Linux platform is /tmp |
| minimalTmpDirGB | |Supported, effective immediately | Minimum space required to be reserved in the directory specified by tempDir, in GB, default value: 1 |
### Log Related
| Parameter Name | Supported Version | Description |
|------------------|-------------------|-------------|
| logDir | | Log file directory, operational logs will be written to this directory, default value: /var/log/taos |
| minimalLogDirGB | | Stops writing logs when the disk space available in the log directory is less than this value, in GB, default value: 1 |
| numOfLogLines | | Maximum number of lines allowed in a single log file, default value: 10,000,000 |
| asyncLog | | Log writing mode, 0: synchronous, 1: asynchronous, default value: 1 |
| logKeepDays | | Maximum retention time for log files, in days, default value: 0, meaning unlimited retention. Log files will not be renamed, nor will new log files be rolled out, but the content of the log files may continue to roll depending on the log file size setting; when set to a value greater than 0, the log file will be renamed to taoslogx.yyy, where yyy is the timestamp of the last modification of the log file, and a new log file will be rolled out |
| debugFlag | | Log switch for running logs, 131 (output error and warning logs), 135 (output error, warning, and debug logs), 143 (output error, warning, debug, and trace logs); default value 131 or 135 (depending on the module) |
| tmrDebugFlag | | Log switch for the timer module, value range as above |
| uDebugFlag | | Log switch for the utility module, value range as above |
| rpcDebugFlag | | Log switch for the rpc module, value range as above |
| jniDebugFlag | | Log switch for the jni module, value range as above |
| qDebugFlag | | Log switch for the query module, value range as above |
| cDebugFlag | | Log switch for the client module, value range as above |
| simDebugFlag | | Internal parameter, log switch for the test tool, value range as above |
| tqClientDebugFlag| After 3.3.4.3 | Log switch for the client module, value range as above |
|Parameter Name|Supported Version|Dynamic Modification|Description|
|----------------------|----------|--------------------|-------------|
| logDir | |Not supported | Log file directory, operational logs will be written to this directory, default value: /var/log/taos |
| minimalLogDirGB | |Supported, effective immediately | Stops writing logs when the disk space available in the log directory is less than this value, in GB, default value: 1 |
| numOfLogLines | |Supported, effective immediately | Maximum number of lines allowed in a single log file, default value: 10,000,000 |
| asyncLog | |Supported, effective immediately | Log writing mode, 0: synchronous, 1: asynchronous, default value: 1 |
| logKeepDays | |Supported, effective immediately | Maximum retention time for log files, in days, default value: 0, meaning unlimited retention. Log files will not be renamed, nor will new log files be rolled out, but the content of the log files may continue to roll depending on the log file size setting; when set to a value greater than 0, the log file will be renamed to taoslogx.yyy, where yyy is the timestamp of the last modification of the log file, and a new log file will be rolled out |
| debugFlag | |Supported, effective immediately | Log switch for running logs, 131 (output error and warning logs), 135 (output error, warning, and debug logs), 143 (output error, warning, debug, and trace logs); default value 131 or 135 (depending on the module) |
| tmrDebugFlag | |Supported, effective immediately | Log switch for the timer module, value range as above |
| uDebugFlag | |Supported, effective immediately | Log switch for the utility module, value range as above |
| rpcDebugFlag | |Supported, effective immediately | Log switch for the rpc module, value range as above |
| jniDebugFlag | |Supported, effective immediately | Log switch for the jni module, value range as above |
| qDebugFlag | |Supported, effective immediately | Log switch for the query module, value range as above |
| cDebugFlag | |Supported, effective immediately | Log switch for the client module, value range as above |
| simDebugFlag | |Supported, effective immediately | Internal parameter, log switch for the test tool, value range as above |
| tqClientDebugFlag| After 3.3.4.3 |Supported, effective immediately | Log switch for the client module, value range as above |
### Debugging Related
| Parameter Name | Supported Version | Description |
|------------------|-------------------|-------------|
| crashReporting | | Whether to upload crash to telemetry, 0: do not upload, 1: upload; default value: 1 |
| enableCoreFile | | Whether to generate a core file when crashing, 0: do not generate, 1: generate; default value: 1 |
| assert | | Assertion control switch, default value: 0 |
| configDir | | Directory for configuration files |
| scriptDir | | Internal parameter, directory for test cases |
| randErrorChance | After 3.3.3.0 | Internal parameter, used for random failure testing |
| randErrorDivisor | After 3.3.3.0 | Internal parameter, used for random failure testing |
| randErrorScope | After 3.3.3.0 | Internal parameter, used for random failure testing |
| safetyCheckLevel | After 3.3.3.0 | Internal parameter, used for random failure testing |
| simdEnable | After 3.3.4.3 | Internal parameter, used for testing SIMD acceleration |
| AVX512Enable | After 3.3.4.3 | Internal parameter, used for testing AVX512 acceleration |
|Parameter Name|Supported Version|Dynamic Modification|Description|
|----------------------|----------|--------------------|-------------|
| crashReporting | |Supported, effective immediately | Whether to upload crash to telemetry, 0: do not upload, 1: upload; default value: 1 |
| enableCoreFile | |Supported, effective immediately | Whether to generate a core file when crashing, 0: do not generate, 1: generate; default value: 1 |
| assert | |Not supported | Assertion control switch, default value: 0 |
| configDir | |Not supported | Directory for configuration files |
| scriptDir | |Not supported | Internal parameter, directory for test cases |
| randErrorChance | After 3.3.3.0 |Not supported | Internal parameter, used for random failure testing |
| randErrorDivisor | After 3.3.3.0 |Not supported | Internal parameter, used for random failure testing |
| randErrorScope | After 3.3.3.0 |Not supported | Internal parameter, used for random failure testing |
| safetyCheckLevel | After 3.3.3.0 |Not supported | Internal parameter, used for random failure testing |
| simdEnable | After 3.3.4.3 |Not supported | Internal parameter, used for testing SIMD acceleration |
| AVX512Enable | After 3.3.4.3 |Not supported | Internal parameter, used for testing AVX512 acceleration |
| bypassFlag |After 3.3.4.5 |Supported, effective immediately | Internal parameter, used for short-circuit testing|
### SHELL Related
|Parameter Name|Supported Version|Description|
|-----------------|----------|-|
|enableScience | |Whether to enable scientific notation for displaying floating numbers; 0: do not enable, 1: enable; default value: 1|
|Parameter Name|Supported Version|Dynamic Modification|Description|
|----------------------|----------|--------------------|-------------|
|enableScience | |Not supported |Whether to enable scientific notation for displaying floating numbers; 0: do not enable, 1: enable; default value: 1|
## API

View File

@ -171,7 +171,37 @@ Metric details:
5. **Writes**: Total number of writes
6. **Other**: Total number of other requests
There are also line charts for the above categories.
There are also line charts for the above categories.
### Automatic import of preconfigured alert rules
After summarizing user experience, 14 commonly used alert rules are sorted out. These alert rules can monitor key indicators of the TDengine cluster and report alerts, such as abnormal and exceeded indicators.
Starting from TDengine-Server 3.3.4.3 (TDengine-datasource 3.6.3), TDengine Datasource supports automatic import of preconfigured alert rules. You can import 14 alert rules to Grafana (version 11 or later) with one click.
In the TDengine-datasource setting interface, turn on the "Load Tengine Alert" switch, click the "Save & test" button, the plugin will automatically load the mentioned 14 alert rules. The rules will be placed in the Grafana alerts directory. If not required, turn off the "Load TDengine Alert" switch, and click the button next to "Clear TDengine Alert" to clear all the alert rules imported into this data source.
After importing, click on "Alert rules" on the left side of the Grafana interface to view all current alert rules. By configuring contact points, users can receive alert notifications.
The specific configuration of the 14 alert rules is as follows:
| alert rule| Rule threshold| Behavior when no data | Data scanning interval |Duration | SQL |
| ------ | --------- | ---------------- | ----------- |------- |----------------------|
|CPU load of dnode node|average > 80%|Trigger alert|5 minutes|5 minutes |`select now(), dnode_id, last(cpu_system) as cup_use from log.taosd_dnodes_info where _ts >= (now- 5m) and _ts < now partition by dnode_id having first(_ts) > 0 `|
|Memory of dnode node |average > 60%|Trigger alert|5 minutes|5 minutes|`select now(), dnode_id, last(mem_engine) / last(mem_total) * 100 as taosd from log.taosd_dnodes_info where _ts >= (now- 5m) and _ts <now partition by dnode_id`|
|Disk capacity occupancy of dnode nodes | > 80%|Trigger alert|5 minutes|5 minutes|`select now(), dnode_id, data_dir_level, data_dir_name, last(used) / last(total) * 100 as used from log.taosd_dnodes_data_dirs where _ts >= (now - 5m) and _ts < now partition by dnode_id, data_dir_level, data_dir_name`|
|Authorization expires |< 60天|Trigger alert|1 day|0 0 seconds|`select now(), cluster_id, last(grants_expire_time) / 86400 as expire_time from log.taosd_cluster_info where _ts >= (now - 24h) and _ts < now partition by cluster_id having first(_ts) > 0 `|
|The used measurement points has reached the authorized number|>= 90%|Trigger alert|1 day|0 seconds|`select now(), cluster_id, CASE WHEN max(grants_timeseries_total) > 0.0 THEN max(grants_timeseries_used) /max(grants_timeseries_total) * 100.0 ELSE 0.0 END AS result from log.taosd_cluster_info where _ts >= (now - 30s) and _ts < now partition by cluster_id having timetruncate(first(_ts), 1m) > 0`|
|Number of concurrent query requests | > 100|Do not trigger alert|1 minute|0 seconds|`select now() as ts, count(*) as slow_count from performance_schema.perf_queries`|
|Maximum time for slow query execution (no time window) |> 300秒|Do not trigger alert|1 minute|0 seconds|`select now() as ts, count(*) as slow_count from performance_schema.perf_queries where exec_usec>300000000`|
|dnode offline |total != alive|Trigger alert|30 seconds|0 seconds|`select now(), cluster_id, last(dnodes_total) - last(dnodes_alive) as dnode_offline from log.taosd_cluster_info where _ts >= (now -30s) and _ts < now partition by cluster_id having first(_ts) > 0`|
|vnode offline |total != alive|Trigger alert|30 seconds|0 seconds|`select now(), cluster_id, last(vnodes_total) - last(vnodes_alive) as vnode_offline from log.taosd_cluster_info where _ts >= (now - 30s) and _ts < now partition by cluster_id having first(_ts) > 0 `|
|Number of data deletion requests |> 0|Do not trigger alert|30 seconds|0 seconds|``select now(), count(`count`) as `delete_count` from log.taos_sql_req where sql_type = 'delete' and _ts >= (now -30s) and _ts < now``|
|Adapter RESTful request fail |> 5|Do not trigger alert|30 seconds|0 seconds|``select now(), sum(`fail`) as `Failed` from log.adapter_requests where req_type=0 and ts >= (now -30s) and ts < now``|
|Adapter WebSocket request fail |> 5|Do not trigger alert|30 seconds|0 seconds|``select now(), sum(`fail`) as `Failed` from log.adapter_requests where req_type=1 and ts >= (now -30s) and ts < now``|
|Dnode data reporting is missing |< 3|Trigger alert|180 seconds|0 seconds|`select now(), cluster_id, count(*) as dnode_report from log.taosd_cluster_info where _ts >= (now -180s) and _ts < now partition by cluster_id having timetruncate(first(_ts), 1h) > 0`|
|Restart dnode |max(update_time) > last(update_time)|Trigger alert|90 seconds|0 seconds|`select now(), dnode_id, max(uptime) - last(uptime) as dnode_restart from log.taosd_dnodes_info where _ts >= (now - 90s) and _ts < now partition by dnode_id`|
TDengine users can modify and improve these alert rules according to their own business needs. In Grafana 7.5 and below versions, the Dashboard and Alert rules functions are combined, while in subsequent new versions, the two functions are separated. To be compatible with Grafana7.5 and below versions, an Alert Used Only panel has been added to the TDinsight panel, which is only required for Grafana7.5 and below versions.
## Upgrade

View File

@ -41,38 +41,28 @@ If there is a single replica on the node and the node is offline, to forcibly de
ALTER DNODE dnode_id dnode_option
ALTER ALL DNODES dnode_option
dnode_option: {
'resetLog'
| 'balance' 'value'
| 'monitor' 'value'
| 'debugFlag' 'value'
| 'monDebugFlag' 'value'
| 'vDebugFlag' 'value'
| 'mDebugFlag' 'value'
| 'cDebugFlag' 'value'
| 'httpDebugFlag' 'value'
| 'qDebugflag' 'value'
| 'sdbDebugFlag' 'value'
| 'uDebugFlag' 'value'
| 'tsdbDebugFlag' 'value'
| 'sDebugflag' 'value'
| 'rpcDebugFlag' 'value'
| 'dDebugFlag' 'value'
| 'mqttDebugFlag' 'value'
| 'wDebugFlag' 'value'
| 'tmrDebugFlag' 'value'
| 'cqDebugFlag' 'value'
}
```
The modifiable configuration items in the syntax above are configured in the same way as in the dnode configuration file, the difference being that modifications are dynamic, take immediate effect, and do not require restarting the dnode.
For configuration parameters that support dynamic modification, you can use the ALTER DNODE or ALTER ALL DNODES syntax to modify the values of configuration parameters in a dnode. Starting from version 3.3.4.0, the modified configuration parameters will be automatically persisted and will remain effective even after the database service is restarted.
`value` is the value of the parameter, which needs to be in string format. For example, to change the log output level of dnode 1 to debug:
To check whether a configuration parameter supports dynamic modification, please refer to the following page: [taosd Reference](../01-components/01-taosd.md)
The value is the parameter's value and needs to be in character format. For example, to change the log output level of dnode 1 to debug:
```sql
ALTER DNODE 1 'debugFlag' '143';
```
### Additional Notes:
Configuration parameters in a dnode are divided into global configuration parameters and local configuration parameters. You can check the category field in SHOW VARIABLES or SHOW DNODE dnode_id VARIABLE to determine whether a configuration parameter is a global configuration parameter or a local configuration parameter:
Local configuration parameters: You can use ALTER DNODE or ALTER ALL DNODES to update the local configuration parameters of a specific dnode or all dnodes.
Global configuration parameters: Global configuration parameters require consistency across all dnodes, so you can only use ALTER ALL DNODES to update the global configuration parameters of all dnodes.
There are three cases for whether a configuration parameter can be dynamically modified:
Supports dynamic modification, effective immediately
Supports dynamic modification, effective after restart
Does not support dynamic modification
For configuration parameters that take effect after a restart, you can see the modified values through SHOW VARIABLES or SHOW DNODE dnode_id VARIABLE, but you need to restart the database service to make them effective.
## Add Management Node
@ -136,18 +126,12 @@ If the client is also considered as part of the cluster in a broader sense, the
```sql
ALTER LOCAL local_option
local_option: {
'resetLog'
| 'rpcDebugFlag' 'value'
| 'tmrDebugFlag' 'value'
| 'cDebugFlag' 'value'
| 'uDebugFlag' 'value'
| 'debugFlag' 'value'
}
```
The parameters in the syntax above are used in the same way as in the configuration file for the client, but do not require a restart of the client, and the changes take effect immediately.
You can use the above syntax to modify the client's configuration parameters, and there is no need to restart the client. The changes take effect immediately.
To check whether a configuration parameter supports dynamic modification, please refer to the following page:[taosc Reference](../01-components/02-taosc.md)
## View Client Configuration

View File

@ -342,3 +342,18 @@ Note: Users with SYSINFO property set to 0 cannot view this table.
| 10 | raw_data | BIGINT | Estimated size of raw data, in KB |
note:
## INS_FILESETS
Provides information about file sets.
| # | **Column** | **Data Type** | **Description** | ** |
| --- | :-----------: | ------------- | ---------------------------------------------------- |
| 1 | db_name | VARCHAR(65) | Database name |
| 2 | vgroup_id | INT | Vgroup ID |
| 3 | fileset_id | INT | File set ID |
| 4 | start_time | TIMESTAMP | Start time of the time range covered by the file set |
| 5 | end_time | TIMESTAMP | End time of the time range covered by the file set |
| 6 | total_size | BIGINT | Total size of the file set |
| 7 | last_compact | TIMESTAMP | Time of the last compaction |
| 8 | shold_compact | bool | Whether the file set should be compacted |

View File

@ -72,6 +72,8 @@ This document details the server error codes that may be encountered when using
| 0x80000133 | Invalid operation | Invalid or unsupported operation | 1. Modify to confirm the current operation is legal and supported, check parameter validity 2. If the problem persists, preserve the scene and logs, report issue on github |
| 0x80000134 | Invalid value | Invalid value | Preserve the scene and logs, report issue on github |
| 0x80000135 | Invalid fqdn | Invalid FQDN | Check if the configured or input FQDN value is correct |
| 0x8000013C | Invalid disk id | Invalid disk id | Check users whether the mounted disk is invalid or use the parameter diskIDCheckEnabled to skip the disk check. |
## tsc

View File

@ -286,4 +286,14 @@ This connection only reports the most basic information that does not involve an
This feature is an optional configuration item, which is enabled by default in the open-source version. The specific parameter is telemetryReporting, as explained in the [official documentation](../tdengine-reference/components/taosd/).
You can disable this parameter at any time by modifying telemetryReporting to 0 in taos.cfg, then restarting the database service.
Code located at: [https://github.com/taosdata/TDengine/blob/62e609c558deb764a37d1a01ba84bc35115a85a4/source/dnode/mnode/impl/src/mndTelem.c](https://github.com/taosdata/TDengine/blob/62e609c558deb764a37d1a01ba84bc35115a85a4/source/dnode/mnode/impl/src/mndTelem.c).
Additionally, for the highly secure enterprise version, TDengine Enterprise, this parameter will not be operational.
Additionally, for the highly secure enterprise version, TDengine Enterprise, this parameter will not be operational.
### 31 What should I do if I encounter 'Sync leader is unreachable' when connecting to the cluster for the first time?
Reporting this error indicates that the first connection to the cluster was successful, but the IP address accessed for the first time was not the leader of mnode. An error occurred when the client attempted to establish a connection with the leader. The client searches for the leader node through EP, which specifies the fqdn and port number. There are two common reasons for this error:
- The ports of other dnodes in the cluster are not open
- The client's hosts file is not configured correctly
Therefore, first, check whether all ports on the server and cluster (default 6030 for native connections and 6041 for HTTP connections) are open; Next, check if the client's hosts file has configured the fqdn and IP information for all dnodes in the cluster.
If the issue still cannot be resolved, it is necessary to contact Taos technical personnel for support.

View File

@ -26,7 +26,6 @@ async function createDbAndTable() {
let conf = new taos.WSConfig(dsn);
conf.setUser('root');
conf.setPwd('taosdata');
conf.setDb('power');
wsSql = await taos.sqlConnect(conf);
console.log("Connected to " + dsn + " successfully.");
// create database

View File

@ -40,7 +40,6 @@ async function prepare() {
let conf = new taos.WSConfig('ws://localhost:6041');
conf.setUser('root');
conf.setPwd('taosdata');
conf.setDb('power');
const createDB = `CREATE DATABASE IF NOT EXISTS ${db}`;
const createStable = `CREATE STABLE IF NOT EXISTS ${db}.${stable} (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int);`;

View File

@ -34,10 +34,10 @@ async function createConsumer() {
}
async function prepare() {
let conf = new taos.WSConfig('ws://192.168.1.98:6041');
let conf = new taos.WSConfig('ws://localhost:6041');
conf.setUser('root');
conf.setPwd('taosdata');
conf.setDb('power');
const createDB = `CREATE DATABASE IF NOT EXISTS ${db}`;
const createStable = `CREATE STABLE IF NOT EXISTS ${db}.${stable} (ts timestamp, current float, voltage int, phase float) TAGS (location binary(64), groupId int);`;

View File

@ -4,11 +4,10 @@ sidebar_label: "安装部署"
---
### 环境准备
使用 TDgpt 的高级时序数据分析功能需要在 TDengine 集群中安装部署 AI nodeAnode。Anode 可以运行在 Linux/Windows/MacOS 等平台上,同时需要 3.10 或以上版本的 Python 环境支持。
使用 TDgpt 的高级时序数据分析功能需要在 TDengine 集群中安装部署 AI nodeAnode。Anode 运行在 Linux 平台上,并需要 3.10 或以上版本的 Python 环境支持。
> 部署 Anode 需要 TDengine Enterprise 3.3.4.3 及以后版本,请首先确认搭配 Anode 使用的 TDengine 能够支持 Anode。
### 安装及卸载
不同操作系统上安装及部署 Anode 有一些差异,主要是卸载操作、安装路径、服务启停等方面。本文以 Linux 系统为例,说明安装部署的流程。
使用 Linux 环境下的安装包 TDengine-enterprise-anode-1.x.x.tar.gz 可进行 Anode 的安装部署工作,命令如下:
```bash
@ -37,7 +36,7 @@ systemctl status taosanoded
|/usr/local/taos/taosanode/bin|可执行文件目录|
|/usr/local/taos/taosanode/resource|资源文件目录,链接到文件夹 /var/lib/taos/taosanode/resource/|
|/usr/local/taos/taosanode/lib|库文件目录|
|/var/lib/taos/taosanode/model/|模型文件目录,链接到文件夹 /var/lib/taos/taosanode/model|
|/usr/local/taos/taosanode/model/|模型文件目录,链接到文件夹 /var/lib/taos/taosanode/model|
|/var/log/taos/taosanode/|日志文件目录|
|/etc/taos/taosanode.ini|配置文件|
@ -64,7 +63,7 @@ pidfile = /usr/local/taos/taosanode/taosanode.pid
# conflict with systemctl, so do NOT uncomment this
# daemonize = /var/log/taos/taosanode/taosanode.log
# log directory
# uWSGI log files
logto = /var/log/taos/taosanode/taosanode.log
# wWSGI monitor port
@ -74,7 +73,7 @@ stats = 127.0.0.1:8387
virtualenv = /usr/local/taos/taosanode/venv/
[taosanode]
# default app log file
# default taosanode log file
app-log = /var/log/taos/taosanode/taosanode.app.log
# model storage directory

View File

@ -12,7 +12,7 @@ import wndata from './pic/white-noise-data.png'
<img src={activity} width="560" alt="预处理流程" />
TDgpt 首先对输入数据进行白噪声检查White Noise Data check, 检查通过以后针对预测分析,还要进行输入(历史)数据的重采样和时间戳对齐处理(异常检测跳过数据重采样和时间戳对齐步骤)。
预处理完成以后,再进行预测或异常检测操作。预处理过程部署于预测或异常检测处理逻辑的一部分。
预处理完成以后,再进行预测或异常检测操作。预处理过程不属于预测或异常检测处理逻辑的一部分。
### 白噪声检查

View File

@ -14,7 +14,7 @@ description: 预测算法
```bash
taos> select * from foo;
ts | k |
ts | i32 |
========================================
2020-01-01 00:00:12.681 | 13 |
2020-01-01 00:00:13.727 | 14 |
@ -42,7 +42,7 @@ algo=expr1
```
1. `column_expr`:预测的时序数据列。与异常检测相同,只支持数值类型列输入。
2. `options`异常检测函数的参数,使用规则与 anomaly_window 相同。预测支持 `conf`, `every`, `rows`, `start`, `rows` 几个控制参数,其含义如下:
2. `options`预测函数的参数。字符串类型,其中使用 K=V 方式调用算法及相关参数。采用逗号分隔的 K=V 字符串表示,其中的字符串不需要使用单引号、双引号、或转义号等符号,不能使用中文及其他宽字符。预测支持 `conf`, `every`, `rows`, `start`, `rows` 几个控制参数,其含义如下:
### 参数说明

View File

@ -34,7 +34,8 @@ return {
```python
import numpy as np
from service import AbstractForecastService
from taosanalytics.service import AbstractForecastService
# 算法实现类名称 需要以下划线 "_" 开始,并以 Service 结束
class _MyForecastService(AbstractForecastService):
@ -51,12 +52,12 @@ class _MyForecastService(AbstractForecastService):
super().__init__()
def execute(self):
""" 算法逻辑的核心实现"""
""" 算法逻辑的核心实现"""
res = []
"""这个预测算法固定返回 1 作为预测值,预测值的数量是用户通过 self.fc_rows 指定"""
ts_list = [self.start_ts + i * self.time_step for i in range(self.fc_rows)]
res.app(ts_list) # 设置预测结果时间戳列
res.append(ts_list) # 设置预测结果时间戳列
"""生成全部为 1 的预测结果 """
res_list = [1] * self.fc_rows
@ -64,18 +65,18 @@ class _MyForecastService(AbstractForecastService):
"""检查用户输入,是否要求返回预测置信区间上下界"""
if self.return_conf:
"""对于没有计算预测置信区间上下界的算法,直接返回预测值作为上下界即可"""
bound_list = [1] * self.fc_rows
res.append(bound_list) # 预测结果置信区间下界
res.append(bound_list) # 预测结果执行区间上界
"""对于没有计算预测置信区间上下界的算法,直接返回预测值作为上下界即可"""
bound_list = [1] * self.fc_rows
res.append(bound_list) # 预测结果置信区间下界
res.append(bound_list) # 预测结果执行区间上界
"""返回结果"""
return { "res": res, "mse": 0}
return {"res": res, "mse": 0}
def set_params(self, params):
"""该算法无需任何输入参数,直接重载父类该函数,不处理算法参数设置逻辑"""
pass
"""该算法无需任何输入参数,直接调用父类函数,不处理算法参数设置逻辑"""
return super().set_params(params)
```
将该文件保存在 `./taosanalytics/algo/fc/` 目录下,然后重启 taosanode 服务。在 TDengine 命令行接口中执行 `SHOW ANODES FULL` 能够看到新加入的算法。应用就可以通过 SQL 语句调用该预测算法。

View File

@ -16,7 +16,7 @@ sidebar_label: "异常检测"
```python
import numpy as np
from service import AbstractAnomalyDetectionService
from taosanalytics.service import AbstractAnomalyDetectionService
# 算法实现类名称 需要以下划线 "_" 开始,并以 Service 结束
class _MyAnomalyDetectionService(AbstractAnomalyDetectionService):

View File

@ -19,24 +19,25 @@ Anode的主要目录结构如下图所示
```bash
.
├── bin
├── cfg
├── model
│   └── ad_autoencoder
├── release
├── script
└── taosanalytics
├── algo
│   ├── ad
│   └── fc
├── misc
└── test
├── lib
│   └── taosanalytics
│   ├── algo
│   │   ├── ad
│   │   └── fc
│   ├── misc
│   └── test
├── log -> /var/log/taos/taosanode
├── model -> /var/lib/taos/taosanode/model
└── venv -> /var/lib/taos/taosanode/venv
```
|目录|说明|
|---|---|
|taosanalytics| 源代码目录,其下包含了算法具体保存目录 algo放置杂项目录 misc单元测试和集成测试目录 test。 algo 目录下 ad 保存异常检测算法代码fc 目录保存预测算法代码|
|script|是安装脚本和发布脚本放置目录|
|venv| Python 虚拟环境|
|model|放置针对数据集完成的训练模型|
|cfg|配置文件目录|
@ -63,7 +64,8 @@ Anode采用算法自动加载模式因此只识别符合命名约定的 Pytho
```SQL
--- algo 后面的参数 name 即为类属性 `name`
SELECT COUNT(*) FROM foo ANOMALY_WINDOW(col_name, 'algo=name')
SELECT COUNT(*)
FROM foo ANOMALY_WINDOW(col_name, 'algo=name')
```
## 添加具有模型的分析算法
@ -76,19 +78,10 @@ SELECT COUNT(*) FROM foo ANOMALY_WINDOW(col_name, 'algo=name')
```bash
.
├── cfg
├── model
│   └── ad_autoencoder
│   ├── ad_autoencoder_foo.dat
│   └── ad_autoencoder_foo.info
├── release
├── script
└── taosanalytics
├── algo
│   ├── ad
│   └── fc
├── misc
└── test
└── model
└── ad_autoencoder
├── ad_autoencoder_foo.dat
└── ad_autoencoder_foo.info
```

View File

@ -18,6 +18,7 @@ TDengine 面向多种写入场景而很多写入场景下TDengine 的存
```SQL
COMPACT DATABASE db_name [start with 'XXXX'] [end with 'YYYY']
COMPACT [db_name.]VGROUPS IN (vgroup_id1, vgroup_id2, ...) [start with 'XXXX'] [end with 'YYYY']
SHOW COMPACTS [compact_id]
KILL COMPACT compact_id
```
@ -25,6 +26,7 @@ KILL COMPACT compact_id
### 效果
- 扫描并压缩指定的 DB 中所有 VGROUP 中 VNODE 的所有数据文件
- 扫描并压缩 DB 中指定的 VGROUP 列表中 VNODE 的所有数据文件, 若 db_name 为空,则默认为当前数据库
- COMPCAT 会删除被删除数据以及被删除的表的数据
- COMPACT 会合并多个 STT 文件
- 可通过 start with 关键字指定 COMPACT 数据的起始时间

View File

@ -26,68 +26,67 @@ taosd 命令行参数如下
:::
### 连接相关
|参数名称|支持版本|参数含义|
|-----------------------|-------------------------|------------|
|firstEp | |taosd 启动时,主动连接的集群中首个 dnode 的 end point默认值 localhost:6030|
|secondEp | |taosd 启动时,如果 firstEp 连接不上,尝试连接集群中第二个 dnode 的 endpoint无默认值|
|fqdn | |taosd 监听的服务地址,默认为所在服务器上配置的第一个 hostname|
|serverPort | |taosd 监听的端口,默认值 6030|
|compressMsgSize | |是否对 RPC 消息进行压缩;-1所有消息都不压缩0所有消息都压缩N (N>0):只有大于 N 个字节的消息才压缩;默认值 -1|
|shellActivityTimer | |客户端向 mnode 发送心跳的时长,单位为秒,取值范围 1-120默认值 3 |
|numOfRpcSessions | |RPC 支持的最大连接数,取值范围 100-100000默认值 30000|
|numOfRpcThreads | |RPC 收发数据线程数目取值范围1-50,默认值为 CPU 核数的一半|
|numOfTaskQueueThreads | |客户端处理 RPC 消息的线程数取值, 范围4-16,默认值为 CPU 核数的一半|
|rpcQueueMemoryAllowed | |dnode允许的已经收到的RPC消息占用的内存最大值单位 bytes取值范围 104857600-INT64_MAX默认值为服务器内存的 1/10 |
|resolveFQDNRetryTime | 3.x 之后取消 |FQDN 解析失败时的重试次数|
|timeToGetAvailableConn | 3.3.4.x之后取消 |获得可用连接的最长等待时间,取值范围 10-50000000单位为毫秒默认值 500000|
|maxShellConns | 3.x 后取消 |允许创建的最大链接数|
|maxRetryWaitTime | |重连最大超时时间, 默认值是 10s|
|shareConnLimit |3.3.4.0 新增 |一个链接可以共享的请求的数目,取值范围 1-512默认值 10|
|readTimeout |3.3.4.0 新增 |单个请求最小超时时间,取值范围 64-604800单位为秒默认值 900|
|参数名称|支持版本|动态修改|参数含义|
|-----------------------|-------------------------|-------------------------|------------|
|firstEp | |不支持动态修改 |taosd 启动时,主动连接的集群中首个 dnode 的 end point默认值 localhost:6030|
|secondEp | |不支持动态修改 |taosd 启动时,如果 firstEp 连接不上,尝试连接集群中第二个 dnode 的 endpoint无默认值|
|fqdn | |不支持动态修改 |taosd 监听的服务地址,默认为所在服务器上配置的第一个 hostname|
|serverPort | |不支持动态修改 |taosd 监听的端口,默认值 6030|
|compressMsgSize | |支持动态修改 重启生效 |是否对 RPC 消息进行压缩;-1所有消息都不压缩0所有消息都压缩N (N>0):只有大于 N 个字节的消息才压缩;默认值 -1|
|shellActivityTimer | |支持动态修改 立即生效 |客户端向 mnode 发送心跳的时长,单位为秒,取值范围 1-120默认值 3 |
|numOfRpcSessions | |支持动态修改 重启生效 |RPC 支持的最大连接数,取值范围 100-100000默认值 30000|
|numOfRpcThreads | |支持动态修改 重启生效 |RPC 收发数据线程数目取值范围1-50,默认值为 CPU 核数的一半|
|numOfTaskQueueThreads | |支持动态修改 重启生效 |客户端处理 RPC 消息的线程数取值, 范围4-16,默认值为 CPU 核数的一半|
|rpcQueueMemoryAllowed | |支持动态修改 立即生效 |dnode允许的已经收到的RPC消息占用的内存最大值单位 bytes取值范围 104857600-INT64_MAX默认值为服务器内存的 1/10 |
|resolveFQDNRetryTime | 3.x 之后取消 |不支持动态修改 |FQDN 解析失败时的重试次数|
|timeToGetAvailableConn | 3.3.4.x之后取消 |支持动态修改 重启生效 |获得可用连接的最长等待时间,取值范围 10-50000000单位为毫秒默认值 500000|
|maxShellConns | 3.x 后取消 |支持动态修改 重启生效 |允许创建的最大链接数|
|maxRetryWaitTime | |支持动态修改 重启生效 |重连最大超时时间, 默认值是 10s|
|shareConnLimit |3.3.4.0 新增 |支持动态修改 重启生效 |一个链接可以共享的请求的数目,取值范围 1-512默认值 10|
|readTimeout |3.3.4.0 新增 |支持动态修改 重启生效 |单个请求最小超时时间,取值范围 64-604800单位为秒默认值 900|
### 监控相关
|参数名称|支持版本|参数含义|
|-----------------------|----------|-|
|monitor | |是否收集监控数据并上报0关闭1:打开;默认值 0|
|monitorFqdn | |taosKeeper 服务所在服务器的 FQDN默认值 无|
|monitorPort | |taosKeeper 服务所监听的端口号,默认值 6043|
|monitorInterval | |监控数据库记录系统参数CPU/内存)的时间间隔,单位是秒,取值范围 1-200000 ,默认值 30|
|monitorMaxLogs | |缓存的待上报日志条数|
|monitorComp | |是否采用压缩方式上报监控日志时|
|monitorLogProtocol | |是否打印监控日志|
|monitorForceV2 | |是否使用 V2 版本协议上报|
|telemetryReporting | |是否上传 telemetry0不上传1上传默认值 1|
|telemetryServer | |telemetry 服务器地址|
|telemetryPort | |telemetry 服务器端口编号|
|telemetryInterval | |telemetry 上传时间间隔,单位为秒,默认 43200|
|crashReporting | |是否上传 crash 信息0不上传1上传默认值 1|
|参数名称|支持版本|动态修改|参数含义|
|-----------------------|----------|-------------------------|-|
|monitor | |支持动态修改 立即生效 |是否收集监控数据并上报0关闭1:打开;默认值 0|
|monitorFqdn | |支持动态修改 重启生效 |taosKeeper 服务所在服务器的 FQDN默认值 无|
|monitorPort | |支持动态修改 重启生效 |taosKeeper 服务所监听的端口号,默认值 6043|
|monitorInterval | |支持动态修改 立即生效 |监控数据库记录系统参数CPU/内存)的时间间隔,单位是秒,取值范围 1-200000 ,默认值 30|
|monitorMaxLogs | |支持动态修改 立即生效 |缓存的待上报日志条数|
|monitorComp | |支持动态修改 重启生效 |是否采用压缩方式上报监控日志时|
|monitorLogProtocol | |支持动态修改 立即生效 |是否打印监控日志|
|monitorForceV2 | |支持动态修改 立即生效 |是否使用 V2 版本协议上报|
|telemetryReporting | |支持动态修改 立即生效 |是否上传 telemetry0不上传1上传默认值 1|
|telemetryServer | |不支持动态修改 |telemetry 服务器地址|
|telemetryPort | |不支持动态修改 |telemetry 服务器端口编号|
|telemetryInterval | |支持动态修改 立即生效 |telemetry 上传时间间隔,单位为秒,默认 43200|
|crashReporting | |支持动态修改 立即生效 |是否上传 crash 信息0不上传1上传默认值 1|
### 查询相关
|参数名称|支持版本|参数含义|
|------------------------|----------|-|
|countAlwaysReturnValue | |count/hyperloglog 函数在输入数据为空或者 NULL 的情况下是否返回值0返回空行1返回默认值 1该参数设置为 1 时,如果查询中含有 INTERVAL 子句或者该查询使用了 TSMA 时,且相应的组或窗口内数据为空或者 NULL对应的组或窗口将不返回查询结果注意此参数客户端和服务端值应保持一致|
|tagFilterCache | |是否缓存标签过滤结果|
|maxNumOfDistinctRes | |允许返回的 distinct 结果最大行数,默认值 10 万,最大允许值 1 亿|
|queryBufferSize | |暂不生效|
|queryRspPolicy | |查询响应策略|
|queryUseMemoryPool | |查询是否使用内存池管理内存默认值1打开; 0: 关闭1: 打开|
|minReservedMemorySize | |最小预留的系统可用内存数量除预留外的内存都可以被用于查询单位MB默认预留大小为系统物理内存的 20%,取值范围 1024 - 1000000000|
|singleQueryMaxMemorySize| |单个查询在单个节点(dnode)上可以使用的内存上限超过该上限将返回错误单位MB默认值0无上限取值范围 0 - 1000000000|
|filterScalarMode | |强制使用标量过滤模式0关闭1开启默认值 0|
|queryPlannerTrace | |内部参数,查询计划是否输出详细日志|
|queryNodeChunkSize | |内部参数,查询计划的块大小|
|queryUseNodeAllocator | |内部参数,查询计划的分配方法|
|queryMaxConcurrentTables| |内部参数,查询计划的并发数目|
|queryRsmaTolerance | |内部参数,用于判定查询哪一级 rsma 数据时的容忍时间,单位为毫秒|
|enableQueryHb | |内部参数,是否发送查询心跳消息|
|pqSortMemThreshold | |内部参数,排序使用的内存阈值|
|参数名称|支持版本|动态修改|参数含义|
|------------------------|----------|-------------------------|-|
|countAlwaysReturnValue | |支持动态修改 立即生效 |count/hyperloglog 函数在输入数据为空或者 NULL 的情况下是否返回值0返回空行1返回默认值 1该参数设置为 1 时,如果查询中含有 INTERVAL 子句或者该查询使用了 TSMA 时,且相应的组或窗口内数据为空或者 NULL对应的组或窗口将不返回查询结果注意此参数客户端和服务端值应保持一致|
|tagFilterCache | |不支持动态修改 |是否缓存标签过滤结果|
|queryBufferSize | |支持动态修改 重启生效 |暂不生效|
|queryRspPolicy | |支持动态修改 立即生效 |查询响应策略|
|queryUseMemoryPool | |不支持动态修改 |查询是否使用内存池管理内存默认值1打开; 0: 关闭1: 打开|
|minReservedMemorySize | |不支持动态修改 |最小预留的系统可用内存数量除预留外的内存都可以被用于查询单位MB默认预留大小为系统物理内存的 20%,取值范围 1024 - 1000000000|
|singleQueryMaxMemorySize| |不支持动态修改 |单个查询在单个节点(dnode)上可以使用的内存上限超过该上限将返回错误单位MB默认值0无上限取值范围 0 - 1000000000|
|filterScalarMode | |不支持动态修改 |强制使用标量过滤模式0关闭1开启默认值 0|
|queryPlannerTrace | |支持动态修改 立即生效 |内部参数,查询计划是否输出详细日志|
|queryNodeChunkSize | |支持动态修改 立即生效 |内部参数,查询计划的块大小|
|queryUseNodeAllocator | |支持动态修改 立即生效 |内部参数,查询计划的分配方法|
|queryMaxConcurrentTables| |不支持动态修改 |内部参数,查询计划的并发数目|
|queryRsmaTolerance | |不支持动态修改 |内部参数,用于判定查询哪一级 rsma 数据时的容忍时间,单位为毫秒|
|enableQueryHb | |支持动态修改 立即生效 |内部参数,是否发送查询心跳消息|
|pqSortMemThreshold | |不支持动态修改 |内部参数,排序使用的内存阈值|
### 区域相关
|参数名称|支持版本|参数含义|
|-----------------|----------|-|
|timezone | |时区;缺省从系统中动态获取当前的时区设置|
|locale | |系统区位信息及编码格式,缺省从系统中获取|
|charset | |字符集编码,缺省从系统中获取|
|参数名称|支持版本|动态修改|参数含义|
|-----------------|----------|-------------------------|-|
|timezone | |不支持动态修改 |时区;缺省从系统中动态获取当前的时区设置|
|locale | |不支持动态修改 |系统区位信息及编码格式,缺省从系统中获取|
|charset | |不支持动态修改 |字符集编码,缺省从系统中获取|
:::info
1. 为应对多时区的数据写入和查询问题TDengine 采用 Unix 时间戳(Unix Timestamp)来记录和存储时间戳。Unix 时间戳的特点决定了任一时刻不论在任何时区产生的时间戳均一致。需要注意的是Unix 时间戳是在客户端完成转换和记录。为了确保客户端其他形式的时间转换为正确的 Unix 时间戳,需要设置正确的时区。
@ -165,159 +164,161 @@ charset 的有效值是 UTF-8。
:::
### 存储相关
|参数名称|支持版本|参数含义|
|--------------------|----------|-|
|dataDir | |数据文件目录,所有的数据文件都将写入该目录,默认值 /var/lib/taos|
|tempDir | |指定所有系统运行过程中的临时文件生成的目录,默认值 /tmp|
|minimalDataDirGB | |dataDir 指定的时序数据存储目录所需要保留的最小空间,单位 GB默认值 2|
|minimalTmpDirGB | |tempDir 所指定的临时文件目录所需要保留的最小空间,单位 GB默认值 1|
|minDiskFreeSize |3.1.1.0 后|当某块磁盘上的可用空间小于等于这个阈值时,该磁盘将不再被选择用于生成新的数据文件,单位为字节,取值范围 52428800-1073741824默认值为 52428800企业版参数|
|s3MigrateIntervalSec|3.3.4.3 后|本地数据文件自动上传 S3 的触发周期单位为秒。最小值600最大值100000。默认值 3600企业版参数|
|s3MigrateEnabled |3.3.4.3 后|是否自动进行 S3 迁移,默认值为 0表示关闭自动 S3 迁移,可配置为 1企业版参数|
|s3Accesskey |3.3.4.3 后|冒号分隔的用户 SecretId:SecretKey例如 AKIDsQmwsfKxTo2A6nGVXZN0UlofKn6JRRSJ:lIdoy99ygEacU7iHfogaN2Xq0yumSm1E企业版参数|
|s3Endpoint |3.3.4.3 后|用户所在地域的 COS 服务域名,支持 http 和 httpsbucket 的区域需要与 endpoint 保持一致,否则无法访问;企业版参数|
|s3BucketName |3.3.4.3 后|存储桶名称,减号后面是用户注册 COS 服务的 AppId其中 AppId 是 COS 特有AWS 和阿里云都没有,配置时需要作为 bucket name 的一部分,使用减号分隔;参数值均为字符串类型,但不需要引号;例如 test0711-1309024725企业版参数|
|s3PageCacheSize |3.3.4.3 后|S3 page cache 缓存页数目,取值范围 4-1048576单位为页默认值 4096企业版参数|
|s3UploadDelaySec |3.3.4.3 后|data 文件持续多长时间不再变动后上传至 S3取值范围 1-2592000 (30天单位为秒默认值 60企业版参数|
|cacheLazyLoadThreshold| |内部参数,缓存的装载策略|
|参数名称|支持版本|动态修改|参数含义|
|--------------------|----------|-------------------------|-|
|dataDir | |不支持动态修改 |数据文件目录,所有的数据文件都将写入该目录,默认值 /var/lib/taos|
|diskIDCheckEnabled | |不支持动态修改 |在 3.3.4.3 后,在重启 dnode 时增加了检查 dataDir 所在磁盘 id 是否发生改变0:进行检查1:不进行检查默认值1|
|tempDir | |不支持动态修改 |指定所有系统运行过程中的临时文件生成的目录,默认值 /tmp|
|minimalDataDirGB | |不支持动态修改 |dataDir 指定的时序数据存储目录所需要保留的最小空间,单位 GB默认值 2|
|minimalTmpDirGB | |不支持动态修改 |tempDir 所指定的临时文件目录所需要保留的最小空间,单位 GB默认值 1|
|minDiskFreeSize |3.1.1.0 后|支持动态修改 立即生效 |当某块磁盘上的可用空间小于等于这个阈值时,该磁盘将不再被选择用于生成新的数据文件,单位为字节,取值范围 52428800-1073741824默认值为 52428800企业版参数|
|s3MigrateIntervalSec|3.3.4.3 后|支持动态修改 立即生效 |本地数据文件自动上传 S3 的触发周期单位为秒。最小值600最大值100000。默认值 3600企业版参数|
|s3MigrateEnabled |3.3.4.3 后|支持动态修改 立即生效 |是否自动进行 S3 迁移,默认值为 0表示关闭自动 S3 迁移,可配置为 1企业版参数|
|s3Accesskey |3.3.4.3 后|支持动态修改 重启生效 |冒号分隔的用户 SecretId:SecretKey例如 AKIDsQmwsfKxTo2A6nGVXZN0UlofKn6JRRSJ:lIdoy99ygEacU7iHfogaN2Xq0yumSm1E企业版参数|
|s3Endpoint |3.3.4.3 后|支持动态修改 重启生效 |用户所在地域的 COS 服务域名,支持 http 和 httpsbucket 的区域需要与 endpoint 保持一致,否则无法访问;企业版参数|
|s3BucketName |3.3.4.3 后|支持动态修改 重启生效 |存储桶名称,减号后面是用户注册 COS 服务的 AppId其中 AppId 是 COS 特有AWS 和阿里云都没有,配置时需要作为 bucket name 的一部分,使用减号分隔;参数值均为字符串类型,但不需要引号;例如 test0711-1309024725企业版参数|
|s3PageCacheSize |3.3.4.3 后|支持动态修改 重启生效 |S3 page cache 缓存页数目,取值范围 4-1048576单位为页默认值 4096企业版参数|
|s3UploadDelaySec |3.3.4.3 后|支持动态修改 立即生效 |data 文件持续多长时间不再变动后上传至 S3取值范围 1-2592000 (30天单位为秒默认值 60企业版参数|
|cacheLazyLoadThreshold| |支持动态修改 立即生效 |内部参数,缓存的装载策略|
### 集群相关
|参数名称|支持版本|参数含义|
|--------------------------|----------|-|
|supportVnodes | |dnode 支持的最大 vnode 数目,取值范围 0-4096默认值 CPU 核数的 2 倍 + 5|
|numOfCommitThreads | |落盘线程的最大数量,取值范围 0-1024默认值为 4|
|numOfMnodeReadThreads | |mnode 的 Read 线程数目,取值范围 0-1024默认值为 CPU 核数的四分之一(不超过 4|
|numOfVnodeQueryThreads | |vnode 的 Query 线程数目,取值范围 0-1024默认值为 CPU 核数的两倍(不超过 16|
|numOfVnodeFetchThreads | |vnode 的 Fetch 线程数目,取值范围 0-1024默认值为 CPU 核数的四分之一(不超过 4|
|numOfVnodeRsmaThreads | |vnode 的 Rsma 线程数目,取值范围 0-1024默认值为 CPU 核数的四分之一(不超过 4|
|numOfQnodeQueryThreads | |qnode 的 Query 线程数目,取值范围 0-1024默认值为 CPU 核数的两倍(不超过 16|
|numOfSnodeSharedThreads | |snode 的共享线程数目,取值范围 0-1024默认值为 CPU 核数的四分之一(不小于 2不超过 4|
|numOfSnodeUniqueThreads | |snode 的独占线程数目,取值范围 0-1024默认值为 CPU 核数的四分之一(不小于 2不超过 4|
|ratioOfVnodeStreamThreads | |流计算使用 vnode 线程的比例,取值范围 0.01-4默认值 4|
|ttlUnit | |ttl 参数的单位,取值范围 1-31572500单位为秒默认值 86400|
|ttlPushInterval | |ttl 检测超时频率,取值范围 1-100000单位为秒默认值 10|
|ttlChangeOnWrite | |ttl 到期时间是否伴随表的修改操作改变0不改变1改变默认值为 0|
|ttlBatchDropNum | |ttl 一批删除子表的数目,最小值为 0默认值 10000|
|retentionSpeedLimitMB | |数据在不同级别硬盘上迁移时的速度限制,取值范围 0-1024单位 MB默认值 0表示不限制|
|maxTsmaNum | |集群内可创建的TSMA个数取值范围 0-3默认值 3|
|tmqMaxTopicNum | |订阅最多可建立的 topic 数量;取值范围 1-10000默认值为 20|
|tmqRowSize | |订阅数据块的最大记录条数,取值范围 1-1000000默认值 4096|
|audit | |审计功能开关;企业版参数|
|auditInterval | |审计数据上报的时间间隔;企业版参数|
|auditCreateTable | |是否针对创建子表开启申计功能;企业版参数|
|encryptAlgorithm | |数据加密算法;企业版参数|
|encryptScope | |加密范围;企业版参数|
|enableWhiteList | |白名单功能开关;企业版参数|
|syncLogBufferMemoryAllowed| |一个 dnode 允许的 sync 日志缓存消息占用的内存最大值,单位 bytes取值范围 104857600-INT64_MAX默认值 服务器内存的 1/103.1.3.2/3.3.2.13 版本开始生效 |
|syncElectInterval | |内部参数,用于同步模块调试|
|syncHeartbeatInterval | |内部参数,用于同步模块调试|
|syncHeartbeatTimeout | |内部参数,用于同步模块调试|
|syncSnapReplMaxWaitN | |内部参数,用于同步模块调试|
|syncSnapReplMaxWaitN | |内部参数,用于同步模块调试|
|arbHeartBeatIntervalSec | |内部参数,用于同步模块调试|
|arbCheckSyncIntervalSec | |内部参数,用于同步模块调试|
|arbSetAssignedTimeoutSec | |内部参数,用于同步模块调试|
|mndSdbWriteDelta | |内部参数,用于 mnode 模块调试|
|mndLogRetention | |内部参数,用于 mnode 模块调试|
|skipGrant | |内部参数,用于授权检查|
|trimVDbIntervalSec | |内部参数,用于删除过期数据|
|ttlFlushThreshold | |内部参数ttl 定时器的频率|
|compactPullupInterval | |内部参数,数据重整定时器的频率|
|walFsyncDataSizeLimit | |内部参数WAL 进行 FSYNC 的阈值|
|transPullupInterval | |内部参数mnode 执行事务的重试间隔|
|mqRebalanceInterval | |内部参数,消费者再平衡的时间间隔|
|uptimeInterval | |内部参数,用于记录系统启动时间|
|timeseriesThreshold | |内部参数,用于统计用量|
|udf | |是否启动 UDF 服务0不启动1启动默认值为 0 |
|udfdResFuncs | |内部参数,用于 UDF 结果集设置|
|udfdLdLibPath | |内部参数,表示 UDF 装载的库路径|
|参数名称|支持版本|动态修改|参数含义|
|--------------------------|----------|-------------------------|-|
|supportVnodes | |支持动态修改 立即生效 |dnode 支持的最大 vnode 数目,取值范围 0-4096默认值 CPU 核数的 2 倍 + 5|
|numOfCommitThreads | |支持动态修改 重启生效 |落盘线程的最大数量,取值范围 0-1024默认值为 4|
|numOfMnodeReadThreads | |支持动态修改 重启生效 |mnode 的 Read 线程数目,取值范围 0-1024默认值为 CPU 核数的四分之一(不超过 4|
|numOfVnodeQueryThreads | |支持动态修改 重启生效 |vnode 的 Query 线程数目,取值范围 0-1024默认值为 CPU 核数的两倍(不超过 16|
|numOfVnodeFetchThreads | |支持动态修改 重启生效 |vnode 的 Fetch 线程数目,取值范围 0-1024默认值为 CPU 核数的四分之一(不超过 4|
|numOfVnodeRsmaThreads | |支持动态修改 重启生效 |vnode 的 Rsma 线程数目,取值范围 0-1024默认值为 CPU 核数的四分之一(不超过 4|
|numOfQnodeQueryThreads | |支持动态修改 重启生效 |qnode 的 Query 线程数目,取值范围 0-1024默认值为 CPU 核数的两倍(不超过 16|
|numOfSnodeSharedThreads | |支持动态修改 重启生效 |snode 的共享线程数目,取值范围 0-1024默认值为 CPU 核数的四分之一(不小于 2不超过 4|
|numOfSnodeUniqueThreads | |支持动态修改 重启生效 |snode 的独占线程数目,取值范围 0-1024默认值为 CPU 核数的四分之一(不小于 2不超过 4|
|ratioOfVnodeStreamThreads | |支持动态修改 重启生效 |流计算使用 vnode 线程的比例,取值范围 0.01-4默认值 4|
|ttlUnit | |不支持动态修改 |ttl 参数的单位,取值范围 1-31572500单位为秒默认值 86400|
|ttlPushInterval | |支持动态修改 立即生效 |ttl 检测超时频率,取值范围 1-100000单位为秒默认值 10|
|ttlChangeOnWrite | |支持动态修改 立即生效 |ttl 到期时间是否伴随表的修改操作改变0不改变1改变默认值为 0|
|ttlBatchDropNum | |支持动态修改 立即生效 |ttl 一批删除子表的数目,最小值为 0默认值 10000|
|retentionSpeedLimitMB | |支持动态修改 立即生效 |数据在不同级别硬盘上迁移时的速度限制,取值范围 0-1024单位 MB默认值 0表示不限制|
|maxTsmaNum | |支持动态修改 立即生效 |集群内可创建的TSMA个数取值范围 0-3默认值 3|
|tmqMaxTopicNum | |支持动态修改 立即生效 |订阅最多可建立的 topic 数量;取值范围 1-10000默认值为 20|
|tmqRowSize | |支持动态修改 立即生效 |订阅数据块的最大记录条数,取值范围 1-1000000默认值 4096|
|audit | |支持动态修改 立即生效 |审计功能开关;企业版参数|
|auditInterval | |支持动态修改 立即生效 |审计数据上报的时间间隔;企业版参数|
|auditCreateTable | |支持动态修改 立即生效 |是否针对创建子表开启申计功能;企业版参数|
|encryptAlgorithm | |不支持动态修改 |数据加密算法;企业版参数|
|encryptScope | |不支持动态修改 |加密范围;企业版参数|
|enableWhiteList | |支持动态修改 立即生效 |白名单功能开关;企业版参数|
|syncLogBufferMemoryAllowed| |支持动态修改 立即生效 |一个 dnode 允许的 sync 日志缓存消息占用的内存最大值,单位 bytes取值范围 104857600-INT64_MAX默认值 服务器内存的 1/103.1.3.2/3.3.2.13 版本开始生效 |
|syncElectInterval | |不支持动态修改 |内部参数,用于同步模块调试|
|syncHeartbeatInterval | |不支持动态修改 |内部参数,用于同步模块调试|
|syncHeartbeatTimeout | |不支持动态修改 |内部参数,用于同步模块调试|
|syncSnapReplMaxWaitN | |支持动态修改 立即生效 |内部参数,用于同步模块调试|
|arbHeartBeatIntervalSec | |支持动态修改 立即生效 |内部参数,用于同步模块调试|
|arbCheckSyncIntervalSec | |支持动态修改 立即生效 |内部参数,用于同步模块调试|
|arbSetAssignedTimeoutSec | |支持动态修改 立即生效 |内部参数,用于同步模块调试|
|mndSdbWriteDelta | |支持动态修改 立即生效 |内部参数,用于 mnode 模块调试|
|mndLogRetention | |支持动态修改 立即生效 |内部参数,用于 mnode 模块调试|
|skipGrant | |不支持动态修改 |内部参数,用于授权检查|
|trimVDbIntervalSec | |支持动态修改 立即生效 |内部参数,用于删除过期数据|
|ttlFlushThreshold | |支持动态修改 立即生效 |内部参数ttl 定时器的频率|
|compactPullupInterval | |支持动态修改 立即生效 |内部参数,数据重整定时器的频率|
|walFsyncDataSizeLimit | |支持动态修改 立即生效 |内部参数WAL 进行 FSYNC 的阈值|
|transPullupInterval | |支持动态修改 立即生效 |内部参数mnode 执行事务的重试间隔|
|mqRebalanceInterval | |支持动态修改 立即生效 |内部参数,消费者再平衡的时间间隔|
|uptimeInterval | |支持动态修改 立即生效 |内部参数,用于记录系统启动时间|
|timeseriesThreshold | |支持动态修改 立即生效 |内部参数,用于统计用量|
|udf | |支持动态修改 重启生效 |是否启动 UDF 服务0不启动1启动默认值为 0 |
|udfdResFuncs | |支持动态修改 重启生效 |内部参数,用于 UDF 结果集设置|
|udfdLdLibPath | |支持动态修改 重启生效 |内部参数,表示 UDF 装载的库路径|
### 流计算参数
|参数名称|支持版本|参数含义|
|-----------------------|----------|-|
|disableStream | |流计算的启动开关|
|streamBufferSize | |控制内存中窗口状态缓存的大小,默认值为 128MB|
|streamAggCnt | |内部参数,并发进行聚合计算的数目|
|checkpointInterval | |内部参数checkponit 同步间隔|
|concurrentCheckpoint | |内部参数,是否并发检查 checkpoint|
|maxStreamBackendCache | |内部参数,流计算使用的最大缓存|
|streamSinkDataRate | |内部参数,用于控制流计算结果的写入速度|
|参数名称|支持版本|动态修改|参数含义|
|-----------------------|-------------------------|----------|-|
|disableStream | |支持动态修改 重启生效 |流计算的启动开关|
|streamBufferSize | |支持动态修改 重启生效 |控制内存中窗口状态缓存的大小,默认值为 128MB|
|streamAggCnt | |不支持动态修改 |内部参数,并发进行聚合计算的数目|
|checkpointInterval | |支持动态修改 重启生效 |内部参数checkponit 同步间隔|
|concurrentCheckpoint | |支持动态修改 立即生效 |内部参数,是否并发检查 checkpoint|
|maxStreamBackendCache | |支持动态修改 立即生效 |内部参数,流计算使用的最大缓存|
|streamSinkDataRate | |支持动态修改 重启生效 |内部参数,用于控制流计算结果的写入速度|
### 日志相关
|参数名称|支持版本|参数含义|
|----------------|----------|-|
|logDir | |日志文件目录,运行日志将写入该目录,默认值 /var/log/taos|
|minimalLogDirGB | |日志文件夹所在磁盘可用空间大小小于该值时,停止写日志,单位 GB默认值 1|
|numOfLogLines | |单个日志文件允许的最大行数,默认值 10,000,000|
|asyncLog | |日志写入模式0同步1异步默认值 1|
|logKeepDays | |日志文件的最长保存时间,单位:天,默认值 0意味着无限保存日志文件不会被重命名也不会有新的日志文件滚动产生但日志文件的内容有可能会不断滚动取决于日志文件大小的设置当设置为大于 0 的值时,当日志文件大小达到设置的上限时会被重命名为 taosdlog.yyy其中 yyy 为日志文件最后修改的时间戳,并滚动产生新的日志文件|
|slowLogThreshold|3.3.3.0 后|慢查询门限值,大于等于门限值认为是慢查询,单位秒,默认值 3 |
|slowLogMaxLen |3.3.3.0 后|慢查询日志最大长度,取值范围 1-16384默认值 4096|
|slowLogScope |3.3.3.0 后|慢查询记录类型,取值范围 ALL/QUERY/INSERT/OTHERS/NONE默认值 QUERY|
|slowLogExceptDb |3.3.3.0 后|指定的数据库不上报慢查询,仅支持配置换一个数据库|
|debugFlag | |运行日志开关131输出错误和警告日志135输出错误、警告和调试日志143输出错误、警告、调试和跟踪日志默认值 131 或 135 (取决于不同模块)|
|tmrDebugFlag | |定时器模块的日志开关,取值范围同上|
|uDebugFlag | |共用功能模块的日志开关,取值范围同上|
|rpcDebugFlag | |rpc 模块的日志开关,取值范围同上|
|qDebugFlag | |query 模块的日志开关,取值范围同上|
|dDebugFlag | |dnode 模块的日志开关,取值范围同上|
|vDebugFlag | |vnode 模块的日志开关,取值范围同上|
|mDebugFlag | |mnode 模块的日志开关,取值范围同上|
|azDebugFlag |3.3.4.3 后|S3 模块的日志开关,取值范围同上|
|sDebugFlag | |sync 模块的日志开关,取值范围同上|
|tsdbDebugFlag | |tsdb 模块的日志开关,取值范围同上|
|tqDebugFlag | |tq 模块的日志开关,取值范围同上|
|fsDebugFlag | |fs 模块的日志开关,取值范围同上|
|udfDebugFlag | |udf 模块的日志开关,取值范围同上|
|smaDebugFlag | |sma 模块的日志开关,取值范围同上|
|idxDebugFlag | |index 模块的日志开关,取值范围同上|
|tdbDebugFlag | |tdb 模块的日志开关,取值范围同上|
|metaDebugFlag | |meta 模块的日志开关,取值范围同上|
|stDebugFlag | |stream 模块的日志开关,取值范围同上|
|sndDebugFlag | |snode 模块的日志开关,取值范围同上|
|参数名称|支持版本|动态修改|参数含义|
|----------------|-------------------------|----------|-|
|logDir | |不支持动态修改 |日志文件目录,运行日志将写入该目录,默认值 /var/log/taos|
|minimalLogDirGB | |不支持动态修改 |日志文件夹所在磁盘可用空间大小小于该值时,停止写日志,单位 GB默认值 1|
|numOfLogLines | |支持动态修改 立即生效 |单个日志文件允许的最大行数,默认值 10,000,000|
|asyncLog | |支持动态修改 立即生效 |日志写入模式0同步1异步默认值 1|
|logKeepDays | |支持动态修改 立即生效 |日志文件的最长保存时间,单位:天,默认值 0意味着无限保存日志文件不会被重命名也不会有新的日志文件滚动产生但日志文件的内容有可能会不断滚动取决于日志文件大小的设置当设置为大于 0 的值时,当日志文件大小达到设置的上限时会被重命名为 taosdlog.yyy其中 yyy 为日志文件最后修改的时间戳,并滚动产生新的日志文件|
|slowLogThreshold|3.3.3.0 后|支持动态修改 立即生效 |慢查询门限值,大于等于门限值认为是慢查询,单位秒,默认值 3 |
|slowLogMaxLen |3.3.3.0 后|支持动态修改 立即生效 |慢查询日志最大长度,取值范围 1-16384默认值 4096|
|slowLogScope |3.3.3.0 后|支持动态修改 立即生效 |慢查询记录类型,取值范围 ALL/QUERY/INSERT/OTHERS/NONE默认值 QUERY|
|slowLogExceptDb |3.3.3.0 后|支持动态修改 立即生效 |指定的数据库不上报慢查询,仅支持配置换一个数据库|
|debugFlag | |支持动态修改 立即生效 |运行日志开关131输出错误和警告日志135输出错误、警告和调试日志143输出错误、警告、调试和跟踪日志默认值 131 或 135 (取决于不同模块)|
|tmrDebugFlag | |支持动态修改 立即生效 |定时器模块的日志开关,取值范围同上|
|uDebugFlag | |支持动态修改 立即生效 |共用功能模块的日志开关,取值范围同上|
|rpcDebugFlag | |支持动态修改 立即生效 |rpc 模块的日志开关,取值范围同上|
|qDebugFlag | |支持动态修改 立即生效 |query 模块的日志开关,取值范围同上|
|dDebugFlag | |支持动态修改 立即生效 |dnode 模块的日志开关,取值范围同上|
|vDebugFlag | |支持动态修改 立即生效 |vnode 模块的日志开关,取值范围同上|
|mDebugFlag | |支持动态修改 立即生效 |mnode 模块的日志开关,取值范围同上|
|azDebugFlag |3.3.4.3 后|支持动态修改 立即生效 |S3 模块的日志开关,取值范围同上|
|sDebugFlag | |支持动态修改 立即生效 |sync 模块的日志开关,取值范围同上|
|tsdbDebugFlag | |支持动态修改 立即生效 |tsdb 模块的日志开关,取值范围同上|
|tqDebugFlag | |支持动态修改 立即生效 |tq 模块的日志开关,取值范围同上|
|fsDebugFlag | |支持动态修改 立即生效 |fs 模块的日志开关,取值范围同上|
|udfDebugFlag | |支持动态修改 立即生效 |udf 模块的日志开关,取值范围同上|
|smaDebugFlag | |支持动态修改 立即生效 |sma 模块的日志开关,取值范围同上|
|idxDebugFlag | |支持动态修改 立即生效 |index 模块的日志开关,取值范围同上|
|tdbDebugFlag | |支持动态修改 立即生效 |tdb 模块的日志开关,取值范围同上|
|metaDebugFlag | |支持动态修改 立即生效 |meta 模块的日志开关,取值范围同上|
|stDebugFlag | |支持动态修改 立即生效 |stream 模块的日志开关,取值范围同上|
|sndDebugFlag | |支持动态修改 立即生效 |snode 模块的日志开关,取值范围同上|
### 调试相关
|参数名称|支持版本|参数含义|
|--------------------|----------|-|
|enableCoreFile | |crash 时是否生成 core 文件0不生成1生成默认值 1|
|configDir | |配置文件所在目录|
|scriptDir | |内部测试工具的脚本目录|
|assert | |断言控制开关,默认值 0|
|randErrorChance | |内部参数,用于随机失败测试|
|randErrorDivisor | |内部参数,用于随机失败测试|
|randErrorScope | |内部参数,用于随机失败测试|
|safetyCheckLevel | |内部参数,用于随机失败测试|
|experimental | |内部参数,用于一些实验特性|
|simdEnable |3.3.4.3 后|内部参数,用于测试 SIMD 加速|
|AVX512Enable |3.3.4.3 后|内部参数,用于测试 AVX512 加速|
|rsyncPort | |内部参数,用于调试流计算|
|snodeAddress | |内部参数,用于调试流计算|
|checkpointBackupDir | |内部参数,用于恢复 snode 数据|
|enableAuditDelete | |内部参数,用于测试审计功能|
|slowLogThresholdTest| |内部参数,用于测试慢日志|
|bypassFlag |3.3.4.5 后|内部参数用于短路测试0正常写入1写入消息在 taos 客户端发送 RPC 消息前返回2写入消息在 taosd 服务端收到 RPC 消息后返回4写入消息在 taosd 服务端写入内存缓存前返回8写入消息在 taosd 服务端数据落盘前返回;默认值 0|
|参数名称|支持版本|动态修改|参数含义|
|--------------------|-------------------------|----------|-|
|enableCoreFile | |支持动态修改 立即生效 |crash 时是否生成 core 文件0不生成1生成默认值 1|
|configDir | |不支持动态修改 |配置文件所在目录|
|forceReadConfig | |不支持动态修改 |强制使用配置文件中的参数0:使用持久化的配置参数1:使用配置文件中的配置参数;默认值 0|
|scriptDir | |不支持动态修改 |内部测试工具的脚本目录|
|assert | |不支持动态修改 |断言控制开关,默认值 0|
|randErrorChance | |支持动态修改 立即生效 |内部参数,用于随机失败测试|
|randErrorDivisor | |支持动态修改 立即生效 |内部参数,用于随机失败测试|
|randErrorScope | |支持动态修改 立即生效 |内部参数,用于随机失败测试|
|safetyCheckLevel | |支持动态修改 立即生效 |内部参数,用于随机失败测试|
|experimental | |支持动态修改 立即生效 |内部参数,用于一些实验特性|
|simdEnable |3.3.4.3 后|不支持动态修改 |内部参数,用于测试 SIMD 加速|
|AVX512Enable |3.3.4.3 后|不支持动态修改 |内部参数,用于测试 AVX512 加速|
|rsyncPort | |不支持动态修改 |内部参数,用于调试流计算|
|snodeAddress | |支持动态修改 重启生效 |内部参数,用于调试流计算|
|checkpointBackupDir | |支持动态修改 重启生效 |内部参数,用于恢复 snode 数据|
|enableAuditDelete | |不支持动态修改 |内部参数,用于测试审计功能|
|slowLogThresholdTest| |不支持动态修改 |内部参数,用于测试慢日志|
|bypassFlag |3.3.4.5 后|支持动态修改 立即生效 |内部参数用于短路测试0正常写入1写入消息在 taos 客户端发送 RPC 消息前返回2写入消息在 taosd 服务端收到 RPC 消息后返回4写入消息在 taosd 服务端写入内存缓存前返回8写入消息在 taosd 服务端数据落盘前返回;默认值 0|
### 压缩参数
|参数名称|支持版本|参数含义|
|------------|----------|-|
|fPrecision | |设置 float 类型浮点数压缩精度 ,取值范围 0.1 ~ 0.00000001 ,默认值 0.00000001 , 小于此值的浮点数尾数部分将被截断|
|dPrecision | |设置 double 类型浮点数压缩精度 , 取值范围 0.1 ~ 0.0000000000000001 默认值 0.0000000000000001 小于此值的浮点数尾数部分将被截取|
|lossyColumn |3.3.0.0 前|对 float 和/或 double 类型启用 TSZ 有损压缩;取值范围 float/double/none默认值 none表示关闭无损压缩|
|ifAdtFse | |在启用 TSZ 有损压缩时,使用 FSE 算法替换 HUFFMAN 算法FSE 算法压缩速度更快但解压稍慢追求压缩速度可选用此算法0关闭1打开默认值为 0|
|maxRange | |内部参数,用于有损压缩设置|
|curRange | |内部参数,用于有损压缩设置|
|compressor | |内部参数,用于有损压缩设置|
|参数名称|支持版本|动态修改|参数含义|
|------------|----------|-------------------------|-|
|fPrecision | |支持动态修改 立即生效 |设置 float 类型浮点数压缩精度 ,取值范围 0.1 ~ 0.00000001 ,默认值 0.00000001 , 小于此值的浮点数尾数部分将被截断|
|dPrecision | |支持动态修改 立即生效 |设置 double 类型浮点数压缩精度 , 取值范围 0.1 ~ 0.0000000000000001 默认值 0.0000000000000001 小于此值的浮点数尾数部分将被截取|
|lossyColumn |3.3.0.0 前|不支持动态修改 |对 float 和/或 double 类型启用 TSZ 有损压缩;取值范围 float/double/none默认值 none表示关闭无损压缩|
|ifAdtFse | |支持动态修改 重启生效 |在启用 TSZ 有损压缩时,使用 FSE 算法替换 HUFFMAN 算法FSE 算法压缩速度更快但解压稍慢追求压缩速度可选用此算法0关闭1打开默认值为 0|
|maxRange | |支持动态修改 重启生效 |内部参数,用于有损压缩设置|
|curRange | |支持动态修改 重启生效 |内部参数,用于有损压缩设置|
|compressor | |支持动态修改 重启生效 |内部参数,用于有损压缩设置|
**补充说明**
1. 在 3.2.0.0 ~ 3.3.0.0(不包含)版本生效,启用该参数后不能回退到升级前的版本
2. TSZ 压缩算法是通过数据预测技术完成的压缩,所以更适合有规律变化的数据
3. TSZ 压缩时间会更长一些,如果您的服务器 CPU 空闲多,存储空间小的情况下适合选用
4. 示例:对 float 和 double 类型都启用有损压缩
1. 在 3.4.0.0 之后,所有配置参数都将被持久化到本地存储,重启数据库服务后,将默认使用持久化的配置参数列表;如果您希望继续使用 config 文件中配置的参数,需设置 forceReadConfig 为 1。
2. 在 3.2.0.0 ~ 3.3.0.0(不包含)版本生效,启用该参数后不能回退到升级前的版本
3. TSZ 压缩算法是通过数据预测技术完成的压缩,所以更适合有规律变化的数据
4. TSZ 压缩时间会更长一些,如果您的服务器 CPU 空闲多,存储空间小的情况下适合选用
5. 示例:对 float 和 double 类型都启用有损压缩
```shell
lossyColumns float|double
```
5. 配置需重启服务生效,重启如果在 taosd 日志中看到以下内容,表明配置已生效:
6. 配置需重启服务生效,重启如果在 taosd 日志中看到以下内容,表明配置已生效:
```sql
02/22 10:49:27.607990 00002933 UTL lossyColumns float|double
```

View File

@ -9,101 +9,102 @@ TDengine 客户端驱动提供了应用编程所需要的全部 API并且在
## 配置参数
### 连接相关
|参数名称|支持版本|参数含义|
|----------------------|----------|-------------|
|firstEp | |启动时,主动连接的集群中首个 dnode 的 endpoint缺省值hostname:6030若无法获取该服务器的 hostname则赋值为 localhost|
|secondEp | |启动时,如果 firstEp 连接不上,尝试连接集群中第二个 dnode 的 endpoint没有缺省值|
|compressMsgSize | |是否对 RPC 消息进行压缩;-1所有消息都不压缩0所有消息都压缩N (N>0):只有大于 N 个字节的消息才压缩;缺省值 -1|
|shellActivityTimer | |客户端向 mnode 发送心跳的时长,单位为秒,取值范围 1-120默认值 3|
|numOfRpcSessions | |RPC 支持的最大连接数,取值范围 100-100000缺省值 30000|
|numOfRpcThreads | |RPC 收发数据线程数目取值范围1-50,默认值为 CPU 核数的一半|
|numOfTaskQueueThreads | |客户端处理 RPC消息的线程数, 范围4-16,默认值为 CPU 核数的一半|
|timeToGetAvailableConn| 3.3.4.*之后取消 |获得可用连接的最长等待时间,取值范围 10-50000000单位为毫秒缺省值 500000|
|useAdapter | |内部参数,是否使用 taosadapter影响 CSV 文件导入|
|shareConnLimit |3.3.4.0 新增|内部参数,一个链接可以共享的查询数目,取值范围 1-256默认值 10|
|readTimeout |3.3.4.0 新增|内部参数,最小超时时间,取值范围 64-604800单位为秒默认值 900|
|参数名称|支持版本|动态修改|参数含义|
|----------------------|----------|-------------------------|-------------|
|firstEp | |支持动态修改 立即生效 |启动时,主动连接的集群中首个 dnode 的 endpoint缺省值hostname:6030若无法获取该服务器的 hostname则赋值为 localhost|
|secondEp | |支持动态修改 立即生效 |启动时,如果 firstEp 连接不上,尝试连接集群中第二个 dnode 的 endpoint没有缺省值|
|serverPort | |支持动态修改 立即生效 |taosd 监听的端口,默认值 6030|
|compressMsgSize | |支持动态修改 立即生效 |是否对 RPC 消息进行压缩;-1所有消息都不压缩0所有消息都压缩N (N>0):只有大于 N 个字节的消息才压缩;缺省值 -1|
|shellActivityTimer | |不支持动态修改 |客户端向 mnode 发送心跳的时长,单位为秒,取值范围 1-120默认值 3|
|numOfRpcSessions | |支持动态修改 立即生效 |RPC 支持的最大连接数,取值范围 100-100000缺省值 30000|
|numOfRpcThreads | |不支持动态修改 |RPC 收发数据线程数目取值范围1-50,默认值为 CPU 核数的一半|
|numOfTaskQueueThreads | |不支持动态修改 |客户端处理 RPC消息的线程数, 范围4-16,默认值为 CPU 核数的一半|
|timeToGetAvailableConn| 3.3.4.*之后取消 |不支持动态修改 |获得可用连接的最长等待时间,取值范围 10-50000000单位为毫秒缺省值 500000|
|useAdapter | |支持动态修改 立即生效 |内部参数,是否使用 taosadapter影响 CSV 文件导入|
|shareConnLimit |3.3.4.0 新增|不支持动态修改 |内部参数,一个链接可以共享的查询数目,取值范围 1-256默认值 10|
|readTimeout |3.3.4.0 新增|不支持动态修改 |内部参数,最小超时时间,取值范围 64-604800单位为秒默认值 900|
### 查询相关
|参数名称|支持版本|参数含义|
|---------------------------------|---------|-|
|countAlwaysReturnValue | |count/hyperloglog 函数在输入数据为空或者 NULL 的情况下是否返回值0返回空行1返回默认值 1该参数设置为 1 时,如果查询中含有 INTERVAL 子句或者该查询使用了 TSMA 时,且相应的组或窗口内数据为空或者 NULL对应的组或窗口将不返回查询结果注意此参数客户端和服务端值应保持一致|
|keepColumnName | |Last、First、LastRow 函数查询且未指定别名时,自动设置别名为列名(不含函数名),因此 order by 子句如果引用了该列名将自动引用该列对应的函数1表示自动设置别名为列名(不包含函数名)0表示不自动设置别名缺省值0|
|multiResultFunctionStarReturnTags|3.3.3.0 后|查询超级表时last(\*)/last_row(\*)/first(\*) 是否返回标签列查询普通表、子表时不受该参数影响0不返回标签列1返回标签列缺省值0该参数设置为 0 时last(\*)/last_row(\*)/first(\*) 只返回超级表的普通列;为 1 时,返回超级表的普通列和标签列|
|metaCacheMaxSize | |指定单个客户端元数据缓存大小的最大值,单位 MB缺省值 -1表示无限制|
|maxTsmaCalcDelay | |查询时客户端可允许的 tsma 计算延迟,若 tsma 的计算延迟大于配置值,则该 TSMA 将不会被使用;取值范围 600s - 86400s即 10 分钟 - 1 小时缺省值600 秒|
|tsmaDataDeleteMark | |TSMA 计算的历史数据中间结果保存时间,单位为毫秒;取值范围 >= 3600000即大于等于1h缺省值86400000即 1d |
|queryPolicy | |查询语句的执行策略1只使用 vnode不使用 qnode2没有扫描算子的子任务在 qnode 执行,带扫描算子的子任务在 vnode 执行3vnode 只运行扫描算子,其余算子均在 qnode 执行缺省值1|
|queryTableNotExistAsEmpty | |查询表不存在时是否返回空结果集false返回错误true返回空结果集缺省值 false|
|querySmaOptimize | |sma index 的优化策略0表示不使用 sma index永远从原始数据进行查询1表示使用 sma index对符合的语句直接从预计算的结果进行查询缺省值0|
|queryPlannerTrace | |内部参数,查询计划是否输出详细日志|
|queryNodeChunkSize | |内部参数,查询计划的块大小|
|queryUseNodeAllocator | |内部参数,查询计划的分配方法|
|queryMaxConcurrentTables | |内部参数,查询计划的并发数目|
|enableQueryHb | |内部参数,是否发送查询心跳消息|
|minSlidingTime | |内部参数sliding 的最小允许值|
|minIntervalTime | |内部参数interval 的最小允许值|
|参数名称|支持版本|动态修改|参数含义|
|----------------------|----------|-------------------------|-------------|
|countAlwaysReturnValue | |支持动态修改 立即生效 |count/hyperloglog 函数在输入数据为空或者 NULL 的情况下是否返回值0返回空行1返回默认值 1该参数设置为 1 时,如果查询中含有 INTERVAL 子句或者该查询使用了 TSMA 时,且相应的组或窗口内数据为空或者 NULL对应的组或窗口将不返回查询结果注意此参数客户端和服务端值应保持一致|
|keepColumnName | |支持动态修改 立即生效 |Last、First、LastRow 函数查询且未指定别名时,自动设置别名为列名(不含函数名),因此 order by 子句如果引用了该列名将自动引用该列对应的函数1表示自动设置别名为列名(不包含函数名)0表示不自动设置别名缺省值0|
|multiResultFunctionStarReturnTags|3.3.3.0 后|支持动态修改 立即生效 |查询超级表时last(\*)/last_row(\*)/first(\*) 是否返回标签列查询普通表、子表时不受该参数影响0不返回标签列1返回标签列缺省值0该参数设置为 0 时last(\*)/last_row(\*)/first(\*) 只返回超级表的普通列;为 1 时,返回超级表的普通列和标签列|
|metaCacheMaxSize | |支持动态修改 立即生效 |指定单个客户端元数据缓存大小的最大值,单位 MB缺省值 -1表示无限制|
|maxTsmaCalcDelay | |支持动态修改 立即生效 |查询时客户端可允许的 tsma 计算延迟,若 tsma 的计算延迟大于配置值,则该 TSMA 将不会被使用;取值范围 600s - 86400s即 10 分钟 - 1 小时缺省值600 秒|
|tsmaDataDeleteMark | |支持动态修改 立即生效 |TSMA 计算的历史数据中间结果保存时间,单位为毫秒;取值范围 >= 3600000即大于等于1h缺省值86400000即 1d |
|queryPolicy | |支持动态修改 立即生效 |查询语句的执行策略1只使用 vnode不使用 qnode2没有扫描算子的子任务在 qnode 执行,带扫描算子的子任务在 vnode 执行3vnode 只运行扫描算子,其余算子均在 qnode 执行缺省值1|
|queryTableNotExistAsEmpty | |支持动态修改 立即生效 |查询表不存在时是否返回空结果集false返回错误true返回空结果集缺省值 false|
|querySmaOptimize | |支持动态修改 立即生效 |sma index 的优化策略0表示不使用 sma index永远从原始数据进行查询1表示使用 sma index对符合的语句直接从预计算的结果进行查询缺省值0|
|queryPlannerTrace | |支持动态修改 立即生效 |内部参数,查询计划是否输出详细日志|
|queryNodeChunkSize | |支持动态修改 立即生效 |内部参数,查询计划的块大小|
|queryUseNodeAllocator | |支持动态修改 立即生效 |内部参数,查询计划的分配方法|
|queryMaxConcurrentTables | |不支持动态修改 |内部参数,查询计划的并发数目|
|enableQueryHb | |支持动态修改 立即生效 |内部参数,是否发送查询心跳消息|
|minSlidingTime | |支持动态修改 立即生效 |内部参数sliding 的最小允许值|
|minIntervalTime | |支持动态修改 立即生效 |内部参数interval 的最小允许值|
### 写入相关
|参数名称|支持版本|参数含义|
|------------------------------|----------|-|
|smlChildTableName | |schemaless 自定义的子表名的 key无缺省值|
|smlAutoChildTableNameDelimiter| |schemaless tag 之间的连接符,连起来作为子表名,无缺省值|
|smlTagName | |schemaless tag 为空时默认的 tag 名字,缺省值 "_tag_null"|
|smlTsDefaultName | |schemaless 自动建表的时间列名字通过该配置设置,缺省值 "_ts"|
|smlDot2Underline | |schemaless 把超级表名中的 dot 转成下划线|
|maxInsertBatchRows | |内部参数,一批写入的最大条数|
|参数名称|支持版本|动态修改|参数含义|
|----------------------|----------|-------------------------|-------------|
|smlChildTableName | |支持动态修改 立即生效 |schemaless 自定义的子表名的 key无缺省值|
|smlAutoChildTableNameDelimiter| |支持动态修改 立即生效 |schemaless tag 之间的连接符,连起来作为子表名,无缺省值|
|smlTagName | |支持动态修改 立即生效 |schemaless tag 为空时默认的 tag 名字,缺省值 "_tag_null"|
|smlTsDefaultName | |支持动态修改 立即生效 |schemaless 自动建表的时间列名字通过该配置设置,缺省值 "_ts"|
|smlDot2Underline | |支持动态修改 立即生效 |schemaless 把超级表名中的 dot 转成下划线|
|maxInsertBatchRows | |支持动态修改 立即生效 |内部参数,一批写入的最大条数|
### 区域相关
|参数名称|支持版本|参数含义|
|-----------------|----------|-|
|timezone | |时区;缺省从系统中动态获取当前的时区设置|
|locale | |系统区位信息及编码格式,缺省从系统中获取|
|charset | |字符集编码,缺省从系统中获取|
|参数名称|支持版本|动态修改|参数含义|
|----------------------|----------|-------------------------|-------------|
|timezone | |支持动态修改 立即生效 |时区;缺省从系统中动态获取当前的时区设置|
|locale | |支持动态修改 立即生效 |系统区位信息及编码格式,缺省从系统中获取|
|charset | |支持动态修改 立即生效 |字符集编码,缺省从系统中获取|
### 存储相关
|参数名称|支持版本|参数含义|
|-----------------|----------|-|
|tempDir | |指定所有运行过程中的临时文件生成的目录Linux 平台默认值为 /tmp|
|minimalTmpDirGB | |tempDir 所指定的临时文件目录所需要保留的最小空间,单位 GB缺省值1|
|参数名称|支持版本|动态修改|参数含义|
|----------------------|----------|-------------------------|-------------|
|tempDir | |支持动态修改 立即生效 |指定所有运行过程中的临时文件生成的目录Linux 平台默认值为 /tmp|
|minimalTmpDirGB | |支持动态修改 立即生效 |tempDir 所指定的临时文件目录所需要保留的最小空间,单位 GB缺省值1|
### 日志相关
|参数名称|支持版本|参数含义|
|-----------------|----------|-|
|logDir | |日志文件目录,运行日志将写入该目录,缺省值:/var/log/taos|
|minimalLogDirGB | |日志文件夹所在磁盘可用空间大小小于该值时,停止写日志,单位 GB缺省值1|
|numOfLogLines | |单个日志文件允许的最大行数缺省值10,000,000|
|asyncLog | |日志写入模式0同步1异步缺省值1|
|logKeepDays | |日志文件的最长保存时间单位缺省值0意味着无限保存日志文件不会被重命名也不会有新的日志文件滚动产生但日志文件的内容有可能会不断滚动取决于日志文件大小的设置当设置为大于 0 的值时,当日志文件大小达到设置的上限时会被重命名为 taoslogx.yyy其中 yyy 为日志文件最后修改的时间戳,并滚动产生新的日志文件|
|debugFlag | |运行日志开关131输出错误和警告日志135输出错误、警告和调试日志143输出错误、警告、调试和跟踪日志默认值 131 或 135 (取决于不同模块)|
|tmrDebugFlag | |定时器模块的日志开关,取值范围同上|
|uDebugFlag | |共用功能模块的日志开关,取值范围同上|
|rpcDebugFlag | |rpc 模块的日志开关,取值范围同上|
|jniDebugFlag | |jni 模块的日志开关,取值范围同上|
|qDebugFlag | |query 模块的日志开关,取值范围同上|
|cDebugFlag | |客户端模块的日志开关,取值范围同上|
|simDebugFlag | |内部参数,测试工具的日志开关,取值范围同上|
|tqClientDebugFlag|3.3.4.3 后|客户端模块的日志开关,取值范围同上|
|参数名称|支持版本|动态修改|参数含义|
|----------------------|----------|-------------------------|-------------|
|logDir | |不支持动态修改 |日志文件目录,运行日志将写入该目录,缺省值:/var/log/taos|
|minimalLogDirGB | |支持动态修改 立即生效 |日志文件夹所在磁盘可用空间大小小于该值时,停止写日志,单位 GB缺省值1|
|numOfLogLines | |支持动态修改 立即生效 |单个日志文件允许的最大行数缺省值10,000,000|
|asyncLog | |支持动态修改 立即生效 |日志写入模式0同步1异步缺省值1|
|logKeepDays | |支持动态修改 立即生效 |日志文件的最长保存时间单位缺省值0意味着无限保存日志文件不会被重命名也不会有新的日志文件滚动产生但日志文件的内容有可能会不断滚动取决于日志文件大小的设置当设置为大于 0 的值时,当日志文件大小达到设置的上限时会被重命名为 taoslogx.yyy其中 yyy 为日志文件最后修改的时间戳,并滚动产生新的日志文件|
|debugFlag | |支持动态修改 立即生效 |运行日志开关131输出错误和警告日志135输出错误、警告和调试日志143输出错误、警告、调试和跟踪日志默认值 131 或 135 (取决于不同模块)|
|tmrDebugFlag | |支持动态修改 立即生效 |定时器模块的日志开关,取值范围同上|
|uDebugFlag | |支持动态修改 立即生效 |共用功能模块的日志开关,取值范围同上|
|rpcDebugFlag | |支持动态修改 立即生效 |rpc 模块的日志开关,取值范围同上|
|jniDebugFlag | |支持动态修改 立即生效 |jni 模块的日志开关,取值范围同上|
|qDebugFlag | |支持动态修改 立即生效 |query 模块的日志开关,取值范围同上|
|cDebugFlag | |支持动态修改 立即生效 |客户端模块的日志开关,取值范围同上|
|simDebugFlag | |支持动态修改 立即生效 |内部参数,测试工具的日志开关,取值范围同上|
|tqClientDebugFlag|3.3.4.3 后|支持动态修改 立即生效 |客户端模块的日志开关,取值范围同上|
### 调试相关
|参数名称|支持版本|参数含义|
|-----------------|-----------|-|
|crashReporting | |是否上传 crash 到 telemetry0不上传1上传缺省值1|
|enableCoreFile | |crash 时是否生成 core 文件0不生成1生成缺省值1|
|assert | |断言控制开关缺省值0|
|configDir | |配置文件所在目录|
|scriptDir | |内部参数,测试用例的目录|
|randErrorChance |3.3.3.0 后|内部参数,用于随机失败测试|
|randErrorDivisor |3.3.3.0 后|内部参数,用于随机失败测试|
|randErrorScope |3.3.3.0 后|内部参数,用于随机失败测试|
|safetyCheckLevel |3.3.3.0 后|内部参数,用于随机失败测试|
|simdEnable |3.3.4.3 后|内部参数,用于测试 SIMD 加速|
|AVX512Enable |3.3.4.3 后|内部参数,用于测试 AVX512 加速|
|bypassFlag |3.3.4.5 后|内部参数用于短路测试0正常写入1写入消息在 taos 客户端发送 RPC 消息前返回2写入消息在 taosd 服务端收到 RPC 消息后返回4写入消息在 taosd 服务端写入内存缓存前返回8写入消息在 taosd 服务端数据落盘前返回缺省值0|
|参数名称|支持版本|动态修改|参数含义|
|----------------------|----------|-------------------------|-------------|
|crashReporting | |支持动态修改 立即生效 |是否上传 crash 到 telemetry0不上传1上传缺省值1|
|enableCoreFile | |支持动态修改 立即生效 |crash 时是否生成 core 文件0不生成1生成缺省值1|
|assert | |不支持动态修改 |断言控制开关缺省值0|
|configDir | |不支持动态修改 |配置文件所在目录|
|scriptDir | |不支持动态修改 |内部参数,测试用例的目录|
|randErrorChance |3.3.3.0 后|不支持动态修改 |内部参数,用于随机失败测试|
|randErrorDivisor |3.3.3.0 后|不支持动态修改 |内部参数,用于随机失败测试|
|randErrorScope |3.3.3.0 后|不支持动态修改 |内部参数,用于随机失败测试|
|safetyCheckLevel |3.3.3.0 后|不支持动态修改 |内部参数,用于随机失败测试|
|simdEnable |3.3.4.3 后|不支持动态修改 |内部参数,用于测试 SIMD 加速|
|AVX512Enable |3.3.4.3 后|不支持动态修改 |内部参数,用于测试 AVX512 加速|
|bypassFlag |3.3.4.5 后|支持动态修改 立即生效 |内部参数用于短路测试0正常写入1写入消息在 taos 客户端发送 RPC 消息前返回2写入消息在 taosd 服务端收到 RPC 消息后返回4写入消息在 taosd 服务端写入内存缓存前返回8写入消息在 taosd 服务端数据落盘前返回缺省值0|
### SHELL 相关
|参数名称|支持版本|参数含义|
|-----------------|----------|-|
|enableScience | |是否开启科学计数法显示浮点数0不开始1开启缺省值1|
|参数名称|支持版本|动态修改|参数含义|
|----------------------|----------|-------------------------|-------------|
|enableScience | |不支持动态修改 |是否开启科学计数法显示浮点数0不开始1开启缺省值1|
## API

View File

@ -136,11 +136,11 @@ alter_database_option: {
1. 如何查看 cachesize?
通过 select * from information_schema.ins_databases; 可以查看这些 cachesize 的具体值。
通过 select * from information_schema.ins_databases; 可以查看这些 cachesize 的具体值(单位为 MB
2. 如何查看 cacheload?
通过 show \<db_name>.vgroups; 可以查看 cacheload
通过 show \<db_name>.vgroups; 可以查看 cacheload(单位为字节)。
3. 判断 cachesize 是否够用

View File

@ -42,32 +42,11 @@ DROP DNODE dnode_id [force] [unsafe]
ALTER DNODE dnode_id dnode_option
ALTER ALL DNODES dnode_option
dnode_option: {
'resetLog'
| 'balance' 'value'
| 'monitor' 'value'
| 'debugFlag' 'value'
| 'monDebugFlag' 'value'
| 'vDebugFlag' 'value'
| 'mDebugFlag' 'value'
| 'cDebugFlag' 'value'
| 'httpDebugFlag' 'value'
| 'qDebugflag' 'value'
| 'sdbDebugFlag' 'value'
| 'uDebugFlag' 'value'
| 'tsdbDebugFlag' 'value'
| 'sDebugflag' 'value'
| 'rpcDebugFlag' 'value'
| 'dDebugFlag' 'value'
| 'mqttDebugFlag' 'value'
| 'wDebugFlag' 'value'
| 'tmrDebugFlag' 'value'
| 'cqDebugFlag' 'value'
}
```
上面语法中的这些可修改配置项其配置方式与 dnode 配置文件中的配置方式相同,区别是修改是动态的立即生效,且不需要重启 dnode。
对于支持动态修改的配置参数,您可以使用 ALTER DNODE 或 ALTER ALL DNODES 语法修改 dnode 中配置参数的值,自 3.3.4.0 后,修改的配置参数将自动持久化,即便数据库服务重启后仍然生效。
对于一个配置参数是否支持动态修改,请您参考以下页面:[taosd 参考手册](../01-components/01-taosd.md)
value 是参数的值,需要是字符格式。如修改 dnode 1 的日志输出级别为 debug
@ -75,6 +54,18 @@ value 是参数的值,需要是字符格式。如修改 dnode 1 的日志输
ALTER DNODE 1 'debugFlag' '143';
```
### 补充说明:
配置参数在 dnode 中被分为全局配置参数与局部配置参数,您可以查看 SHOW VARIABLES 或 SHOW DNODE dnode_id VARIABLE 中的 category 字段来确认配置参数属于全局配置参数还是局部配置参数:
1. 局部配置参数:您可以使用 ALTER DNODE 或 ALTER ALL DNODES 来更新某一个 dnode 或全部 dnodes 的局部配置参数。
2. 全局配置参数:全局配置参数要求各个 dnode 保持一致,所以您只可以使用 ALTER ALL DNODES 来更新全部 dnodes 的全局配置参数。
配置参数是否可以动态修改,有以下三种情况:
1. 支持动态修改 立即生效
2. 支持动态修改 重启生效
3. 不支持动态修改
对于重启后生效的配置参数,您可以通过 SHOW VARIABLES 或 SHOW DNODE dnode_id VARIABLE 看到修改后的值,但是需要重启数据库服务才使其生效。
## 添加管理节点
```sql
@ -137,18 +128,12 @@ SHOW CLUSTER ALIVE;
```sql
ALTER LOCAL local_option
local_option: {
'resetLog'
| 'rpcDebugFlag' 'value'
| 'tmrDebugFlag' 'value'
| 'cDebugFlag' 'value'
| 'uDebugFlag' 'value'
| 'debugFlag' 'value'
}
```
上面语法中的参数与在配置文件中配置客户端的用法相同,但不需要重启客户端,修改后立即生效。
您可以使用以上语法更该客户端的配置参数,并且不需要重启客户端,修改后立即生效。
对于一个配置参数是否支持动态修改,请您参考以下页面:[taosc 参考手册](../01-components/02-taosc.md)
## 查看客户端配置

View File

@ -343,3 +343,17 @@ TDengine 内置了一个名为 `INFORMATION_SCHEMA` 的数据库,提供对数
| 10 | raw_data | BIGINT | 预估的原始数据的大小, 单位为KB |
## INS_FILESETS
提供当前数据存储的文件组的相关信息。
| # | **列名** | **数据类型** | **说明** |
| --- | :-----------: | ------------ | --------------------------------------- |
| 1 | db_name | VARCHAR(65) | 数据库名 |
| 2 | vgroup_id | INT | vgroup id |
| 3 | fileset_id | INT | 文件组 id |
| 4 | start_time | TIMESTAMP | 文件组的覆盖数据的开始时间 |
| 5 | end_time | TIMESTAMP | 文件组的覆盖数据的结束时间 |
| 6 | total_size | BIGINT | 文件组的总大小 |
| 7 | last_compact | TIMESTAMP | 最后一次压缩的时间 |
| 8 | shold_compact | bool | 是否需要压缩true需要false不需要 |

View File

@ -75,6 +75,7 @@ description: TDengine 服务端的错误码列表和详细说明
| 0x80000133 | Invalid operation | 无效的或不支持的操作 | 1. 修改确认当前操作为合法有效支持的操作,检查参数有效性 2. 如果问题还未解决保留现场和日志github上报issue |
| 0x80000134 | Invalid value | 无效值 | 保留现场和日志github上报issue |
| 0x80000135 | Invalid fqdn | 无效FQDN | 检查配置或输入的FQDN值是否正确 |
| 0x8000013C | Invalid disk id | 不合法的disk id | 建议用户检查挂载磁盘是否失效或者使用参数 diskIDCheckEnabled 来跳过磁盘检查 |

View File

@ -289,3 +289,12 @@ https://docs.taosdata.com/reference/components/taosd/#%E7%9B%91%E6%8E%A7%E7%9B%B
因此用户首先要检查服务端集群的所有端口原生连接默认6030http连接默认6041有无打开其次是客户端的hosts文件中是否配置了集群所有节点的fqdn与IP信息。
如仍无法解决,则需要联系涛思技术人员支持。
### 32 同一台服务器,数据库的数据目录 dataDir 不变,为什么原有数据库丢失且集群 ID 发生了变化?
背景知识TDengine 服务端进程taosd在启动时若数据目录dataDir该目录在配置文件 taos.cfg 中指定)下不存在有效的数据文件子目录(如 mnode、dnode 和 vnode 等),则会自动创建这些目录。在创建新的 mnode 目录的同时,会分配一个新的集群 ID从而产生一个新的集群。
原因分析taosd 的数据目录 dataDir 可以指向多个不同的挂载点。如果这些挂载点未在 fstab 文件中配置自动挂载服务器重启后dataDir 将仅作为一个本地磁盘的普通目录存在,而未能按预期指向挂载的磁盘。此时,若 taosd 服务启动,它将在 dataDir 下新建目录,从而产生一个新的集群。
问题影响:服务器重启后,原有数据库丢失(注:并非真正丢失,只是原有的数据磁盘未挂载,暂时看不到)且集群 ID 发生变化,导致无法访问原有数据库。对于企业版用户,如果已针对集群 ID 进行授权,还会发现集群服务器的机器码未变,但原有的授权已失效。如果未针对该问题进行监控或者未及时发现并进行处理,则用户不会注意到原有数据库已经丢失,从而造成损失,增加运维成本。
问题解决:应在 fstab 文件中配置 dataDir 目录的自动挂载,确保 dataDir 始终指向预期的挂载点和目录,此时,再重启服务器,会找回原有的数据库和集群。在后续的版本中,我们将开发一个功能,使 taosd 在检测到启动前后 dataDir 发生变化时,在启动阶段退出,同时提供相应的错误提示。

View File

@ -188,6 +188,7 @@ void tCleanupStreamHbMsg(SStreamHbMsg* pMsg);
typedef struct {
SMsgHead head;
int32_t msgId;
SEpSet mndEpset;
} SMStreamHbRspMsg;
int32_t tEncodeStreamHbRsp(SEncoder* pEncoder, const SMStreamHbRspMsg* pRsp);

View File

@ -62,6 +62,7 @@ extern "C" {
#define TSDB_INS_TABLE_ENCRYPTIONS "ins_encryptions"
#define TSDB_INS_TABLE_TSMAS "ins_tsmas"
#define TSDB_INS_DISK_USAGE "ins_disk_usage"
#define TSDB_INS_TABLE_FILESETS "ins_filesets"
#define TSDB_PERFORMANCE_SCHEMA_DB "performance_schema"
#define TSDB_PERFS_TABLE_SMAS "perf_smas"

View File

@ -19,6 +19,7 @@
#include "tarray.h"
#include "tconfig.h"
#include "tdef.h"
#include "tmsg.h"
#ifdef __cplusplus
extern "C" {
@ -30,6 +31,9 @@ extern "C" {
#define SLOW_LOG_TYPE_OTHERS 0x4
#define SLOW_LOG_TYPE_ALL 0x7
#define GLOBAL_CONFIG_FILE_VERSION 1
#define LOCAL_CONFIG_FILE_VERSION 1
typedef enum {
DND_CA_SM4 = 1,
} EEncryptAlgor;
@ -41,6 +45,8 @@ typedef enum {
DND_CS_MNODE_WAL = 8,
} EEncryptScope;
extern SConfig *tsCfg;
// cluster
extern char tsFirst[];
extern char tsSecond[];
@ -49,6 +55,9 @@ extern char tsLocalEp[];
extern char tsVersionName[];
extern uint16_t tsServerPort;
extern int32_t tsVersion;
extern int32_t tsForceReadConfig;
extern int32_t tsdmConfigVersion;
extern int32_t tsConfigInited;
extern int32_t tsStatusInterval;
extern int32_t tsNumOfSupportVnodes;
extern char tsEncryptAlgorithm[];
@ -76,7 +85,7 @@ extern int32_t tsQueryConcurrentTaskNum;
extern int32_t tsSingleQueryMaxMemorySize;
extern int8_t tsQueryUseMemoryPool;
extern int8_t tsMemPoolFullFunc;
//extern int32_t tsQueryBufferPoolSize;
// extern int32_t tsQueryBufferPoolSize;
extern int32_t tsMinReservedMemorySize;
extern int64_t tsCurrentAvailMemorySize;
extern int8_t tsNeedTrim;
@ -87,7 +96,6 @@ extern int32_t tsNumOfRpcSessions;
extern int32_t tsShareConnLimit;
extern int32_t tsReadTimeout;
extern int32_t tsTimeToGetAvailableConn;
extern int32_t tsKeepAliveIdle;
extern int32_t tsNumOfCommitThreads;
extern int32_t tsNumOfTaskQueueThreads;
extern int32_t tsNumOfMnodeQueryThreads;
@ -104,6 +112,9 @@ extern int32_t tsNumOfSnodeWriteThreads;
extern int64_t tsQueueMemoryAllowed;
extern int32_t tsRetentionSpeedLimitMB;
extern const char *tsAlterCompactTaskKeywords;
extern int32_t tsNumOfCompactThreads;
// sync raft
extern int32_t tsElectInterval;
extern int32_t tsHeartbeatInterval;
@ -167,7 +178,7 @@ extern bool tsEnableCrashReport;
extern char *tsTelemUri;
extern char *tsClientCrashReportUri;
extern char *tsSvrCrashReportUri;
extern int8_t tsSafetyCheckLevel;
extern int32_t tsSafetyCheckLevel;
enum {
TSDB_SAFETY_CHECK_LEVELL_NEVER = 0,
TSDB_SAFETY_CHECK_LEVELL_NORMAL = 1,
@ -256,6 +267,7 @@ extern int64_t tsmaDataDeleteMark;
extern int64_t tsWalFsyncDataSizeLimit;
// internal
extern bool tsDiskIDCheckEnabled;
extern int32_t tsTransPullupInterval;
extern int32_t tsCompactPullupInterval;
extern int32_t tsMqRebalanceInterval;
@ -271,7 +283,7 @@ extern int32_t tsS3MigrateIntervalSec;
extern bool tsS3MigrateEnabled;
extern int32_t tsGrantHBInterval;
extern int32_t tsUptimeInterval;
extern bool tsUpdateCacheBatch;
extern bool tsDisableStream;
extern int64_t tsStreamBufferSize;
extern int tsStreamAggCnt;
@ -301,6 +313,16 @@ void taosLocalCfgForbiddenToChange(char *name, bool *forbidden);
int8_t taosGranted(int8_t type);
int32_t taosSetSlowLogScope(char *pScopeStr, int32_t *pScope);
int32_t taosPersistGlobalConfig(SArray *array, const char *path, int32_t version);
int32_t taosPersistLocalConfig(const char *path);
int32_t localConfigSerialize(SArray *array, char **serialized);
int32_t tSerializeSConfigArray(SEncoder *pEncoder, SArray *array);
int32_t tDeserializeSConfigArray(SDecoder *pDecoder, SArray *array);
int32_t setAllConfigs(SConfig *pCfg);
void printConfigNotMatch(SArray *array);
int32_t compareSConfigItemArrays(SArray *mArray, const SArray *dArray, SArray *diffArray);
bool isConifgItemLazyMode(SConfigItem *item);
#ifdef __cplusplus
}
#endif

View File

@ -162,6 +162,7 @@ typedef enum _mgmt_table {
TSDB_MGMT_TABLE_ANODE,
TSDB_MGMT_TABLE_ANODE_FULL,
TSDB_MGMT_TABLE_USAGE,
TSDB_MGMT_TABLE_FILESETS,
TSDB_MGMT_TABLE_MAX,
} EShowType;
@ -310,6 +311,7 @@ typedef enum ENodeType {
QUERY_NODE_DESCRIBE_STMT,
QUERY_NODE_RESET_QUERY_CACHE_STMT,
QUERY_NODE_COMPACT_DATABASE_STMT,
QUERY_NODE_COMPACT_VGROUPS_STMT,
QUERY_NODE_CREATE_FUNCTION_STMT,
QUERY_NODE_DROP_FUNCTION_STMT,
QUERY_NODE_CREATE_STREAM_STMT,
@ -402,6 +404,7 @@ typedef enum ENodeType {
QUERY_NODE_CREATE_TSMA_STMT,
QUERY_NODE_SHOW_CREATE_TSMA_STMT,
QUERY_NODE_DROP_TSMA_STMT,
QUERY_NODE_SHOW_FILESETS_STMT,
// logic plan node
QUERY_NODE_LOGIC_PLAN_SCAN = 1000,
@ -681,7 +684,7 @@ typedef struct {
int32_t tsSlowLogThreshold;
int32_t tsSlowLogMaxLen;
int32_t tsSlowLogScope;
int32_t tsSlowLogThresholdTest; //Obsolete
int32_t tsSlowLogThresholdTest; // Obsolete
char tsSlowLogExceptDb[TSDB_DB_NAME_LEN];
} SMonitorParas;
@ -1347,6 +1350,11 @@ typedef struct {
int8_t withArbitrator;
int8_t encryptAlgorithm;
char dnodeListStr[TSDB_DNODE_LIST_LEN];
// 1. add auto-compact parameters
int32_t compactInterval; // minutes
int32_t compactStartTime; // minutes
int32_t compactEndTime; // minutes
int8_t compactTimeOffset; // hour
} SCreateDbReq;
int32_t tSerializeSCreateDbReq(void* buf, int32_t bufLen, SCreateDbReq* pReq);
@ -1378,6 +1386,11 @@ typedef struct {
int32_t sqlLen;
char* sql;
int8_t withArbitrator;
// 1. add auto-compact parameters
int32_t compactInterval;
int32_t compactStartTime;
int32_t compactEndTime;
int8_t compactTimeOffset;
} SAlterDbReq;
int32_t tSerializeSAlterDbReq(void* buf, int32_t bufLen, SAlterDbReq* pReq);
@ -1510,6 +1523,10 @@ typedef struct {
int32_t s3ChunkSize;
int32_t s3KeepLocal;
int8_t s3Compact;
int8_t compactTimeOffset;
int32_t compactInterval;
int32_t compactStartTime;
int32_t compactEndTime;
int32_t tsdbPageSize;
int32_t walRetentionPeriod;
int32_t walRollPeriod;
@ -1617,6 +1634,7 @@ typedef struct {
STimeWindow timeRange;
int32_t sqlLen;
char* sql;
SArray* vgroupIds;
} SCompactDbReq;
int32_t tSerializeSCompactDbReq(void* buf, int32_t bufLen, SCompactDbReq* pReq);
@ -1827,6 +1845,16 @@ int32_t tSerializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq);
int32_t tDeserializeSStatusReq(void* buf, int32_t bufLen, SStatusReq* pReq);
void tFreeSStatusReq(SStatusReq* pReq);
typedef struct {
int32_t forceReadConfig;
int32_t cver;
SArray* array;
} SConfigReq;
int32_t tSerializeSConfigReq(void* buf, int32_t bufLen, SConfigReq* pReq);
int32_t tDeserializeSConfigReq(void* buf, int32_t bufLen, SConfigReq* pReq);
void tFreeSConfigReq(SConfigReq* pReq);
typedef struct {
int32_t dnodeId;
char machineId[TSDB_MACHINE_ID_LEN + 1];
@ -1904,6 +1932,18 @@ int32_t tSerializeSStatusRsp(void* buf, int32_t bufLen, SStatusRsp* pRsp);
int32_t tDeserializeSStatusRsp(void* buf, int32_t bufLen, SStatusRsp* pRsp);
void tFreeSStatusRsp(SStatusRsp* pRsp);
typedef struct {
int32_t forceReadConfig;
int32_t isConifgVerified;
int32_t isVersionVerified;
int32_t cver;
SArray* array;
} SConfigRsp;
int32_t tSerializeSConfigRsp(void* buf, int32_t bufLen, SConfigRsp* pRsp);
int32_t tDeserializeSConfigRsp(void* buf, int32_t bufLen, SConfigRsp* pRsp);
void tFreeSConfigRsp(SConfigRsp* pRsp);
typedef struct {
int32_t reserved;
} SMTimerReq;
@ -2002,6 +2042,8 @@ typedef struct {
int32_t dnodeId;
int32_t numberFileset;
int32_t finished;
int32_t progress;
int64_t remainingTime;
} SQueryCompactProgressRsp;
int32_t tSerializeSQueryCompactProgressRsp(void* buf, int32_t bufLen, SQueryCompactProgressRsp* pReq);
@ -2209,6 +2251,7 @@ typedef struct {
char name[TSDB_CONFIG_OPTION_LEN + 1];
char value[TSDB_CONFIG_PATH_LEN + 1];
char scope[TSDB_CONFIG_SCOPE_LEN + 1];
char category[TSDB_CONFIG_CATEGORY_LEN + 1];
char info[TSDB_CONFIG_INFO_LEN + 1];
} SVariablesInfo;
@ -2417,8 +2460,9 @@ int32_t tDeserializeSMCfgDnodeReq(void* buf, int32_t bufLen, SMCfgDnodeReq* pReq
void tFreeSMCfgDnodeReq(SMCfgDnodeReq* pReq);
typedef struct {
char config[TSDB_DNODE_CONFIG_LEN];
char value[TSDB_DNODE_VALUE_LEN];
char config[TSDB_DNODE_CONFIG_LEN];
char value[TSDB_DNODE_VALUE_LEN];
int32_t version;
} SDCfgDnodeReq;
int32_t tSerializeSDCfgDnodeReq(void* buf, int32_t bufLen, SDCfgDnodeReq* pReq);

View File

@ -260,6 +260,7 @@
TD_DEF_MSG_TYPE(TDMT_MND_STREAM_TASK_RESET, "stream-reset-tasks", NULL, NULL)
TD_DEF_MSG_TYPE(TDMT_MND_UPDATE_DNODE_INFO, "update-dnode-info", NULL, NULL)
TD_DEF_MSG_TYPE(TDMT_MND_AUDIT, "audit", NULL, NULL)
TD_DEF_MSG_TYPE(TDMT_MND_CONFIG, "init-config", NULL, NULL)
TD_CLOSE_MSG_SEG(TDMT_END_MND_MSG)
TD_NEW_MSG_SEG(TDMT_VND_MSG) // 2<<8

View File

@ -17,10 +17,10 @@
#define _TD_MND_H_
#include "monitor.h"
#include "sync.h"
#include "tmsg.h"
#include "tmsgcb.h"
#include "trpc.h"
#include "sync.h"
#ifdef __cplusplus
extern "C" {
@ -73,7 +73,7 @@ int32_t mndStart(SMnode *pMnode);
*/
void mndStop(SMnode *pMnode);
int32_t mndIsCatchUp(SMnode *pMnode);
int32_t mndIsCatchUp(SMnode *pMnode);
ESyncRole mndGetRole(SMnode *pMnode);
int64_t mndGetTerm(SMnode *pMnode);
@ -109,7 +109,7 @@ int64_t mndGetRoleTimeMs(SMnode *pMnode);
* @param pMsg The request msg.
* @return int32_t 0 for success, -1 for failure.
*/
int32_t mndProcessRpcMsg(SRpcMsg *pMsg, SQueueInfo* pQueueInfo);
int32_t mndProcessRpcMsg(SRpcMsg *pMsg, SQueueInfo *pQueueInfo);
int32_t mndProcessSyncMsg(SRpcMsg *pMsg);
int32_t mndPreProcessQueryMsg(SRpcMsg *pMsg);
void mndPostProcessQueryMsg(SRpcMsg *pMsg);

View File

@ -21,19 +21,19 @@
extern "C" {
#endif
typedef struct SCryptOpts{
int32_t len;
char* source;
char* result;
int32_t unitLen;
unsigned char key[17];
}SCryptOpts;
typedef struct SCryptOpts {
int32_t len;
char* source;
char* result;
int32_t unitLen;
char key[17];
} SCryptOpts;
int32_t CBC_Decrypt(SCryptOpts *opts);
int32_t CBC_Encrypt(SCryptOpts *opts);
int32_t CBC_Decrypt(SCryptOpts* opts);
int32_t CBC_Encrypt(SCryptOpts* opts);
#ifdef __cplusplus
}
#endif
#endif // _CRYPT_H_
#endif // _CRYPT_H_

View File

@ -171,6 +171,8 @@ typedef union {
typedef void (*TsdReaderNotifyCbFn)(ETsdReaderNotifyType type, STsdReaderNotifyInfo* info, void* param);
struct SFileSetReader;
typedef struct TsdReader {
int32_t (*tsdReaderOpen)(void* pVnode, SQueryTableDataCond* pCond, void* pTableList, int32_t numOfTables,
SSDataBlock* pResBlock, void** ppReader, const char* idstr, SHashObj** pIgnoreTables);
@ -191,6 +193,13 @@ typedef struct TsdReader {
void (*tsdSetFilesetDelimited)(void* pReader);
void (*tsdSetSetNotifyCb)(void* pReader, TsdReaderNotifyCbFn notifyFn, void* param);
// for fileset query
int32_t (*fileSetReaderOpen)(void *pVnode, struct SFileSetReader **ppReader);
int32_t (*fileSetReadNext)(struct SFileSetReader *);
int32_t (*fileSetGetEntryField)(struct SFileSetReader *, const char *, void *);
void (*fileSetReaderClose)(struct SFileSetReader **);
} TsdReader;
typedef struct SStoreCacheReader {
@ -431,7 +440,7 @@ typedef struct SStateStore {
int32_t (*streamFileStateInit)(int64_t memSize, uint32_t keySize, uint32_t rowSize, uint32_t selectRowSize,
GetTsFun fp, void* pFile, TSKEY delMark, const char* id, int64_t ckId, int8_t type,
struct SStreamFileState** ppFileState);
int32_t (*streamStateGroupPut)(SStreamState* pState, int64_t groupId, void* value, int32_t vLen);
SStreamStateCur* (*streamStateGroupGetCur)(SStreamState* pState);
void (*streamStateGroupCurNext)(SStreamStateCur* pCur);

View File

@ -42,11 +42,12 @@ extern "C" {
#define SHOW_CREATE_VIEW_RESULT_FIELD1_LEN (TSDB_VIEW_FNAME_LEN + 4 + VARSTR_HEADER_SIZE)
#define SHOW_CREATE_VIEW_RESULT_FIELD2_LEN (TSDB_MAX_ALLOWED_SQL_LEN + VARSTR_HEADER_SIZE)
#define SHOW_LOCAL_VARIABLES_RESULT_COLS 4
#define SHOW_LOCAL_VARIABLES_RESULT_COLS 5
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE)
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_PATH_LEN + VARSTR_HEADER_SIZE)
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD3_LEN (TSDB_CONFIG_SCOPE_LEN + VARSTR_HEADER_SIZE)
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD4_LEN (TSDB_CONFIG_INFO_LEN + VARSTR_HEADER_SIZE)
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD4_LEN (TSDB_CONFIG_CATEGORY_LEN + VARSTR_HEADER_SIZE)
#define SHOW_LOCAL_VARIABLES_RESULT_FIELD5_LEN (TSDB_CONFIG_INFO_LEN + VARSTR_HEADER_SIZE)
#define COMPACT_DB_RESULT_COLS 3
#define COMPACT_DB_RESULT_FIELD1_LEN 32
@ -110,6 +111,16 @@ typedef struct SDatabaseOptions {
SValueNode* s3KeepLocalStr;
int8_t s3Compact;
int8_t withArbitrator;
// for auto-compact
int8_t compactTimeOffset; // hours
int32_t compactInterval; // minutes
int32_t compactStartTime; // minutes
int32_t compactEndTime; // minutes
SValueNode* pCompactTimeOffsetNode;
SValueNode* pCompactIntervalNode;
SNodeList* pCompactTimeRangeList;
// for cache
SDbCfgInfo* pDbCfg;
} SDatabaseOptions;
typedef struct SCreateDatabaseStmt {
@ -159,6 +170,14 @@ typedef struct SCompactDatabaseStmt {
SNode* pEnd;
} SCompactDatabaseStmt;
typedef struct SCompactVgroupsStmt {
ENodeType type;
SNode* pDbName;
SNodeList* vgidList;
SNode* pStart;
SNode* pEnd;
} SCompactVgroupsStmt;
typedef struct STableOptions {
ENodeType type;
bool commentNull;

View File

@ -83,6 +83,8 @@ int32_t taosUnLockFile(TdFilePtr pFile);
int32_t taosUmaskFile(int32_t maskVal);
int32_t taosStatFile(const char *path, int64_t *size, int64_t *mtime, int64_t *atime);
int32_t taosGetFileDiskID(const char *path, int64_t *diskid);
bool taosCheckFileDiskID(const char *path, int64_t *actDiskID, int64_t expDiskID);
int32_t taosDevInoFile(TdFilePtr pFile, int64_t *stDev, int64_t *stIno);
int32_t taosFStatFile(TdFilePtr pFile, int64_t *size, int64_t *mtime);
bool taosCheckExistFile(const char *pathname);

View File

@ -159,6 +159,7 @@ int32_t taosGetErrSize();
#define TSDB_CODE_SOCKET_ERROR TAOS_DEF_ERROR_CODE(0, 0x0139)
#define TSDB_CODE_UNSUPPORT_OS TAOS_DEF_ERROR_CODE(0, 0x013A)
#define TSDB_CODE_TIME_ERROR TAOS_DEF_ERROR_CODE(0, 0x013B)
#define TSDB_CODE_INVALID_DISK_ID TAOS_DEF_ERROR_CODE(0, 0x013C)
//client
#define TSDB_CODE_TSC_INVALID_OPERATION TAOS_DEF_ERROR_CODE(0, 0x0200)
@ -480,6 +481,7 @@ int32_t taosGetErrSize();
#define TSDB_CODE_DNODE_INVALID_EN_WHITELIST TAOS_DEF_ERROR_CODE(0, 0x0428)
#define TSDB_CODE_DNODE_INVALID_MONITOR_PARAS TAOS_DEF_ERROR_CODE(0, 0x0429)
#define TSDB_CODE_MNODE_STOPPED TAOS_DEF_ERROR_CODE(0, 0x042A)
#define TSDB_CODE_DNODE_INVALID_COMPACT_TASKS TAOS_DEF_ERROR_CODE(0, 0x042B)
// anode
#define TSDB_CODE_MND_ANODE_ALREADY_EXIST TAOS_DEF_ERROR_CODE(0, 0x0430)
@ -903,6 +905,7 @@ int32_t taosGetErrSize();
#define TSDB_CODE_PAR_INVALID_ANOMALY_WIN_COL TAOS_DEF_ERROR_CODE(0, 0x2683)
#define TSDB_CODE_PAR_INVALID_ANOMALY_WIN_OPT TAOS_DEF_ERROR_CODE(0, 0x2684)
#define TSDB_CODE_PAR_INVALID_FORECAST_CLAUSE TAOS_DEF_ERROR_CODE(0, 0x2685)
#define TSDB_CODE_PAR_INVALID_VGID_LIST TAOS_DEF_ERROR_CODE(0, 0x2686)
#define TSDB_CODE_PAR_INTERNAL_ERROR TAOS_DEF_ERROR_CODE(0, 0x26FF)
//planner

View File

@ -53,19 +53,30 @@ typedef enum {
} ECfgDataType;
typedef enum { CFG_SCOPE_SERVER, CFG_SCOPE_CLIENT, CFG_SCOPE_BOTH } ECfgScopeType;
typedef enum { CFG_CATEGORY_GLOBAL, CFG_CATEGORY_LOCAL } ECfgCategoryType;
typedef enum { CFG_ALTER_LOCAL, CFG_ALTER_DNODE, CFG_ALTER_ALL_DNODES } CfgAlterType;
typedef enum {
CFG_DYN_NONE = 0,
CFG_DYN_SERVER = 1,
CFG_DYN_CLIENT = 2,
CFG_DYN_BOTH = 3,
CFG_DYN_SERVER_LAZY = 3,
CFG_DYN_CLIENT_LAZY = 4,
CFG_DYN_BOTH_LAZY = 5,
CFG_DYN_BOTH = 6,
#ifdef TD_ENTERPRISE
CFG_DYN_ENT_SERVER = CFG_DYN_SERVER,
CFG_DYN_ENT_CLIENT = CFG_DYN_CLIENT,
CFG_DYN_ENT_SERVER_LAZY = CFG_DYN_SERVER_LAZY,
CFG_DYN_ENT_CLIENT_LAZY = CFG_DYN_CLIENT_LAZY,
CFG_DYN_ENT_BOTH_LAZY = CFG_DYN_BOTH_LAZY,
CFG_DYN_ENT_BOTH = CFG_DYN_BOTH,
#else
CFG_DYN_ENT_SERVER = CFG_DYN_NONE,
CFG_DYN_ENT_CLIENT = CFG_DYN_NONE,
CFG_DYN_ENT_SERVER_LAZY = CFG_DYN_NONE,
CFG_DYN_ENT_CLIENT_LAZY = CFG_DYN_NONE,
CFG_DYN_ENT_BOTH_LAZY = CFG_DYN_NONE,
CFG_DYN_ENT_BOTH = CFG_DYN_NONE,
#endif
} ECfgDynType;
@ -75,6 +86,7 @@ typedef struct SConfigItem {
ECfgDataType dtype;
int8_t scope;
int8_t dynScope;
int8_t category;
char *name;
union {
bool bval;
@ -99,17 +111,21 @@ typedef struct {
const char *value;
} SConfigPair;
typedef struct SConfig SConfig;
typedef struct SConfig SConfig;
typedef struct SConfigIter SConfigIter;
int32_t cfgInit(SConfig **ppCfg);
int32_t cfgLoad(SConfig *pCfg, ECfgSrcType cfgType, const void *sourceStr);
int32_t cfgLoadFromArray(SConfig *pCfg, SArray *pArgs); // SConfigPair
int32_t cfgLoadFromArray(SConfig *pCfg, SArray *pArgs); // SConfigPair
int32_t cfgUpdateFromArray(SConfig *pCfg, SArray *pArgs); // SConfigItem
void cfgCleanup(SConfig *pCfg);
int32_t cfgGetSize(SConfig *pCfg);
SConfigItem *cfgGetItem(SConfig *pCfg, const char *pName);
int32_t cfgSetItem(SConfig *pCfg, const char *name, const char *value, ECfgSrcType stype, bool lock);
int32_t cfgCheckRangeForDynUpdate(SConfig *pCfg, const char *name, const char *pVal, bool isServer);
int32_t cfgGetAndSetItem(SConfig *pCfg, SConfigItem **ppItem, const char *name, const char *value, ECfgSrcType stype,
bool lock);
int32_t cfgCheckRangeForDynUpdate(SConfig *pCfg, const char *name, const char *pVal, bool isServer,
CfgAlterType alterType);
int32_t cfgCreateIter(SConfig *pConf, SConfigIter **ppIter);
SConfigItem *cfgNextIter(SConfigIter *pIter);
@ -118,16 +134,16 @@ void cfgLock(SConfig *pCfg);
void cfgUnLock(SConfig *pCfg);
// clang-format off
int32_t cfgAddBool(SConfig *pCfg, const char *name, bool defaultVal, int8_t scope, int8_t dynScope);
int32_t cfgAddInt32Ex(SConfig *pCfg, const char *name, int32_t defaultVal, int64_t minval, int64_t maxval, int8_t scope, int8_t dynScope);
int32_t cfgAddInt32(SConfig *pCfg, const char *name, int32_t defaultVal, int64_t minval, int64_t maxval, int8_t scope, int8_t dynScope);
int32_t cfgAddInt64(SConfig *pCfg, const char *name, int64_t defaultVal, int64_t minval, int64_t maxval, int8_t scope, int8_t dynScope);
int32_t cfgAddFloat(SConfig *pCfg, const char *name, float defaultVal, float minval, float maxval, int8_t scope, int8_t dynScope);
int32_t cfgAddString(SConfig *pCfg, const char *name, const char *defaultVal, int8_t scope, int8_t dynScope);
int32_t cfgAddDir(SConfig *pCfg, const char *name, const char *defaultVal, int8_t scope, int8_t dynScope);
int32_t cfgAddLocale(SConfig *pCfg, const char *name, const char *defaultVal, int8_t scope, int8_t dynScope);
int32_t cfgAddCharset(SConfig *pCfg, const char *name, const char *defaultVal, int8_t scope, int8_t dynScope);
int32_t cfgAddTimezone(SConfig *pCfg, const char *name, const char *defaultVal, int8_t scope, int8_t dynScope);
int32_t cfgAddBool(SConfig *pCfg, const char *name, bool defaultVal, int8_t scope, int8_t dynScope,int8_t category);
int32_t cfgAddInt32(SConfig *pCfg, const char *name, int32_t defaultVal, int64_t minval, int64_t maxval, int8_t scope, int8_t dynScope,int8_t category);
int32_t cfgAddInt32Ex(SConfig *pCfg, const char *name, int32_t defaultVal, int64_t minval, int64_t maxval, int8_t scope, int8_t dynScope,int8_t category);
int32_t cfgAddInt64(SConfig *pCfg, const char *name, int64_t defaultVal, int64_t minval, int64_t maxval, int8_t scope, int8_t dynScope,int8_t category);
int32_t cfgAddFloat(SConfig *pCfg, const char *name, float defaultVal, float minval, float maxval, int8_t scope, int8_t dynScope,int8_t category);
int32_t cfgAddString(SConfig *pCfg, const char *name, const char *defaultVal, int8_t scope, int8_t dynScope,int8_t category);
int32_t cfgAddDir(SConfig *pCfg, const char *name, const char *defaultVal, int8_t scope, int8_t dynScope,int8_t category);
int32_t cfgAddLocale(SConfig *pCfg, const char *name, const char *defaultVal, int8_t scope, int8_t dynScope,int8_t category);
int32_t cfgAddCharset(SConfig *pCfg, const char *name, const char *defaultVal, int8_t scope, int8_t dynScope,int8_t category);
int32_t cfgAddTimezone(SConfig *pCfg, const char *name, const char *defaultVal, int8_t scope, int8_t dynScope,int8_t category);
// clang-format on
const char *cfgStypeStr(ECfgSrcType type);
@ -135,12 +151,17 @@ const char *cfgDtypeStr(ECfgDataType type);
int32_t cfgDumpItemValue(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *pLen);
int32_t cfgDumpItemScope(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *pLen);
int32_t cfgDumpItemCategory(SConfigItem *pItem, char *buf, int32_t bufSize, int32_t *pLen);
void cfgDumpCfg(SConfig *pCfg, bool tsc, bool dump);
void cfgDumpCfgS3(SConfig *pCfg, bool tsc, bool dump);
int32_t cfgGetApollUrl(const char **envCmd, const char *envFile, char *apolloUrl);
SArray *taosGetLocalCfg(SConfig *pCfg);
SArray *taosGetGlobalCfg(SConfig *pCfg);
void taosSetLocalCfg(SConfig *pCfg, SArray *pArray);
void taosSetGlobalCfg(SConfig *pCfg, SArray *pArray);
#ifdef __cplusplus
}
#endif

View File

@ -190,45 +190,22 @@ typedef enum EOperatorType {
} EOperatorType;
static const EOperatorType OPERATOR_ARRAY[] = {
OP_TYPE_ADD,
OP_TYPE_SUB,
OP_TYPE_MULTI,
OP_TYPE_DIV,
OP_TYPE_REM,
OP_TYPE_ADD, OP_TYPE_SUB, OP_TYPE_MULTI, OP_TYPE_DIV, OP_TYPE_REM,
OP_TYPE_MINUS,
OP_TYPE_MINUS,
OP_TYPE_BIT_AND,
OP_TYPE_BIT_OR,
OP_TYPE_BIT_AND, OP_TYPE_BIT_OR,
OP_TYPE_GREATER_THAN,
OP_TYPE_GREATER_EQUAL,
OP_TYPE_LOWER_THAN,
OP_TYPE_LOWER_EQUAL,
OP_TYPE_EQUAL,
OP_TYPE_NOT_EQUAL,
OP_TYPE_IN,
OP_TYPE_NOT_IN,
OP_TYPE_LIKE,
OP_TYPE_NOT_LIKE,
OP_TYPE_MATCH,
OP_TYPE_NMATCH,
OP_TYPE_GREATER_THAN, OP_TYPE_GREATER_EQUAL, OP_TYPE_LOWER_THAN, OP_TYPE_LOWER_EQUAL, OP_TYPE_EQUAL,
OP_TYPE_NOT_EQUAL, OP_TYPE_IN, OP_TYPE_NOT_IN, OP_TYPE_LIKE, OP_TYPE_NOT_LIKE, OP_TYPE_MATCH, OP_TYPE_NMATCH,
OP_TYPE_IS_NULL,
OP_TYPE_IS_NOT_NULL,
OP_TYPE_IS_TRUE,
OP_TYPE_IS_FALSE,
OP_TYPE_IS_UNKNOWN,
OP_TYPE_IS_NOT_TRUE,
OP_TYPE_IS_NOT_FALSE,
OP_TYPE_IS_NOT_UNKNOWN,
//OP_TYPE_COMPARE_MAX_VALUE,
OP_TYPE_IS_NULL, OP_TYPE_IS_NOT_NULL, OP_TYPE_IS_TRUE, OP_TYPE_IS_FALSE, OP_TYPE_IS_UNKNOWN, OP_TYPE_IS_NOT_TRUE,
OP_TYPE_IS_NOT_FALSE, OP_TYPE_IS_NOT_UNKNOWN,
// OP_TYPE_COMPARE_MAX_VALUE,
OP_TYPE_JSON_GET_VALUE,
OP_TYPE_JSON_CONTAINS,
OP_TYPE_JSON_GET_VALUE, OP_TYPE_JSON_CONTAINS,
OP_TYPE_ASSIGN
};
OP_TYPE_ASSIGN};
#define OP_TYPE_CALC_MAX OP_TYPE_BIT_OR
@ -531,6 +508,15 @@ typedef enum ELogicConditionType {
#define TSDB_MIN_TABLE_TTL 0
#define TSDB_DEFAULT_TABLE_TTL 0
#define TSDB_DEFAULT_COMPACT_INTERVAL 0
#define TSDB_MIN_COMPACT_INTERVAL 10 // unit minute
#define TSDB_MAX_COMPACT_INTERVAL TSDB_MAX_KEEP // unit minute
#define TSDB_DEFAULT_COMPACT_START_TIME 0
#define TSDB_DEFAULT_COMPACT_END_TIME 0
#define TSDB_MIN_COMPACT_TIME_OFFSET 0
#define TSDB_MAX_COMPACT_TIME_OFFSET 23
#define TSDB_DEFAULT_COMPACT_TIME_OFFSET 0
#define TSDB_MIN_EXPLAIN_RATIO 0
#define TSDB_MAX_EXPLAIN_RATIO 1
#define TSDB_DEFAULT_EXPLAIN_RATIO 0.001
@ -605,6 +591,7 @@ enum { ENCRYPT_KEY_STAT_UNKNOWN = 0, ENCRYPT_KEY_STAT_UNSET, ENCRYPT_KEY_STAT_SE
typedef struct {
char dir[TSDB_FILENAME_LEN];
int32_t level;
int64_t diskId;
int32_t primary;
int8_t disable; // disable create new file
} SDiskCfg;
@ -640,12 +627,13 @@ enum { RAND_ERR_MEMORY = 1, RAND_ERR_FILE = 2, RAND_ERR_NETWORK = 4 };
#define VNODE_HANDLE -3
#define CLIENT_HANDLE -5
#define TSDB_CONFIG_OPTION_LEN 32
#define TSDB_CONFIG_VALUE_LEN 64
#define TSDB_CONFIG_SCOPE_LEN 8
#define TSDB_CONFIG_NUMBER 16
#define TSDB_CONFIG_PATH_LEN 4096
#define TSDB_CONFIG_INFO_LEN 64
#define TSDB_CONFIG_OPTION_LEN 32
#define TSDB_CONFIG_VALUE_LEN 64
#define TSDB_CONFIG_SCOPE_LEN 8
#define TSDB_CONFIG_NUMBER 16
#define TSDB_CONFIG_PATH_LEN 4096
#define TSDB_CONFIG_INFO_LEN 64
#define TSDB_CONFIG_CATEGORY_LEN 8
#define QUERY_ID_SIZE 20
#define QUERY_OBJ_ID_SIZE 18

View File

@ -88,6 +88,7 @@ static int32_t tEncodeU64v(SEncoder* pCoder, uint64_t val);
static int32_t tEncodeI64v(SEncoder* pCoder, int64_t val);
static int32_t tEncodeFloat(SEncoder* pCoder, float val);
static int32_t tEncodeDouble(SEncoder* pCoder, double val);
static int32_t tEncodeBool(SEncoder* pCoder, bool val);
static int32_t tEncodeBinary(SEncoder* pCoder, const uint8_t* val, uint32_t len);
static int32_t tEncodeBinaryEx(SEncoder* pCoder, const uint8_t* val, uint32_t len);
static int32_t tEncodeCStrWithLen(SEncoder* pCoder, const char* val, uint32_t len);
@ -116,6 +117,7 @@ static int32_t tDecodeU64v(SDecoder* pCoder, uint64_t* val);
static int32_t tDecodeI64v(SDecoder* pCoder, int64_t* val);
static int32_t tDecodeFloat(SDecoder* pCoder, float* val);
static int32_t tDecodeDouble(SDecoder* pCoder, double* val);
static int32_t tDecodeBool(SDecoder* pCoder, bool* val);
static int32_t tDecodeBinary(SDecoder* pCoder, uint8_t** val, uint32_t* len);
static int32_t tDecodeCStrAndLen(SDecoder* pCoder, char** val, uint32_t* len);
static int32_t tDecodeCStr(SDecoder* pCoder, char** val);
@ -205,6 +207,8 @@ static FORCE_INLINE int32_t tEncodeDouble(SEncoder* pCoder, double val) {
return tEncodeU64(pCoder, v.ui);
}
static int32_t tEncodeBool(SEncoder* pCoder, bool val) { return tEncodeU8(pCoder, val ? 1 : 0); }
static FORCE_INLINE int32_t tEncodeBinary(SEncoder* pCoder, const uint8_t* val, uint32_t len) {
TAOS_CHECK_RETURN(tEncodeU32v(pCoder, len));
if (len) {
@ -391,6 +395,15 @@ static FORCE_INLINE int32_t tDecodeDouble(SDecoder* pCoder, double* val) {
return 0;
}
static int32_t tDecodeBool(SDecoder* pCoder, bool* val) {
uint8_t v;
TAOS_CHECK_RETURN(tDecodeU8(pCoder, &v));
if (val) {
*val = v ? true : false;
}
return 0;
}
static FORCE_INLINE int32_t tDecodeBinary(SDecoder* pCoder, uint8_t** val, uint32_t* len) {
uint32_t length = 0;

View File

@ -47,11 +47,12 @@ enum {
RES_TYPE__TMQ_BATCH_META,
};
#define SHOW_VARIABLES_RESULT_COLS 4
#define SHOW_VARIABLES_RESULT_COLS 5
#define SHOW_VARIABLES_RESULT_FIELD1_LEN (TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE)
#define SHOW_VARIABLES_RESULT_FIELD2_LEN (TSDB_CONFIG_VALUE_LEN + VARSTR_HEADER_SIZE)
#define SHOW_VARIABLES_RESULT_FIELD3_LEN (TSDB_CONFIG_SCOPE_LEN + VARSTR_HEADER_SIZE)
#define SHOW_VARIABLES_RESULT_FIELD4_LEN (TSDB_CONFIG_INFO_LEN + VARSTR_HEADER_SIZE)
#define SHOW_VARIABLES_RESULT_FIELD4_LEN (TSDB_CONFIG_CATEGORY_LEN + VARSTR_HEADER_SIZE)
#define SHOW_VARIABLES_RESULT_FIELD5_LEN (TSDB_CONFIG_INFO_LEN + VARSTR_HEADER_SIZE)
#define TD_RES_QUERY(res) (*(int8_t*)(res) == RES_TYPE__QUERY)
#define TD_RES_TMQ(res) (*(int8_t*)(res) == RES_TYPE__TMQ)

View File

@ -150,6 +150,7 @@ typedef struct {
SStmtExecInfo exec;
SStmtBindInfo bInfo;
char *db;
int64_t reqid;
int32_t errCode;
tsem_t asyncQuerySem;

View File

@ -15,9 +15,10 @@
#include "catalog.h"
#include "clientInt.h"
#include "clientMonitor.h"
#include "clientLog.h"
#include "clientMonitor.h"
#include "cmdnodes.h"
#include "command.h"
#include "os.h"
#include "query.h"
#include "systable.h"
@ -26,7 +27,6 @@
#include "tglobal.h"
#include "tname.h"
#include "tversion.h"
#include "command.h"
extern SClientHbMgr clientHbMgr;
@ -40,7 +40,7 @@ int32_t genericRspCallback(void* param, SDataBuf* pMsg, int32_t code) {
setErrno(pRequest, code);
if (NEED_CLIENT_RM_TBLMETA_REQ(pRequest->type)) {
if (removeMeta(pRequest->pTscObj, pRequest->targetTableList, IS_VIEW_REQUEST(pRequest->type)) != 0){
if (removeMeta(pRequest->pTscObj, pRequest->targetTableList, IS_VIEW_REQUEST(pRequest->type)) != 0) {
tscError("failed to remove meta data for table");
}
}
@ -50,7 +50,7 @@ int32_t genericRspCallback(void* param, SDataBuf* pMsg, int32_t code) {
if (pRequest->body.queryFp != NULL) {
doRequestCallback(pRequest, code);
} else {
if (tsem_post(&pRequest->body.rspSem) != 0){
if (tsem_post(&pRequest->body.rspSem) != 0) {
tscError("failed to post semaphore");
}
}
@ -104,7 +104,7 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
SEpSet dstEpSet = connectRsp.epSet;
if (srcEpSet.numOfEps == 1) {
if (rpcSetDefaultAddr(pTscObj->pAppInfo->pTransporter, srcEpSet.eps[srcEpSet.inUse].fqdn,
dstEpSet.eps[dstEpSet.inUse].fqdn) != 0){
dstEpSet.eps[dstEpSet.inUse].fqdn) != 0) {
tscError("failed to set default addr for rpc");
}
updateEpSet = 0;
@ -146,14 +146,15 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
pTscObj->authVer = connectRsp.authVer;
pTscObj->whiteListInfo.ver = connectRsp.whiteListVer;
if(taosHashGet(appInfo.pInstMapByClusterId, &connectRsp.clusterId, LONG_BYTES) == NULL){
if(taosHashPut(appInfo.pInstMapByClusterId, &connectRsp.clusterId, LONG_BYTES, &pTscObj->pAppInfo, POINTER_BYTES) != 0){
if (taosHashGet(appInfo.pInstMapByClusterId, &connectRsp.clusterId, LONG_BYTES) == NULL) {
if (taosHashPut(appInfo.pInstMapByClusterId, &connectRsp.clusterId, LONG_BYTES, &pTscObj->pAppInfo,
POINTER_BYTES) != 0) {
tscError("failed to put appInfo into appInfo.pInstMapByClusterId");
}else{
} else {
MonitorSlowLogData data = {0};
data.clusterId = pTscObj->pAppInfo->clusterId;
data.type = SLOW_LOG_READ_BEGINNIG;
(void)monitorPutData2MonitorQueue(data); // ignore
(void)monitorPutData2MonitorQueue(data); // ignore
monitorClientSlowQueryInit(connectRsp.clusterId);
monitorClientSQLReqInit(connectRsp.clusterId);
}
@ -162,7 +163,7 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
(void)taosThreadMutexLock(&clientHbMgr.lock);
SAppHbMgr* pAppHbMgr = taosArrayGetP(clientHbMgr.appHbMgrs, pTscObj->appHbMgrIdx);
if (pAppHbMgr) {
if (hbRegisterConn(pAppHbMgr, pTscObj->id, connectRsp.clusterId, connectRsp.connType) != 0){
if (hbRegisterConn(pAppHbMgr, pTscObj->id, connectRsp.clusterId, connectRsp.connType) != 0) {
tscError("0x%" PRIx64 " failed to register conn to hbMgr", pRequest->requestId);
}
} else {
@ -176,10 +177,10 @@ int32_t processConnectRsp(void* param, SDataBuf* pMsg, int32_t code) {
pTscObj->pAppInfo->numOfConns);
End:
if (code != 0){
if (code != 0) {
setErrno(pRequest, code);
}
if (tsem_post(&pRequest->body.rspSem) != 0){
if (tsem_post(&pRequest->body.rspSem) != 0) {
tscError("failed to post semaphore");
}
@ -196,7 +197,7 @@ EXIT:
SMsgSendInfo* buildMsgInfoImpl(SRequestObj* pRequest) {
SMsgSendInfo* pMsgSendInfo = taosMemoryCalloc(1, sizeof(SMsgSendInfo));
if(pMsgSendInfo == NULL) return pMsgSendInfo;
if (pMsgSendInfo == NULL) return pMsgSendInfo;
pMsgSendInfo->requestObjRefId = pRequest->self;
pMsgSendInfo->requestId = pRequest->requestId;
pMsgSendInfo->param = pRequest;
@ -227,11 +228,11 @@ int32_t processCreateDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
.mgmtEps = getEpSet_s(&pTscObj->pAppInfo->mgmtEp)};
char dbFName[TSDB_DB_FNAME_LEN];
(void)snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_INFORMATION_SCHEMA_DB);
if (catalogRefreshDBVgInfo(pCatalog, &conn, dbFName) != 0){
if (catalogRefreshDBVgInfo(pCatalog, &conn, dbFName) != 0) {
tscError("0x%" PRIx64 " failed to refresh db vg info", pRequest->requestId);
}
(void)snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_PERFORMANCE_SCHEMA_DB);
if (catalogRefreshDBVgInfo(pCatalog, &conn, dbFName) != 0){
if (catalogRefreshDBVgInfo(pCatalog, &conn, dbFName) != 0) {
tscError("0x%" PRIx64 " failed to refresh db vg info", pRequest->requestId);
}
}
@ -240,7 +241,7 @@ int32_t processCreateDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
if (pRequest->body.queryFp) {
doRequestCallback(pRequest, code);
} else {
if (tsem_post(&pRequest->body.rspSem) != 0){
if (tsem_post(&pRequest->body.rspSem) != 0) {
tscError("failed to post semaphore");
}
}
@ -252,19 +253,19 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
if (TSDB_CODE_MND_DB_NOT_EXIST == code || TSDB_CODE_MND_DB_IN_CREATING == code ||
TSDB_CODE_MND_DB_IN_DROPPING == code) {
SUseDbRsp usedbRsp = {0};
if (tDeserializeSUseDbRsp(pMsg->pData, pMsg->len, &usedbRsp) != 0){
if (tDeserializeSUseDbRsp(pMsg->pData, pMsg->len, &usedbRsp) != 0) {
tscError("0x%" PRIx64 " deserialize SUseDbRsp failed", pRequest->requestId);
}
struct SCatalog* pCatalog = NULL;
if (usedbRsp.vgVersion >= 0) { // cached in local
int64_t clusterId = pRequest->pTscObj->pAppInfo->clusterId;
int32_t code1 = catalogGetHandle(clusterId, &pCatalog);
int32_t code1 = catalogGetHandle(clusterId, &pCatalog);
if (code1 != TSDB_CODE_SUCCESS) {
tscWarn("0x%" PRIx64 "catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pRequest->requestId, clusterId,
tstrerror(code1));
} else {
if (catalogRemoveDB(pCatalog, usedbRsp.db, usedbRsp.uid) != 0){
if (catalogRemoveDB(pCatalog, usedbRsp.db, usedbRsp.uid) != 0) {
tscError("0x%" PRIx64 "catalogRemoveDB failed, db:%s, uid:%" PRId64, pRequest->requestId, usedbRsp.db,
usedbRsp.uid);
}
@ -282,7 +283,7 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
doRequestCallback(pRequest, pRequest->code);
} else {
if (tsem_post(&pRequest->body.rspSem) != 0){
if (tsem_post(&pRequest->body.rspSem) != 0) {
tscError("failed to post semaphore");
}
}
@ -291,7 +292,7 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
}
SUseDbRsp usedbRsp = {0};
if (tDeserializeSUseDbRsp(pMsg->pData, pMsg->len, &usedbRsp) != 0){
if (tDeserializeSUseDbRsp(pMsg->pData, pMsg->len, &usedbRsp) != 0) {
tscError("0x%" PRIx64 " deserialize SUseDbRsp failed", pRequest->requestId);
}
@ -309,7 +310,7 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
tscTrace("db:%s, usedbRsp received, numOfVgroups:%d", usedbRsp.db, usedbRsp.vgNum);
for (int32_t i = 0; i < usedbRsp.vgNum; ++i) {
SVgroupInfo* pInfo = taosArrayGet(usedbRsp.pVgroupInfos, i);
if (pInfo == NULL){
if (pInfo == NULL) {
continue;
}
tscTrace("vgId:%d, numOfEps:%d inUse:%d ", pInfo->vgId, pInfo->epSet.numOfEps, pInfo->epSet.inUse);
@ -319,7 +320,7 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
}
SName name = {0};
if(tNameFromString(&name, usedbRsp.db, T_NAME_ACCT | T_NAME_DB) != TSDB_CODE_SUCCESS) {
if (tNameFromString(&name, usedbRsp.db, T_NAME_ACCT | T_NAME_DB) != TSDB_CODE_SUCCESS) {
tscError("0x%" PRIx64 " failed to parse db name:%s", pRequest->requestId, usedbRsp.db);
}
@ -338,7 +339,7 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
tscWarn("catalogGetHandle failed, clusterId:%" PRIx64 ", error:%s", pRequest->pTscObj->pAppInfo->clusterId,
tstrerror(code1));
} else {
if (catalogUpdateDBVgInfo(pCatalog, output.db, output.dbId, output.dbVgroup) != 0){
if (catalogUpdateDBVgInfo(pCatalog, output.db, output.dbId, output.dbVgroup) != 0) {
tscError("0x%" PRIx64 " failed to update db vg info, db:%s, dbId:%" PRId64, pRequest->requestId, output.db,
output.dbId);
}
@ -350,7 +351,7 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
tFreeSUsedbRsp(&usedbRsp);
char db[TSDB_DB_NAME_LEN] = {0};
if(tNameGetDbName(&name, db) != TSDB_CODE_SUCCESS) {
if (tNameGetDbName(&name, db) != TSDB_CODE_SUCCESS) {
tscError("0x%" PRIx64 " failed to get db name since %s", pRequest->requestId, tstrerror(code));
}
@ -362,7 +363,7 @@ int32_t processUseDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
if (pRequest->body.queryFp != NULL) {
doRequestCallback(pRequest, pRequest->code);
} else {
if (tsem_post(&pRequest->body.rspSem) != 0){
if (tsem_post(&pRequest->body.rspSem) != 0) {
tscError("failed to post semaphore");
}
}
@ -387,7 +388,7 @@ int32_t processCreateSTableRsp(void* param, SDataBuf* pMsg, int32_t code) {
SMCreateStbRsp createRsp = {0};
SDecoder coder = {0};
tDecoderInit(&coder, pMsg->pData, pMsg->len);
if (pMsg->len > 0){
if (pMsg->len > 0) {
code = tDecodeSMCreateStbRsp(&coder, &createRsp); // pMsg->len == 0
if (code != TSDB_CODE_SUCCESS) {
setErrno(pRequest, code);
@ -419,7 +420,7 @@ int32_t processCreateSTableRsp(void* param, SDataBuf* pMsg, int32_t code) {
doRequestCallback(pRequest, code);
} else {
if (tsem_post(&pRequest->body.rspSem) != 0){
if (tsem_post(&pRequest->body.rspSem) != 0) {
tscError("failed to post semaphore");
}
}
@ -432,13 +433,13 @@ int32_t processDropDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
setErrno(pRequest, code);
} else {
SDropDbRsp dropdbRsp = {0};
if (tDeserializeSDropDbRsp(pMsg->pData, pMsg->len, &dropdbRsp) != 0){
if (tDeserializeSDropDbRsp(pMsg->pData, pMsg->len, &dropdbRsp) != 0) {
tscError("0x%" PRIx64 " deserialize SDropDbRsp failed", pRequest->requestId);
}
struct SCatalog* pCatalog = NULL;
code = catalogGetHandle(pRequest->pTscObj->pAppInfo->clusterId, &pCatalog);
if (TSDB_CODE_SUCCESS == code) {
if (catalogRemoveDB(pCatalog, dropdbRsp.db, dropdbRsp.uid) != 0){
if (catalogRemoveDB(pCatalog, dropdbRsp.db, dropdbRsp.uid) != 0) {
tscError("0x%" PRIx64 " failed to remove db:%s", pRequest->requestId, dropdbRsp.db);
}
STscObj* pTscObj = pRequest->pTscObj;
@ -451,7 +452,7 @@ int32_t processDropDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
(void)snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_INFORMATION_SCHEMA_DB);
if (catalogRefreshDBVgInfo(pCatalog, &conn, dbFName) != TSDB_CODE_SUCCESS) {
tscError("0x%" PRIx64 " failed to refresh db vg info, db:%s", pRequest->requestId, dbFName);
}
}
(void)snprintf(dbFName, sizeof(dbFName) - 1, "%d.%s", pTscObj->acctId, TSDB_PERFORMANCE_SCHEMA_DB);
if (catalogRefreshDBVgInfo(pCatalog, &conn, dbFName) != 0) {
tscError("0x%" PRIx64 " failed to refresh db vg info, db:%s", pRequest->requestId, dbFName);
@ -465,7 +466,7 @@ int32_t processDropDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
if (pRequest->body.queryFp != NULL) {
doRequestCallback(pRequest, code);
} else {
if (tsem_post(&pRequest->body.rspSem) != 0){
if (tsem_post(&pRequest->body.rspSem) != 0) {
tscError("failed to post semaphore");
}
}
@ -480,7 +481,7 @@ int32_t processAlterStbRsp(void* param, SDataBuf* pMsg, int32_t code) {
SMAlterStbRsp alterRsp = {0};
SDecoder coder = {0};
tDecoderInit(&coder, pMsg->pData, pMsg->len);
if (pMsg->len > 0){
if (pMsg->len > 0) {
code = tDecodeSMAlterStbRsp(&coder, &alterRsp); // pMsg->len == 0
if (code != TSDB_CODE_SUCCESS) {
setErrno(pRequest, code);
@ -512,7 +513,7 @@ int32_t processAlterStbRsp(void* param, SDataBuf* pMsg, int32_t code) {
doRequestCallback(pRequest, code);
} else {
if (tsem_post(&pRequest->body.rspSem) != 0){
if (tsem_post(&pRequest->body.rspSem) != 0) {
tscError("failed to post semaphore");
}
}
@ -520,8 +521,8 @@ int32_t processAlterStbRsp(void* param, SDataBuf* pMsg, int32_t code) {
}
static int32_t buildShowVariablesBlock(SArray* pVars, SSDataBlock** block) {
int32_t code = 0;
int32_t line = 0;
int32_t code = 0;
int32_t line = 0;
SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
TSDB_CHECK_NULL(pBlock, code, line, END, terrno);
pBlock->info.hasVarCol = true;
@ -545,6 +546,10 @@ static int32_t buildShowVariablesBlock(SArray* pVars, SSDataBlock** block) {
infoData.info.bytes = SHOW_VARIABLES_RESULT_FIELD4_LEN;
TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, terrno);
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
infoData.info.bytes = SHOW_VARIABLES_RESULT_FIELD5_LEN;
TSDB_CHECK_NULL(taosArrayPush(pBlock->pDataBlock, &infoData), code, line, END, terrno);
int32_t numOfCfg = taosArrayGetSize(pVars);
code = blockDataEnsureCapacity(pBlock, numOfCfg);
TSDB_CHECK_CODE(code, line, END);
@ -574,6 +579,13 @@ static int32_t buildShowVariablesBlock(SArray* pVars, SSDataBlock** block) {
code = colDataSetVal(pColInfo, i, scope, false);
TSDB_CHECK_CODE(code, line, END);
char category[TSDB_CONFIG_CATEGORY_LEN + VARSTR_HEADER_SIZE] = {0};
STR_WITH_MAXSIZE_TO_VARSTR(category, pInfo->category, TSDB_CONFIG_CATEGORY_LEN + VARSTR_HEADER_SIZE);
pColInfo = taosArrayGet(pBlock->pDataBlock, c++);
TSDB_CHECK_NULL(pColInfo, code, line, END, terrno);
code = colDataSetVal(pColInfo, i, category, false);
TSDB_CHECK_CODE(code, line, END);
char info[TSDB_CONFIG_INFO_LEN + VARSTR_HEADER_SIZE] = {0};
STR_WITH_MAXSIZE_TO_VARSTR(info, pInfo->info, TSDB_CONFIG_INFO_LEN + VARSTR_HEADER_SIZE);
pColInfo = taosArrayGet(pBlock->pDataBlock, c++);
@ -605,7 +617,7 @@ static int32_t buildShowVariablesRsp(SArray* pVars, SRetrieveTableRsp** pRsp) {
*pRsp = taosMemoryCalloc(1, rspSize);
if (NULL == *pRsp) {
code = terrno;
goto _exit;
goto _exit;
}
(*pRsp)->useconds = 0;
@ -617,7 +629,7 @@ static int32_t buildShowVariablesRsp(SArray* pVars, SRetrieveTableRsp** pRsp) {
(*pRsp)->numOfCols = htonl(SHOW_VARIABLES_RESULT_COLS);
int32_t len = blockEncode(pBlock, (*pRsp)->data + PAYLOAD_PREFIX_LEN, dataEncodeBufSize, SHOW_VARIABLES_RESULT_COLS);
if(len < 0) {
if (len < 0) {
uError("buildShowVariablesRsp error, len:%d", len);
code = terrno;
goto _exit;
@ -639,11 +651,11 @@ static int32_t buildShowVariablesRsp(SArray* pVars, SRetrieveTableRsp** pRsp) {
return TSDB_CODE_SUCCESS;
_exit:
if(*pRsp) {
if (*pRsp) {
taosMemoryFree(*pRsp);
*pRsp = NULL;
}
if(pBlock) {
if (pBlock) {
blockDataDestroy(pBlock);
pBlock = NULL;
}
@ -677,7 +689,7 @@ int32_t processShowVariablesRsp(void* param, SDataBuf* pMsg, int32_t code) {
if (pRequest->body.queryFp != NULL) {
doRequestCallback(pRequest, code);
} else {
if (tsem_post(&pRequest->body.rspSem) != 0){
if (tsem_post(&pRequest->body.rspSem) != 0) {
tscError("failed to post semaphore");
}
}
@ -685,8 +697,8 @@ int32_t processShowVariablesRsp(void* param, SDataBuf* pMsg, int32_t code) {
}
static int32_t buildCompactDbBlock(SCompactDbRsp* pRsp, SSDataBlock** block) {
int32_t code = 0;
int32_t line = 0;
int32_t code = 0;
int32_t line = 0;
SSDataBlock* pBlock = taosMemoryCalloc(1, sizeof(SSDataBlock));
TSDB_CHECK_NULL(pBlock, code, line, END, terrno);
pBlock->info.hasVarCol = true;
@ -772,7 +784,7 @@ static int32_t buildRetriveTableRspForCompactDb(SCompactDbRsp* pCompactDb, SRetr
(*pRsp)->numOfCols = htonl(COMPACT_DB_RESULT_COLS);
int32_t len = blockEncode(pBlock, (*pRsp)->data + PAYLOAD_PREFIX_LEN, dataEncodeBufSize, COMPACT_DB_RESULT_COLS);
if(len < 0) {
if (len < 0) {
uError("buildRetriveTableRspForCompactDb error, len:%d", len);
code = terrno;
goto _exit;
@ -794,24 +806,23 @@ static int32_t buildRetriveTableRspForCompactDb(SCompactDbRsp* pCompactDb, SRetr
return TSDB_CODE_SUCCESS;
_exit:
if(*pRsp) {
if (*pRsp) {
taosMemoryFree(*pRsp);
*pRsp = NULL;
}
if(pBlock) {
if (pBlock) {
blockDataDestroy(pBlock);
pBlock = NULL;
}
return code;
}
int32_t processCompactDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
SRequestObj* pRequest = param;
if (code != TSDB_CODE_SUCCESS) {
setErrno(pRequest, code);
} else {
SCompactDbRsp rsp = {0};
SCompactDbRsp rsp = {0};
SRetrieveTableRsp* pRes = NULL;
code = tDeserializeSCompactDbRsp(pMsg->pData, pMsg->len, &rsp);
if (TSDB_CODE_SUCCESS == code) {
@ -830,9 +841,9 @@ int32_t processCompactDbRsp(void* param, SDataBuf* pMsg, int32_t code) {
taosMemoryFree(pMsg->pEpSet);
if (pRequest->body.queryFp != NULL) {
pRequest->body.queryFp(((SSyncQueryParam *)pRequest->body.interParam)->userParam, pRequest, code);
pRequest->body.queryFp(((SSyncQueryParam*)pRequest->body.interParam)->userParam, pRequest, code);
} else {
if (tsem_post(&pRequest->body.rspSem) != 0){
if (tsem_post(&pRequest->body.rspSem) != 0) {
tscError("failed to post semaphore");
}
}

View File

@ -75,6 +75,10 @@ static int32_t stmtCreateRequest(STscStmt2* pStmt) {
if (pStmt->reqid != 0) {
pStmt->reqid++;
}
if (pStmt->db != NULL) {
taosMemoryFreeClear(pStmt->exec.pRequest->pDb);
pStmt->exec.pRequest->pDb = strdup(pStmt->db);
}
if (TSDB_CODE_SUCCESS == code) {
pStmt->exec.pRequest->syncQuery = true;
pStmt->exec.pRequest->isStmtBind = true;
@ -109,7 +113,7 @@ static int32_t stmtSwitchStatus(STscStmt2* pStmt, STMT_STATUS newStatus) {
}
break;
case STMT_SETTAGS:
if (STMT_STATUS_NE(SETTBNAME) && STMT_STATUS_NE(FETCH_FIELDS)) {
if (STMT_STATUS_EQ(INIT)) {
code = TSDB_CODE_TSC_STMT_API_ERROR;
}
break;
@ -412,6 +416,7 @@ static void stmtFreeTbCols(void* buf) {
static int32_t stmtCleanSQLInfo(STscStmt2* pStmt) {
STMT_DLOG_E("start to free SQL info");
taosMemoryFreeClear(pStmt->db);
taosMemoryFree(pStmt->sql.pBindInfo);
taosMemoryFree(pStmt->sql.queryRes.fields);
taosMemoryFree(pStmt->sql.queryRes.userFields);
@ -842,6 +847,7 @@ static int stmtSetDbName2(TAOS_STMT2* stmt, const char* dbName) {
STMT_DLOG("start to set dbName: %s", dbName);
pStmt->db = taosStrdup(dbName);
STMT_ERR_RET(stmtCreateRequest(pStmt));
// The SQL statement specifies a database name, overriding the previously specified database
@ -992,6 +998,19 @@ int stmtSetTbTags2(TAOS_STMT2* stmt, TAOS_STMT2_BIND* tags) {
STMT_ERR_RET(stmtSwitchStatus(pStmt, STMT_SETTAGS));
if (pStmt->bInfo.needParse && pStmt->sql.runTimes && pStmt->sql.type > 0 &&
STMT_TYPE_MULTI_INSERT != pStmt->sql.type) {
pStmt->bInfo.needParse = false;
}
STMT_ERR_RET(stmtCreateRequest(pStmt));
if (pStmt->bInfo.needParse) {
STMT_ERR_RET(stmtParseSql(pStmt));
}
if (pStmt->sql.stbInterlaceMode && NULL == pStmt->sql.siInfo.pDataCtx) {
STMT_ERR_RET(stmtInitStbInterlaceTableInfo(pStmt));
}
SBoundColInfo* tags_info = (SBoundColInfo*)pStmt->bInfo.boundTags;
if (tags_info->numOfBound <= 0 || tags_info->numOfCols <= 0) {
tscWarn("no tags or cols bound in sql, will not bound tags");
@ -1093,6 +1112,7 @@ static int stmtFetchStbColFields2(STscStmt2* pStmt, int32_t* fieldNum, TAOS_FIEL
STMT_ERR_RET(qBuildStmtStbColFields(*pDataBlock, pStmt->bInfo.boundTags, pStmt->bInfo.preCtbname, fieldNum, fields));
if (pStmt->bInfo.tbType == TSDB_SUPER_TABLE) {
pStmt->bInfo.needParse = true;
qDestroyStmtDataBlock(*pDataBlock);
if (taosHashRemove(pStmt->exec.pBlockHash, pStmt->bInfo.tbFName, strlen(pStmt->bInfo.tbFName)) != 0) {
tscError("get fileds %s remove exec blockHash fail", pStmt->bInfo.tbFName);
STMT_ERR_RET(TSDB_CODE_APP_ERROR);

View File

@ -651,6 +651,7 @@ int32_t tEncodeStreamHbRsp(SEncoder* pEncoder, const SMStreamHbRspMsg* pRsp) {
TAOS_CHECK_EXIT(tStartEncode(pEncoder));
TAOS_CHECK_EXIT(tEncodeI32(pEncoder, pRsp->msgId));
TAOS_CHECK_EXIT(tEncodeSEpSet(pEncoder, &pRsp->mndEpset));
tEndEncode(pEncoder);
_exit:
@ -663,6 +664,7 @@ int32_t tDecodeStreamHbRsp(SDecoder* pDecoder, SMStreamHbRspMsg* pRsp) {
TAOS_CHECK_EXIT(tStartDecode(pDecoder));
TAOS_CHECK_EXIT(tDecodeI32(pDecoder, &pRsp->msgId));
TAOS_CHECK_EXIT(tDecodeSEpSet(pDecoder, &pRsp->mndEpset));
tEndDecode(pDecoder);
_exit:

View File

@ -14,6 +14,7 @@
*/
#define _DEFAULT_SOURCE
#include "tglobal.h"
#include "tmsg.h"
#undef TD_MSG_NUMBER_
@ -76,7 +77,7 @@ static int32_t tSerializeSMonitorParas(SEncoder *encoder, const SMonitorParas *p
TAOS_CHECK_RETURN(tEncodeI32(encoder, pMonitorParas->tsSlowLogScope));
TAOS_CHECK_RETURN(tEncodeI32(encoder, pMonitorParas->tsSlowLogMaxLen));
TAOS_CHECK_RETURN(tEncodeI32(encoder, pMonitorParas->tsSlowLogThreshold));
TAOS_CHECK_RETURN(tEncodeI32(encoder, pMonitorParas->tsSlowLogThresholdTest)); //Obsolete
TAOS_CHECK_RETURN(tEncodeI32(encoder, pMonitorParas->tsSlowLogThresholdTest)); // Obsolete
TAOS_CHECK_RETURN(tEncodeCStr(encoder, pMonitorParas->tsSlowLogExceptDb));
return 0;
}
@ -87,7 +88,7 @@ static int32_t tDeserializeSMonitorParas(SDecoder *decoder, SMonitorParas *pMoni
TAOS_CHECK_RETURN(tDecodeI32(decoder, &pMonitorParas->tsSlowLogScope));
TAOS_CHECK_RETURN(tDecodeI32(decoder, &pMonitorParas->tsSlowLogMaxLen));
TAOS_CHECK_RETURN(tDecodeI32(decoder, &pMonitorParas->tsSlowLogThreshold));
TAOS_CHECK_RETURN(tDecodeI32(decoder, &pMonitorParas->tsSlowLogThresholdTest)); //Obsolete
TAOS_CHECK_RETURN(tDecodeI32(decoder, &pMonitorParas->tsSlowLogThresholdTest)); // Obsolete
TAOS_CHECK_RETURN(tDecodeCStrTo(decoder, pMonitorParas->tsSlowLogExceptDb));
return 0;
}
@ -1608,6 +1609,99 @@ _exit:
void tFreeSStatusReq(SStatusReq *pReq) { taosArrayDestroy(pReq->pVloads); }
int32_t tSerializeSConfigReq(void *buf, int32_t bufLen, SConfigReq *pReq) {
SEncoder encoder = {0};
int32_t code = 0;
int32_t lino;
int32_t tlen;
tEncoderInit(&encoder, buf, bufLen);
TAOS_CHECK_EXIT(tStartEncode(&encoder));
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->cver));
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->forceReadConfig));
if (pReq->forceReadConfig) {
TAOS_CHECK_EXIT(tSerializeSConfigArray(&encoder, pReq->array));
}
tEndEncode(&encoder);
_exit:
if (code) {
tlen = code;
} else {
tlen = encoder.pos;
}
tEncoderClear(&encoder);
return tlen;
}
int32_t tDeserializeSConfigReq(void *buf, int32_t bufLen, SConfigReq *pReq) {
SDecoder decoder = {0};
int32_t code = 0;
int32_t lino;
tDecoderInit(&decoder, buf, bufLen);
TAOS_CHECK_EXIT(tStartDecode(&decoder));
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->cver));
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->forceReadConfig));
if (pReq->forceReadConfig) {
pReq->array = taosArrayInit(128, sizeof(SConfigItem));
if (pReq->array == NULL) {
TAOS_CHECK_EXIT(terrno);
}
TAOS_CHECK_EXIT(tDeserializeSConfigArray(&decoder, pReq->array));
}
tEndDecode(&decoder);
_exit:
tDecoderClear(&decoder);
return code;
}
void tFreeSConfigReq(SConfigReq *pReq) { taosArrayDestroy(pReq->array); }
int32_t tSerializeSConfigRsp(void *buf, int32_t bufLen, SConfigRsp *pRsp) {
SEncoder encoder = {0};
int32_t code = 0;
int32_t lino;
int32_t tlen;
tEncoderInit(&encoder, buf, bufLen);
TAOS_CHECK_EXIT(tStartEncode(&encoder));
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pRsp->forceReadConfig));
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pRsp->isConifgVerified));
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pRsp->isVersionVerified));
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pRsp->cver));
if ((!pRsp->isConifgVerified) || (!pRsp->isVersionVerified)) {
TAOS_CHECK_EXIT(tSerializeSConfigArray(&encoder, pRsp->array));
}
tEndEncode(&encoder);
_exit:
if (code) {
tlen = code;
} else {
tlen = encoder.pos;
}
tEncoderClear(&encoder);
return tlen;
}
int32_t tDeserializeSConfigRsp(void *buf, int32_t bufLen, SConfigRsp *pRsp) {
SDecoder decoder = {0};
int32_t code = 0;
int32_t lino;
tDecoderInit(&decoder, buf, bufLen);
TAOS_CHECK_EXIT(tStartDecode(&decoder));
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pRsp->forceReadConfig));
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pRsp->isConifgVerified));
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pRsp->isVersionVerified));
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pRsp->cver));
if ((!pRsp->isConifgVerified) || (!pRsp->isVersionVerified)) {
pRsp->array = taosArrayInit(128, sizeof(SConfigItem));
TAOS_CHECK_EXIT(tDeserializeSConfigArray(&decoder, pRsp->array));
}
_exit:
tEndDecode(&decoder);
tDecoderClear(&decoder);
return code;
}
void tFreeSConfigRsp(SConfigRsp *pRsp) { taosArrayDestroy(pRsp->array); }
int32_t tSerializeSDnodeInfoReq(void *buf, int32_t bufLen, SDnodeInfoReq *pReq) {
int32_t code = 0, lino = 0;
int32_t tlen = 0;
@ -3160,6 +3254,7 @@ int32_t tSerializeSDCfgDnodeReq(void *buf, int32_t bufLen, SDCfgDnodeReq *pReq)
tEncoderInit(&encoder, buf, bufLen);
TAOS_CHECK_EXIT(tStartEncode(&encoder));
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->version));
TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->config));
TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->value));
tEndEncode(&encoder);
@ -3181,6 +3276,7 @@ int32_t tDeserializeSDCfgDnodeReq(void *buf, int32_t bufLen, SDCfgDnodeReq *pReq
tDecoderInit(&decoder, buf, bufLen);
TAOS_CHECK_EXIT(tStartDecode(&decoder));
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->version));
TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->config));
TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->value));
tEndDecode(&decoder);
@ -3943,6 +4039,12 @@ int32_t tSerializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq) {
TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->s3Compact));
TAOS_CHECK_EXIT(tEncodeCStr(&encoder, pReq->dnodeListStr));
// auto-compact parameters
TAOS_CHECK_EXIT(tEncodeI32v(&encoder, pReq->compactInterval));
TAOS_CHECK_EXIT(tEncodeI32v(&encoder, pReq->compactStartTime));
TAOS_CHECK_EXIT(tEncodeI32v(&encoder, pReq->compactEndTime));
TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->compactTimeOffset));
tEndEncode(&encoder);
_exit:
@ -4010,30 +4112,44 @@ int32_t tDeserializeSCreateDbReq(void *buf, int32_t bufLen, SCreateDbReq *pReq)
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->tsdbPageSize));
pReq->keepTimeOffset = TSDB_DEFAULT_KEEP_TIME_OFFSET;
if (!tDecodeIsEnd(&decoder)) {
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->keepTimeOffset));
} else {
pReq->keepTimeOffset = TSDB_DEFAULT_KEEP_TIME_OFFSET;
}
DECODESQL();
pReq->withArbitrator = TSDB_DEFAULT_DB_WITH_ARBITRATOR;
pReq->encryptAlgorithm = TSDB_DEFAULT_ENCRYPT_ALGO;
pReq->s3ChunkSize = TSDB_DEFAULT_S3_CHUNK_SIZE;
pReq->s3KeepLocal = TSDB_DEFAULT_S3_KEEP_LOCAL;
pReq->s3Compact = TSDB_DEFAULT_S3_COMPACT;
if (!tDecodeIsEnd(&decoder)) {
TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->withArbitrator));
TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->encryptAlgorithm));
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->s3ChunkSize));
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->s3KeepLocal));
TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->s3Compact));
} else {
pReq->withArbitrator = TSDB_DEFAULT_DB_WITH_ARBITRATOR;
pReq->encryptAlgorithm = TSDB_DEFAULT_ENCRYPT_ALGO;
pReq->s3ChunkSize = TSDB_DEFAULT_S3_CHUNK_SIZE;
pReq->s3KeepLocal = TSDB_DEFAULT_S3_KEEP_LOCAL;
pReq->s3Compact = TSDB_DEFAULT_S3_COMPACT;
}
if (!tDecodeIsEnd(&decoder)) {
TAOS_CHECK_EXIT(tDecodeCStrTo(&decoder, pReq->dnodeListStr));
}
if (!tDecodeIsEnd(&decoder)) {
TAOS_CHECK_EXIT(tDecodeI32v(&decoder, &pReq->compactInterval));
TAOS_CHECK_EXIT(tDecodeI32v(&decoder, &pReq->compactStartTime));
TAOS_CHECK_EXIT(tDecodeI32v(&decoder, &pReq->compactEndTime));
TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->compactTimeOffset));
} else {
pReq->compactInterval = TSDB_DEFAULT_COMPACT_INTERVAL;
pReq->compactStartTime = TSDB_DEFAULT_COMPACT_START_TIME;
pReq->compactEndTime = TSDB_DEFAULT_COMPACT_END_TIME;
pReq->compactTimeOffset = TSDB_DEFAULT_COMPACT_TIME_OFFSET;
}
tEndDecode(&decoder);
_exit:
@ -4084,6 +4200,11 @@ int32_t tSerializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) {
ENCODESQL();
TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->withArbitrator));
// auto compact config
TAOS_CHECK_EXIT(tEncodeI32v(&encoder, pReq->compactInterval));
TAOS_CHECK_EXIT(tEncodeI32v(&encoder, pReq->compactStartTime));
TAOS_CHECK_EXIT(tEncodeI32v(&encoder, pReq->compactEndTime));
TAOS_CHECK_EXIT(tEncodeI8(&encoder, pReq->compactTimeOffset));
tEndEncode(&encoder);
_exit:
@ -4151,6 +4272,19 @@ int32_t tDeserializeSAlterDbReq(void *buf, int32_t bufLen, SAlterDbReq *pReq) {
if (!tDecodeIsEnd(&decoder)) {
TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->withArbitrator));
}
// auto compact config
if (!tDecodeIsEnd(&decoder)) {
TAOS_CHECK_EXIT(tDecodeI32v(&decoder, &pReq->compactInterval));
TAOS_CHECK_EXIT(tDecodeI32v(&decoder, &pReq->compactStartTime));
TAOS_CHECK_EXIT(tDecodeI32v(&decoder, &pReq->compactEndTime));
TAOS_CHECK_EXIT(tDecodeI8(&decoder, &pReq->compactTimeOffset));
} else {
pReq->compactInterval = TSDB_DEFAULT_COMPACT_INTERVAL;
pReq->compactStartTime = TSDB_DEFAULT_COMPACT_START_TIME;
pReq->compactEndTime = TSDB_DEFAULT_COMPACT_END_TIME;
pReq->compactTimeOffset = TSDB_DEFAULT_COMPACT_TIME_OFFSET;
}
tEndDecode(&decoder);
_exit:
@ -4527,6 +4661,17 @@ int32_t tSerializeSCompactDbReq(void *buf, int32_t bufLen, SCompactDbReq *pReq)
TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->timeRange.skey));
TAOS_CHECK_EXIT(tEncodeI64(&encoder, pReq->timeRange.ekey));
ENCODESQL();
// encode vgroup list
int32_t numOfVgroups = taosArrayGetSize(pReq->vgroupIds);
TAOS_CHECK_EXIT(tEncodeI32(&encoder, numOfVgroups));
if (numOfVgroups > 0) {
for (int32_t i = 0; i < numOfVgroups; ++i) {
int64_t vgid = *(int64_t *)taosArrayGet(pReq->vgroupIds, i);
TAOS_CHECK_EXIT(tEncodeI64v(&encoder, vgid));
}
}
tEndEncode(&encoder);
_exit:
@ -4550,6 +4695,26 @@ int32_t tDeserializeSCompactDbReq(void *buf, int32_t bufLen, SCompactDbReq *pReq
TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pReq->timeRange.skey));
TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pReq->timeRange.ekey));
DECODESQL();
// decode vgroup list
if (!tDecodeIsEnd(&decoder)) {
int32_t numOfVgroups = 0;
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &numOfVgroups));
if (numOfVgroups > 0) {
pReq->vgroupIds = taosArrayInit(numOfVgroups, sizeof(int64_t));
if (NULL == pReq->vgroupIds) {
TAOS_CHECK_EXIT(terrno);
}
for (int32_t i = 0; i < numOfVgroups; ++i) {
int64_t vgid;
TAOS_CHECK_EXIT(tDecodeI64v(&decoder, &vgid));
if (taosArrayPush(pReq->vgroupIds, &vgid) == NULL) {
TAOS_CHECK_EXIT(terrno);
}
}
}
}
tEndDecode(&decoder);
_exit:
@ -4557,7 +4722,11 @@ _exit:
return code;
}
void tFreeSCompactDbReq(SCompactDbReq *pReq) { FREESQL(); }
void tFreeSCompactDbReq(SCompactDbReq *pReq) {
FREESQL();
taosArrayDestroy(pReq->vgroupIds);
pReq->vgroupIds = NULL;
}
int32_t tSerializeSCompactDbRsp(void *buf, int32_t bufLen, SCompactDbRsp *pRsp) {
SEncoder encoder = {0};
@ -5249,6 +5418,10 @@ int32_t tSerializeSDbCfgRspImpl(SEncoder *encoder, const SDbCfgRsp *pRsp) {
TAOS_CHECK_RETURN(tEncodeI32(encoder, pRsp->s3KeepLocal));
TAOS_CHECK_RETURN(tEncodeI8(encoder, pRsp->s3Compact));
TAOS_CHECK_RETURN(tEncodeI8(encoder, pRsp->hashMethod));
TAOS_CHECK_RETURN(tEncodeI32v(encoder, pRsp->compactInterval));
TAOS_CHECK_RETURN(tEncodeI32v(encoder, pRsp->compactStartTime));
TAOS_CHECK_RETURN(tEncodeI32v(encoder, pRsp->compactEndTime));
TAOS_CHECK_RETURN(tEncodeI8(encoder, pRsp->compactTimeOffset));
return 0;
}
@ -5324,27 +5497,40 @@ int32_t tDeserializeSDbCfgRspImpl(SDecoder *decoder, SDbCfgRsp *pRsp) {
}
TAOS_CHECK_RETURN(tDecodeI8(decoder, &pRsp->schemaless));
TAOS_CHECK_RETURN(tDecodeI16(decoder, &pRsp->sstTrigger));
pRsp->keepTimeOffset = TSDB_DEFAULT_KEEP_TIME_OFFSET;
if (!tDecodeIsEnd(decoder)) {
TAOS_CHECK_RETURN(tDecodeI32(decoder, &pRsp->keepTimeOffset));
} else {
pRsp->keepTimeOffset = TSDB_DEFAULT_KEEP_TIME_OFFSET;
}
pRsp->withArbitrator = TSDB_DEFAULT_DB_WITH_ARBITRATOR;
pRsp->encryptAlgorithm = TSDB_DEFAULT_ENCRYPT_ALGO;
pRsp->s3ChunkSize = TSDB_DEFAULT_S3_CHUNK_SIZE;
pRsp->s3KeepLocal = TSDB_DEFAULT_S3_KEEP_LOCAL;
pRsp->s3Compact = TSDB_DEFAULT_S3_COMPACT;
if (!tDecodeIsEnd(decoder)) {
TAOS_CHECK_RETURN(tDecodeI8(decoder, &pRsp->withArbitrator));
TAOS_CHECK_RETURN(tDecodeI8(decoder, &pRsp->encryptAlgorithm));
TAOS_CHECK_RETURN(tDecodeI32(decoder, &pRsp->s3ChunkSize));
TAOS_CHECK_RETURN(tDecodeI32(decoder, &pRsp->s3KeepLocal));
TAOS_CHECK_RETURN(tDecodeI8(decoder, &pRsp->s3Compact));
} else {
pRsp->withArbitrator = TSDB_DEFAULT_DB_WITH_ARBITRATOR;
pRsp->encryptAlgorithm = TSDB_DEFAULT_ENCRYPT_ALGO;
pRsp->s3ChunkSize = TSDB_DEFAULT_S3_CHUNK_SIZE;
pRsp->s3KeepLocal = TSDB_DEFAULT_S3_KEEP_LOCAL;
pRsp->s3Compact = TSDB_DEFAULT_S3_COMPACT;
}
if (!tDecodeIsEnd(decoder)) {
TAOS_CHECK_RETURN(tDecodeI8(decoder, &pRsp->hashMethod));
} else {
pRsp->hashMethod = 1; // default value
}
if (!tDecodeIsEnd(decoder)) {
TAOS_CHECK_RETURN(tDecodeI32v(decoder, &pRsp->compactInterval));
TAOS_CHECK_RETURN(tDecodeI32v(decoder, &pRsp->compactStartTime));
TAOS_CHECK_RETURN(tDecodeI32v(decoder, &pRsp->compactEndTime));
TAOS_CHECK_RETURN(tDecodeI8(decoder, &pRsp->compactTimeOffset));
} else {
pRsp->compactInterval = TSDB_DEFAULT_COMPACT_INTERVAL;
pRsp->compactStartTime = TSDB_DEFAULT_COMPACT_START_TIME;
pRsp->compactEndTime = TSDB_DEFAULT_COMPACT_END_TIME;
pRsp->compactTimeOffset = TSDB_DEFAULT_COMPACT_TIME_OFFSET;
}
return 0;
}
@ -5624,6 +5810,7 @@ int32_t tEncodeSVariablesInfo(SEncoder *pEncoder, SVariablesInfo *pInfo) {
TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pInfo->name));
TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pInfo->value));
TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pInfo->scope));
TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pInfo->category));
return 0;
}
@ -5631,6 +5818,7 @@ int32_t tDecodeSVariablesInfo(SDecoder *pDecoder, SVariablesInfo *pInfo) {
TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pInfo->name));
TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pInfo->value));
TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pInfo->scope));
TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pInfo->category));
return 0;
}
@ -6800,6 +6988,9 @@ int32_t tSerializeSQueryCompactProgressRsp(void *buf, int32_t bufLen, SQueryComp
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->dnodeId));
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->numberFileset));
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pReq->finished));
// 1. add progress and remaining time
TAOS_CHECK_EXIT(tEncodeI32v(&encoder, pReq->progress));
TAOS_CHECK_EXIT(tEncodeI64v(&encoder, pReq->remainingTime));
tEndEncode(&encoder);
@ -6824,6 +7015,14 @@ int32_t tDeserializeSQueryCompactProgressRsp(void *buf, int32_t bufLen, SQueryCo
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->dnodeId));
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->numberFileset));
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pReq->finished));
// 1. decode progress and remaining time
if (!tDecodeIsEnd(&decoder)) {
TAOS_CHECK_EXIT(tDecodeI32v(&decoder, &pReq->progress));
TAOS_CHECK_EXIT(tDecodeI64v(&decoder, &pReq->remainingTime));
} else {
pReq->progress = 0;
pReq->remainingTime = 0;
}
tEndDecode(&decoder);
_exit:
@ -10182,7 +10381,7 @@ int tDecodeSVCreateTbReq(SDecoder *pCoder, SVCreateTbReq *pReq) {
char name[TSDB_COL_NAME_LEN] = {0};
char *tmp = NULL;
TAOS_CHECK_EXIT(tDecodeCStr(pCoder, &tmp));
strncpy(name, tmp, TSDB_COL_NAME_LEN - 1);
tstrncpy(name, tmp, TSDB_COL_NAME_LEN);
if (taosArrayPush(pReq->ctb.tagName, name) == NULL) {
TAOS_CHECK_EXIT(terrno);
}
@ -12218,7 +12417,7 @@ void setFieldWithOptions(SFieldWithOptions *fieldWithOptions, SField *field) {
fieldWithOptions->bytes = field->bytes;
fieldWithOptions->flags = field->flags;
fieldWithOptions->type = field->type;
strncpy(fieldWithOptions->name, field->name, TSDB_COL_NAME_LEN);
tstrncpy(fieldWithOptions->name, field->name, TSDB_COL_NAME_LEN);
}
int32_t tSerializeTableTSMAInfoReq(void *buf, int32_t bufLen, const STableTSMAInfoReq *pReq) {
SEncoder encoder = {0};

View File

@ -329,6 +329,7 @@ static const SSysDbTableSchema variablesSchema[] = {
{.name = "name", .bytes = TSDB_CONFIG_OPTION_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
{.name = "value", .bytes = TSDB_CONFIG_PATH_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
{.name = "scope", .bytes = TSDB_CONFIG_SCOPE_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
{.name = "category", .bytes = TSDB_CONFIG_CATEGORY_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
{.name = "info", .bytes = TSDB_CONFIG_INFO_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
};
@ -398,6 +399,8 @@ static const SSysDbTableSchema userCompactsDetailSchema[] = {
{.name = "number_fileset", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
{.name = "finished", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
{.name = "start_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
{.name = "progress(%)", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
{.name = "remain_time(s)", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = false},
};
static const SSysDbTableSchema anodesSchema[] = {
@ -414,6 +417,18 @@ static const SSysDbTableSchema anodesFullSchema[] = {
{.name = "algo", .bytes = TSDB_ANALYTIC_ALGO_NAME_LEN + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = true},
};
static const SSysDbTableSchema filesetsFullSchema[] = {
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
{.name = "vgroup_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
{.name = "fileset_id", .bytes = 4, .type = TSDB_DATA_TYPE_INT, .sysInfo = false},
{.name = "start_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
{.name = "end_time", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
{.name = "total_size", .bytes = 8, .type = TSDB_DATA_TYPE_BIGINT, .sysInfo = false},
{.name = "last_compact", .bytes = 8, .type = TSDB_DATA_TYPE_TIMESTAMP, .sysInfo = false},
{.name = "shold_compact", .bytes = 1, .type = TSDB_DATA_TYPE_BOOL, .sysInfo = false},
// {.name = "details", .bytes = 256 + VARSTR_HEADER_SIZE, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
};
static const SSysDbTableSchema tsmaSchema[] = {
{.name = "tsma_name", .bytes = SYSTABLE_SCH_TABLE_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
{.name = "db_name", .bytes = SYSTABLE_SCH_DB_NAME_LEN, .type = TSDB_DATA_TYPE_VARCHAR, .sysInfo = false},
@ -505,6 +520,7 @@ static const SSysTableMeta infosMeta[] = {
{TSDB_INS_TABLE_ANODES, anodesSchema, tListLen(anodesSchema), true},
{TSDB_INS_TABLE_ANODES_FULL, anodesFullSchema, tListLen(anodesFullSchema), true},
{TSDB_INS_DISK_USAGE, diskUsageSchema, tListLen(diskUsageSchema), false},
{TSDB_INS_TABLE_FILESETS, filesetsFullSchema, tListLen(filesetsFullSchema), false},
};
static const SSysDbTableSchema connectionsSchema[] = {

View File

@ -1434,7 +1434,7 @@ static void debugPrintTagVal(int8_t type, const void *val, int32_t vlen, const c
case TSDB_DATA_TYPE_NCHAR:
case TSDB_DATA_TYPE_GEOMETRY: {
char tmpVal[32] = {0};
strncpy(tmpVal, val, vlen > 31 ? 31 : vlen);
tstrncpy(tmpVal, val, vlen > 31 ? 31 : vlen);
printf("%s:%d type:%d vlen:%d, val:\"%s\"\n", tag, ln, (int32_t)type, vlen, tmpVal);
} break;
case TSDB_DATA_TYPE_FLOAT:

File diff suppressed because it is too large Load Diff

View File

@ -14,10 +14,10 @@
*/
#define _DEFAULT_SOURCE
#include "tmisce.h"
#include "tdatablock.h"
#include "tglobal.h"
#include "tjson.h"
#include "tmisce.h"
int32_t taosGetFqdnPortFromEp(const char* ep, SEp* pEp) {
pEp->port = 0;
@ -333,6 +333,18 @@ int32_t dumpConfToDataBlock(SSDataBlock* pBlock, int32_t startCol) {
}
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, scope, false), NULL, _exit);
char category[TSDB_CONFIG_CATEGORY_LEN + VARSTR_HEADER_SIZE] = {0};
TAOS_CHECK_GOTO(cfgDumpItemCategory(pItem, &category[VARSTR_HEADER_SIZE], TSDB_CONFIG_CATEGORY_LEN, &valueLen),
NULL, _exit);
varDataSetLen(category, valueLen);
pColInfo = taosArrayGet(pBlock->pDataBlock, col++);
if (pColInfo == NULL) {
code = terrno;
TAOS_CHECK_GOTO(code, NULL, _exit);
}
TAOS_CHECK_GOTO(colDataSetVal(pColInfo, numOfRows, category, false), NULL, _exit);
char info[TSDB_CONFIG_INFO_LEN + VARSTR_HEADER_SIZE] = {0};
if (strcasecmp(pItem->name, "dataDir") == 0 && pDiskCfg) {
char* buf = &info[VARSTR_HEADER_SIZE];

View File

@ -81,7 +81,7 @@ SName* tNameDup(const SName* name) {
}
int32_t tNameGetDbName(const SName* name, char* dst) {
strncpy(dst, name->dbname, tListLen(name->dbname));
tstrncpy(dst, name->dbname, tListLen(name->dbname));
return 0;
}

View File

@ -28,6 +28,7 @@ typedef struct SDnodeMgmt {
const char *path;
const char *name;
TdThread statusThread;
TdThread configThread;
TdThread statusInfoThread;
TdThread notifyThread;
TdThread monitorThread;
@ -50,6 +51,7 @@ typedef struct SDnodeMgmt {
// dmHandle.c
SArray *dmGetMsgHandles();
void dmSendStatusReq(SDnodeMgmt *pMgmt);
void dmSendConfigReq(SDnodeMgmt *pMgmt);
void dmUpdateStatusInfo(SDnodeMgmt *pMgmt);
void dmSendNotifyReq(SDnodeMgmt *pMgmt, SNotifyReq *pReq);
int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
@ -64,6 +66,7 @@ int32_t dmProcessCreateEncryptKeyReq(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
// dmWorker.c
int32_t dmPutNodeMsgToMgmtQueue(SDnodeMgmt *pMgmt, SRpcMsg *pMsg);
int32_t dmStartStatusThread(SDnodeMgmt *pMgmt);
int32_t dmStartConfigThread(SDnodeMgmt *pMgmt);
int32_t dmStartStatusInfoThread(SDnodeMgmt *pMgmt);
void dmStopStatusThread(SDnodeMgmt *pMgmt);
void dmStopStatusInfoThread(SDnodeMgmt *pMgmt);

View File

@ -20,6 +20,7 @@
#include "systable.h"
#include "tanalytics.h"
#include "tchecksum.h"
#include "tutil.h"
extern SConfig *tsCfg;
@ -197,7 +198,8 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
req.clusterCfg.monitorParas.tsSlowLogThreshold = tsSlowLogThreshold;
tstrncpy(req.clusterCfg.monitorParas.tsSlowLogExceptDb, tsSlowLogExceptDb, TSDB_DB_NAME_LEN);
char timestr[32] = "1970-01-01 00:00:00.00";
if (taosParseTime(timestr, &req.clusterCfg.checkTime, (int32_t)strlen(timestr), TSDB_TIME_PRECISION_MILLI, NULL) != 0) {
if (taosParseTime(timestr, &req.clusterCfg.checkTime, (int32_t)strlen(timestr), TSDB_TIME_PRECISION_MILLI, NULL) !=
0) {
dError("failed to parse time since %s", tstrerror(code));
}
memcpy(req.clusterCfg.timezone, tsTimezoneStr, TD_TIMEZONE_LEN);
@ -282,6 +284,135 @@ void dmSendStatusReq(SDnodeMgmt *pMgmt) {
dmProcessStatusRsp(pMgmt, &rpcRsp);
}
static void dmProcessConfigRsp(SDnodeMgmt *pMgmt, SRpcMsg *pRsp) {
const STraceId *trace = &pRsp->info.traceId;
int32_t code = 0;
SConfigRsp configRsp = {0};
bool needStop = false;
if (pRsp->code != 0) {
if (pRsp->code == TSDB_CODE_MND_DNODE_NOT_EXIST && !pMgmt->pData->dropped && pMgmt->pData->dnodeId > 0) {
dGInfo("dnode:%d, set to dropped since not exist in mnode", pMgmt->pData->dnodeId);
pMgmt->pData->dropped = 1;
if (dmWriteEps(pMgmt->pData) != 0) {
dError("failed to write dnode file");
}
dInfo("dnode will exit since it is in the dropped state");
(void)raise(SIGINT);
}
} else {
bool needUpdate = false;
if (pRsp->pCont != NULL && pRsp->contLen > 0 &&
tDeserializeSConfigRsp(pRsp->pCont, pRsp->contLen, &configRsp) == 0) {
// Try to use cfg file in current dnode.
if (configRsp.forceReadConfig) {
if (configRsp.isConifgVerified) {
uInfo("force read config and check config verified");
code = taosPersistGlobalConfig(taosGetGlobalCfg(tsCfg), pMgmt->path, configRsp.cver);
if (code != TSDB_CODE_SUCCESS) {
dError("failed to persist global config since %s", tstrerror(code));
goto _exit;
}
needUpdate = true;
} else {
// log the difference configurations
printConfigNotMatch(configRsp.array);
needStop = true;
goto _exit;
}
}
// Try to use cfg from mnode sdb.
if (!configRsp.isVersionVerified) {
uInfo("config version not verified, update config");
needUpdate = true;
code = taosPersistGlobalConfig(configRsp.array, pMgmt->path, configRsp.cver);
if (code != TSDB_CODE_SUCCESS) {
dError("failed to persist global config since %s", tstrerror(code));
goto _exit;
}
}
}
if (needUpdate) {
code = cfgUpdateFromArray(tsCfg, configRsp.array);
if (code != TSDB_CODE_SUCCESS) {
dError("failed to update config since %s", tstrerror(code));
goto _exit;
}
code = setAllConfigs(tsCfg);
if (code != TSDB_CODE_SUCCESS) {
dError("failed to set all configs since %s", tstrerror(code));
goto _exit;
}
}
code = taosPersistLocalConfig(pMgmt->path);
if (code != TSDB_CODE_SUCCESS) {
dError("failed to persist local config since %s", tstrerror(code));
}
tsConfigInited = 1;
}
_exit:
tFreeSConfigRsp(&configRsp);
rpcFreeCont(pRsp->pCont);
if (needStop) {
dmStop();
}
}
void dmSendConfigReq(SDnodeMgmt *pMgmt) {
int32_t code = 0;
SConfigReq req = {0};
req.cver = tsdmConfigVersion;
req.forceReadConfig = tsForceReadConfig;
req.array = taosGetGlobalCfg(tsCfg);
dDebug("send config req to mnode, configVersion:%d", req.cver);
int32_t contLen = tSerializeSConfigReq(NULL, 0, &req);
if (contLen < 0) {
dError("failed to serialize status req since %s", tstrerror(contLen));
return;
}
void *pHead = rpcMallocCont(contLen);
if (pHead == NULL) {
dError("failed to malloc cont since %s", tstrerror(contLen));
return;
}
contLen = tSerializeSConfigReq(pHead, contLen, &req);
if (contLen < 0) {
rpcFreeCont(pHead);
dError("failed to serialize status req since %s", tstrerror(contLen));
return;
}
SRpcMsg rpcMsg = {.pCont = pHead,
.contLen = contLen,
.msgType = TDMT_MND_CONFIG,
.info.ahandle = 0,
.info.notFreeAhandle = 1,
.info.refId = 0,
.info.noResp = 0,
.info.handle = 0};
SRpcMsg rpcRsp = {0};
SEpSet epSet = {0};
int8_t epUpdated = 0;
(void)dmGetMnodeEpSet(pMgmt->pData, &epSet);
dDebug("send status req to mnode, statusSeq:%d, begin to send rpc msg", pMgmt->statusSeq);
code =
rpcSendRecvWithTimeout(pMgmt->msgCb.statusRpc, &epSet, &rpcMsg, &rpcRsp, &epUpdated, tsStatusInterval * 5 * 1000);
if (code != 0) {
dError("failed to send status req since %s", tstrerror(code));
return;
}
if (rpcRsp.code != 0) {
dError("failed to send config req since %s", tstrerror(rpcRsp.code));
return;
}
dmProcessConfigRsp(pMgmt, &rpcRsp);
}
void dmUpdateStatusInfo(SDnodeMgmt *pMgmt) {
SMonVloadInfo vinfo = {0};
dDebug("begin to get vnode loads");
@ -344,6 +475,27 @@ int32_t dmProcessGrantRsp(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) {
return 0;
}
extern void tsdbAlterMaxCompactTasks();
static int32_t dmAlterMaxCompactTask(const char *value) {
int32_t max_compact_tasks;
char *endptr = NULL;
max_compact_tasks = taosStr2Int32(value, &endptr, 10);
if (endptr == value || endptr[0] != '\0') {
return TSDB_CODE_INVALID_MSG;
}
if (max_compact_tasks != tsNumOfCompactThreads) {
dInfo("alter max compact tasks from %d to %d", tsNumOfCompactThreads, max_compact_tasks);
tsNumOfCompactThreads = max_compact_tasks;
#ifdef TD_ENTERPRISE
tsdbAlterMaxCompactTasks();
#endif
}
return TSDB_CODE_SUCCESS;
}
int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) {
int32_t code = 0;
SDCfgDnodeReq cfgReq = {0};
@ -351,20 +503,46 @@ int32_t dmProcessConfigReq(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) {
return TSDB_CODE_INVALID_MSG;
}
if (strncmp(cfgReq.config, tsAlterCompactTaskKeywords, strlen(tsAlterCompactTaskKeywords) + 1) == 0) {
return dmAlterMaxCompactTask(cfgReq.value);
}
dInfo("start to config, option:%s, value:%s", cfgReq.config, cfgReq.value);
SConfig *pCfg = taosGetCfg();
SConfig *pCfg = taosGetCfg();
SConfigItem *pItem = NULL;
code = cfgSetItem(pCfg, cfgReq.config, cfgReq.value, CFG_STYPE_ALTER_SERVER_CMD, true);
code = cfgGetAndSetItem(pCfg, &pItem, cfgReq.config, cfgReq.value, CFG_STYPE_ALTER_SERVER_CMD, true);
if (code != 0) {
if (strncasecmp(cfgReq.config, "resetlog", strlen("resetlog")) == 0) {
code = 0;
TAOS_CHECK_RETURN(taosCfgDynamicOptions(pCfg, cfgReq.config, true));
return TSDB_CODE_SUCCESS;
} else {
return code;
}
}
if (pItem == NULL) {
return TSDB_CODE_CFG_NOT_FOUND;
}
if (!isConifgItemLazyMode(pItem)) {
TAOS_CHECK_RETURN(taosCfgDynamicOptions(pCfg, cfgReq.config, true));
}
return taosCfgDynamicOptions(pCfg, cfgReq.config, true);
if (pItem->category == CFG_CATEGORY_GLOBAL) {
code = taosPersistGlobalConfig(taosGetGlobalCfg(pCfg), pMgmt->path, tsdmConfigVersion);
if (code != TSDB_CODE_SUCCESS) {
dError("failed to persist global config since %s", tstrerror(code));
}
} else {
code = taosPersistLocalConfig(pMgmt->path);
if (code != TSDB_CODE_SUCCESS) {
dError("failed to persist local config since %s", tstrerror(code));
}
}
if (cfgReq.version > 0) {
tsdmConfigVersion = cfgReq.version;
}
return code;
}
int32_t dmProcessCreateEncryptKeyReq(SDnodeMgmt *pMgmt, SRpcMsg *pMsg) {

View File

@ -23,6 +23,10 @@ static int32_t dmStartMgmt(SDnodeMgmt *pMgmt) {
if ((code = dmStartStatusThread(pMgmt)) != 0) {
return code;
}
if ((code = dmStartConfigThread(pMgmt)) != 0) {
return code;
}
if ((code = dmStartStatusInfoThread(pMgmt)) != 0) {
return code;
}

View File

@ -47,6 +47,25 @@ static void *dmStatusThreadFp(void *param) {
return NULL;
}
static void *dmConfigThreadFp(void *param) {
SDnodeMgmt *pMgmt = param;
int64_t lastTime = taosGetTimestampMs();
setThreadName("dnode-config");
while (1) {
taosMsleep(200);
if (pMgmt->pData->dropped || pMgmt->pData->stopped || tsConfigInited) break;
int64_t curTime = taosGetTimestampMs();
if (curTime < lastTime) lastTime = curTime;
float interval = (curTime - lastTime) / 1000.0f;
if (interval >= tsStatusInterval) {
dmSendConfigReq(pMgmt);
lastTime = curTime;
}
}
return NULL;
}
static void *dmStatusInfoThreadFp(void *param) {
SDnodeMgmt *pMgmt = param;
int64_t lastTime = taosGetTimestampMs();
@ -312,6 +331,22 @@ int32_t dmStartStatusThread(SDnodeMgmt *pMgmt) {
return 0;
}
int32_t dmStartConfigThread(SDnodeMgmt *pMgmt) {
int32_t code = 0;
TdThreadAttr thAttr;
(void)taosThreadAttrInit(&thAttr);
(void)taosThreadAttrSetDetachState(&thAttr, PTHREAD_CREATE_DETACHED);
if (taosThreadCreate(&pMgmt->configThread, &thAttr, dmConfigThreadFp, pMgmt) != 0) {
code = TAOS_SYSTEM_ERROR(errno);
dError("failed to create config thread since %s", tstrerror(code));
return code;
}
(void)taosThreadAttrDestroy(&thAttr);
tmsgReportStartup("config-status", "initialized");
return 0;
}
int32_t dmStartStatusInfoThread(SDnodeMgmt *pMgmt) {
int32_t code = 0;
TdThreadAttr thAttr;

View File

@ -200,6 +200,7 @@ SArray *mmGetMsgHandles() {
if (dmSetMgmtHandle(pArray, TDMT_MND_KILL_CONN, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_MND_HEARTBEAT, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_MND_STATUS, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_MND_CONFIG, mmPutMsgToWriteQueue, 0) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_MND_NOTIFY, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_MND_SYSTABLE_RETRIEVE, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;
if (dmSetMgmtHandle(pArray, TDMT_MND_AUTH, mmPutMsgToReadQueue, 0) == NULL) goto _OVER;

View File

@ -211,7 +211,7 @@ static void vmGenerateVnodeCfg(SCreateVnodeReq *pCreate, SVnodeCfg *pCfg) {
#if defined(TD_ENTERPRISE)
pCfg->tdbEncryptAlgorithm = pCreate->encryptAlgorithm;
if (pCfg->tdbEncryptAlgorithm == DND_CA_SM4) {
strncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
tstrncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
}
#else
pCfg->tdbEncryptAlgorithm = 0;

View File

@ -551,7 +551,7 @@ int32_t dmGetEncryptKey() {
goto _OVER;
}
strncpy(tsEncryptKey, encryptKey, ENCRYPT_KEY_LEN + 1);
tstrncpy(tsEncryptKey, encryptKey, ENCRYPT_KEY_LEN + 1);
taosMemoryFreeClear(encryptKey);
tsEncryptionKeyChksum = taosCalcChecksum(0, tsEncryptKey, strlen(tsEncryptKey));
tsEncryptionKeyStat = ENCRYPT_KEY_STAT_LOADED;

View File

@ -17,6 +17,7 @@
void* serverLoop(void* param) {
TestServer* server = (TestServer*)param;
cfgInit(&tsCfg);
if (dmInit() != 0) {
return NULL;

View File

@ -25,19 +25,17 @@ extern "C" {
int32_t mndInitCompactDetail(SMnode *pMnode);
void mndCleanupCompactDetail(SMnode *pMnode);
void tFreeCompactDetailObj(SCompactDetailObj *pCompact);
int32_t tSerializeSCompactDetailObj(void *buf, int32_t bufLen, const SCompactDetailObj *pObj);
int32_t tDeserializeSCompactDetailObj(void *buf, int32_t bufLen, SCompactDetailObj *pObj);
void tFreeCompactDetailObj(SCompactDetailObj *pCompact);
SSdbRaw* mndCompactDetailActionEncode(SCompactDetailObj *pCompact);
SSdbRow* mndCompactDetailActionDecode(SSdbRaw *pRaw);
SSdbRaw *mndCompactDetailActionEncode(SCompactDetailObj *pCompact);
SSdbRow *mndCompactDetailActionDecode(SSdbRaw *pRaw);
int32_t mndCompactDetailActionInsert(SSdb *pSdb, SCompactDetailObj *pCompact);
int32_t mndCompactDetailActionDelete(SSdb *pSdb, SCompactDetailObj *pCompact);
int32_t mndCompactDetailActionUpdate(SSdb *pSdb, SCompactDetailObj *pOldCompact, SCompactDetailObj *pNewCompact);
int32_t mndAddCompactDetailToTran(SMnode *pMnode, STrans *pTrans, SCompactObj* pCompact, SVgObj *pVgroup,
SVnodeGid *pVgid, int32_t index);
int32_t mndAddCompactDetailToTran(SMnode *pMnode, STrans *pTrans, SCompactObj *pCompact, SVgObj *pVgroup,
SVnodeGid *pVgid, int32_t index);
int32_t mndRetrieveCompactDetail(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);

View File

@ -0,0 +1,39 @@
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _TD_MND_CONFIG_H_
#define _TD_MND_CONFIG_H_
#include "mndInt.h"
#ifdef __cplusplus
extern "C" {
#endif
int32_t mndInitConfig(SMnode *pMnode);
SSdbRaw *mnCfgActionEncode(SConfigObj *pCfg);
SSdbRow *mndCfgActionDecode(SSdbRaw *pRaw);
static int32_t mndCfgActionInsert(SSdb *pSdb, SConfigObj *obj);
static int32_t mndCfgActionDelete(SSdb *pSdb, SConfigObj *obj);
static int32_t mndCfgActionUpdate(SSdb *pSdb, SConfigObj *oldItem, SConfigObj *newObj);
static int32_t mndCfgActionDeploy(SMnode *pMnode);
static int32_t mndCfgActionPrepare(SMnode *pMnode);
static int32_t mndProcessConfigReq(SRpcMsg *pReq);
#ifdef __cplusplus
}
#endif
#endif /*_TD_MND_ARBGROUP_H_*/

View File

@ -106,8 +106,8 @@ typedef enum {
TRN_CONFLICT_GLOBAL = 1,
TRN_CONFLICT_DB = 2,
TRN_CONFLICT_DB_INSIDE = 3,
// TRN_CONFLICT_TOPIC = 4,
// TRN_CONFLICT_TOPIC_INSIDE = 5,
// TRN_CONFLICT_TOPIC = 4,
// TRN_CONFLICT_TOPIC_INSIDE = 5,
TRN_CONFLICT_ARBGROUP = 6,
TRN_CONFLICT_TSMA = 7,
} ETrnConflct;
@ -316,6 +316,25 @@ typedef struct {
TdThreadMutex mutex;
} SArbGroup;
typedef struct {
char name[CFG_NAME_MAX_LEN];
ECfgDataType dtype;
union {
bool bval;
float fval;
int32_t i32;
int64_t i64;
char* str;
};
} SConfigObj;
int32_t tEncodeSConfigObj(SEncoder* pEncoder, const SConfigObj* pObj);
int32_t tDecodeSConfigObj(SDecoder* pDecoder, SConfigObj* pObj);
SConfigObj* mndInitConfigObj(SConfigItem* pItem);
SConfigObj* mndInitConfigVersion();
int32_t mndUpdateObj(SConfigObj* pObj, const char* name, char* value);
void tFreeSConfigObj(SConfigObj* obj);
typedef struct {
int32_t maxUsers;
int32_t maxDbs;
@ -423,6 +442,10 @@ typedef struct {
int8_t s3Compact;
int8_t withArbitrator;
int8_t encryptAlgorithm;
int8_t compactTimeOffset; // hour
int32_t compactInterval; // minute
int32_t compactStartTime; // minute
int32_t compactEndTime; // minute
} SDbCfg;
typedef struct {
@ -489,8 +512,8 @@ typedef struct {
int64_t dstTbUid;
int8_t intervalUnit;
int8_t slidingUnit;
int8_t timezone; // int8_t is not enough, timezone is unit of second
int32_t dstVgId; // for stream
int8_t timezone; // int8_t is not enough, timezone is unit of second
int32_t dstVgId; // for stream
int64_t interval;
int64_t offset;
int64_t sliding;
@ -649,12 +672,12 @@ typedef struct {
int32_t maxPollIntervalMs;
} SMqConsumerObj;
int32_t tNewSMqConsumerObj(int64_t consumerId, char *cgroup, int8_t updateType,
char *topic, SCMSubscribeReq *subscribe, SMqConsumerObj** ppConsumer);
void tClearSMqConsumerObj(SMqConsumerObj* pConsumer);
void tDeleteSMqConsumerObj(SMqConsumerObj* pConsumer);
int32_t tEncodeSMqConsumerObj(void** buf, const SMqConsumerObj* pConsumer);
void* tDecodeSMqConsumerObj(const void* buf, SMqConsumerObj* pConsumer, int8_t sver);
int32_t tNewSMqConsumerObj(int64_t consumerId, char* cgroup, int8_t updateType, char* topic, SCMSubscribeReq* subscribe,
SMqConsumerObj** ppConsumer);
void tClearSMqConsumerObj(SMqConsumerObj* pConsumer);
void tDeleteSMqConsumerObj(SMqConsumerObj* pConsumer);
int32_t tEncodeSMqConsumerObj(void** buf, const SMqConsumerObj* pConsumer);
void* tDecodeSMqConsumerObj(const void* buf, SMqConsumerObj* pConsumer, int8_t sver);
typedef struct {
int32_t vgId;
@ -693,11 +716,11 @@ typedef struct {
char* qmsg; // SubPlanToString
} SMqSubscribeObj;
int32_t tNewSubscribeObj(const char *key, SMqSubscribeObj **ppSub);
int32_t tCloneSubscribeObj(const SMqSubscribeObj* pSub, SMqSubscribeObj **ppSub);
void tDeleteSubscribeObj(SMqSubscribeObj* pSub);
int32_t tEncodeSubscribeObj(void** buf, const SMqSubscribeObj* pSub);
void* tDecodeSubscribeObj(const void* buf, SMqSubscribeObj* pSub, int8_t sver);
int32_t tNewSubscribeObj(const char* key, SMqSubscribeObj** ppSub);
int32_t tCloneSubscribeObj(const SMqSubscribeObj* pSub, SMqSubscribeObj** ppSub);
void tDeleteSubscribeObj(SMqSubscribeObj* pSub);
int32_t tEncodeSubscribeObj(void** buf, const SMqSubscribeObj* pSub);
void* tDecodeSubscribeObj(const void* buf, SMqSubscribeObj* pSub, int8_t sver);
// typedef struct {
// int32_t epoch;
@ -846,6 +869,8 @@ typedef struct {
int64_t startTime;
int32_t newNumberFileset;
int32_t newFinished;
int32_t progress;
int64_t remainingTime;
} SCompactDetailObj;
typedef struct {

View File

@ -457,7 +457,7 @@ int32_t mndProcessConfigClusterReq(SRpcMsg *pReq) {
_exit:
tFreeSMCfgClusterReq(&cfgReq);
if (code != 0) {
mError("cluster: failed to config:%s %s since %s", cfgReq.config, cfgReq.value, terrstr());
mError("cluster: failed to config:%s %s since %s", cfgReq.config, cfgReq.value, tstrerror(code));
} else {
mInfo("cluster: success to config:%s %s", cfgReq.config, cfgReq.value);
}

View File

@ -549,6 +549,8 @@ static int32_t mndUpdateCompactProgress(SMnode *pMnode, SRpcMsg *pReq, int32_t c
if (pDetail->compactId == compactId && pDetail->vgId == rsp->vgId && pDetail->dnodeId == rsp->dnodeId) {
pDetail->newNumberFileset = rsp->numberFileset;
pDetail->newFinished = rsp->finished;
pDetail->progress = rsp->progress;
pDetail->remainingTime = rsp->remainingTime;
sdbCancelFetch(pMnode->pSdb, pIter);
sdbRelease(pMnode->pSdb, pDetail);
@ -859,7 +861,7 @@ static int32_t mndSaveCompactProgress(SMnode *pMnode, int32_t compactId) {
return 0;
}
void mndCompactPullup(SMnode *pMnode) {
static void mndCompactPullup(SMnode *pMnode) {
int32_t code = 0;
SSdb *pSdb = pMnode->pSdb;
SArray *pArray = taosArrayInit(sdbGetSize(pSdb, SDB_COMPACT), sizeof(int32_t));
@ -891,9 +893,115 @@ void mndCompactPullup(SMnode *pMnode) {
}
taosArrayDestroy(pArray);
}
#ifdef TD_ENTERPRISE
static int32_t mndCompactDispatchAudit(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, STimeWindow *tw) {
if (!tsEnableAudit || tsMonitorFqdn[0] == 0 || tsMonitorPort == 0) {
return 0;
}
SName name = {0};
int32_t sqlLen = 0;
char sql[256] = {0};
char skeyStr[40] = {0};
char ekeyStr[40] = {0};
char *pDbName = pDb->name;
if (tNameFromString(&name, pDb->name, T_NAME_ACCT | T_NAME_DB) == 0) {
pDbName = name.dbname;
}
if (taosFormatUtcTime(skeyStr, sizeof(skeyStr), tw->skey, pDb->cfg.precision) == 0 &&
taosFormatUtcTime(ekeyStr, sizeof(ekeyStr), tw->ekey, pDb->cfg.precision) == 0) {
sqlLen = tsnprintf(sql, sizeof(sql), "compact db %s start with '%s' end with '%s'", pDbName, skeyStr, ekeyStr);
} else {
sqlLen = tsnprintf(sql, sizeof(sql), "compact db %s start with %" PRIi64 " end with %" PRIi64, pDbName, tw->skey,
tw->ekey);
}
auditRecord(NULL, pMnode->clusterId, "autoCompactDB", name.dbname, "", sql, sqlLen);
static int32_t mndProcessCompactTimer(SRpcMsg *pReq) {
mTrace("start to process compact timer");
mndCompactPullup(pReq->info.node);
return 0;
}
extern int32_t mndCompactDb(SMnode *pMnode, SRpcMsg *pReq, SDbObj *pDb, STimeWindow tw, SArray *vgroupIds);
static int32_t mndCompactDispatch(SRpcMsg *pReq) {
int32_t code = 0;
SMnode *pMnode = pReq->info.node;
SSdb *pSdb = pMnode->pSdb;
int64_t curMs = taosGetTimestampMs();
int64_t curMin = curMs / 60000LL;
void *pIter = NULL;
SDbObj *pDb = NULL;
while ((pIter = sdbFetch(pSdb, SDB_DB, pIter, (void **)&pDb))) {
if (pDb->cfg.compactInterval <= 0) {
mDebug("db:%p,%s, compact interval is %dm, skip", pDb, pDb->name, pDb->cfg.compactInterval);
sdbRelease(pSdb, pDb);
continue;
}
// daysToKeep2 would be altered
if (pDb->cfg.compactEndTime && (pDb->cfg.compactEndTime <= -pDb->cfg.daysToKeep2)) {
mWarn("db:%p,%s, compact end time:%dm <= -keep2:%dm , skip", pDb, pDb->name, pDb->cfg.compactEndTime,
-pDb->cfg.daysToKeep2);
sdbRelease(pSdb, pDb);
continue;
}
int64_t compactStartTime = pDb->cfg.compactStartTime ? pDb->cfg.compactStartTime : -pDb->cfg.daysToKeep2;
int64_t compactEndTime = pDb->cfg.compactEndTime ? pDb->cfg.compactEndTime : -pDb->cfg.daysPerFile;
if (compactStartTime >= compactEndTime) {
mDebug("db:%p,%s, compact start time:%" PRIi64 "m >= end time:%" PRIi64 "m, skip", pDb, pDb->name,
compactStartTime, compactEndTime);
sdbRelease(pSdb, pDb);
continue;
}
int64_t remainder = ((curMin - (int64_t)pDb->cfg.compactTimeOffset * 60LL) % pDb->cfg.compactInterval);
if (remainder != 0) {
mDebug("db:%p,%s, current time:%" PRIi64 "m is not divisible by compact interval:%dm, offset:%" PRIi8
"h, remainder:%" PRIi64 "m, skip",
pDb, pDb->name, curMin, pDb->cfg.compactInterval, pDb->cfg.compactTimeOffset, remainder);
sdbRelease(pSdb, pDb);
continue;
}
if ((pDb->compactStartTime / 60000LL) == curMin) {
mDebug("db:%p:%s, compact has already been dispatched at %" PRIi64 "m(%" PRIi64 "ms), skip", pDb, pDb->name,
curMin, pDb->compactStartTime);
sdbRelease(pSdb, pDb);
continue;
}
STimeWindow tw = {
.skey = convertTimePrecision(curMs + compactStartTime * 60000LL, TSDB_TIME_PRECISION_MILLI, pDb->cfg.precision),
.ekey = convertTimePrecision(curMs + compactEndTime * 60000LL, TSDB_TIME_PRECISION_MILLI, pDb->cfg.precision)};
if ((code = mndCompactDb(pMnode, NULL, pDb, tw, NULL)) == 0) {
mInfo("db:%p,%s, succeed to dispatch compact with range:[%" PRIi64 ",%" PRIi64 "], interval:%dm, start:%" PRIi64
"m, end:%" PRIi64 "m, offset:%" PRIi8 "h",
pDb, pDb->name, tw.skey, tw.ekey, pDb->cfg.compactInterval, compactStartTime, compactEndTime,
pDb->cfg.compactTimeOffset);
} else {
mWarn("db:%p,%s, failed to dispatch compact with range:[%" PRIi64 ",%" PRIi64 "], interval:%dm, start:%" PRIi64
"m, end:%" PRIi64 "m, offset:%" PRIi8 "h, since %s",
pDb, pDb->name, tw.skey, tw.ekey, pDb->cfg.compactInterval, compactStartTime, compactEndTime,
pDb->cfg.compactTimeOffset, tstrerror(code));
}
TAOS_UNUSED(mndCompactDispatchAudit(pMnode, pReq, pDb, &tw));
sdbRelease(pSdb, pDb);
}
return 0;
}
#endif
static int32_t mndProcessCompactTimer(SRpcMsg *pReq) {
#ifdef TD_ENTERPRISE
mTrace("start to process compact timer");
mndCompactPullup(pReq->info.node);
TAOS_UNUSED(mndCompactDispatch(pReq));
#endif
return 0;
}

View File

@ -90,6 +90,14 @@ int32_t mndRetrieveCompactDetail(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
TAOS_CHECK_RETURN_WITH_RELEASE(colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->startTime, false),
pSdb, pCompactDetail);
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
TAOS_CHECK_RETURN_WITH_RELEASE(colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->progress, false),
pSdb, pCompactDetail);
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
TAOS_CHECK_RETURN_WITH_RELEASE(
colDataSetVal(pColInfo, numOfRows, (const char *)&pCompactDetail->remainingTime, false), pSdb, pCompactDetail);
numOfRows++;
sdbRelease(pSdb, pCompactDetail);
}
@ -101,7 +109,7 @@ int32_t mndRetrieveCompactDetail(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
void tFreeCompactDetailObj(SCompactDetailObj *pCompact) {}
int32_t tSerializeSCompactDetailObj(void *buf, int32_t bufLen, const SCompactDetailObj *pObj) {
static int32_t tSerializeSCompactDetailObj(void *buf, int32_t bufLen, const SCompactDetailObj *pObj) {
SEncoder encoder = {0};
int32_t code = 0;
int32_t lino;
@ -118,6 +126,9 @@ int32_t tSerializeSCompactDetailObj(void *buf, int32_t bufLen, const SCompactDet
TAOS_CHECK_EXIT(tEncodeI64(&encoder, pObj->startTime));
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pObj->newNumberFileset));
TAOS_CHECK_EXIT(tEncodeI32(&encoder, pObj->newFinished));
// 1. add progress and remaining time
TAOS_CHECK_EXIT(tEncodeI32v(&encoder, pObj->progress));
TAOS_CHECK_EXIT(tEncodeI64v(&encoder, pObj->remainingTime));
tEndEncode(&encoder);
@ -131,7 +142,7 @@ _exit:
return tlen;
}
int32_t tDeserializeSCompactDetailObj(void *buf, int32_t bufLen, SCompactDetailObj *pObj) {
static int32_t tDeserializeSCompactDetailObj(void *buf, int32_t bufLen, SCompactDetailObj *pObj) {
int32_t code = 0;
int32_t lino;
SDecoder decoder = {0};
@ -147,6 +158,14 @@ int32_t tDeserializeSCompactDetailObj(void *buf, int32_t bufLen, SCompactDetailO
TAOS_CHECK_EXIT(tDecodeI64(&decoder, &pObj->startTime));
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pObj->newNumberFileset));
TAOS_CHECK_EXIT(tDecodeI32(&decoder, &pObj->newFinished));
// 1. add progress and remaining time decode
if (!tDecodeIsEnd(&decoder)) {
TAOS_CHECK_EXIT(tDecodeI32v(&decoder, &pObj->progress));
TAOS_CHECK_EXIT(tDecodeI64v(&decoder, &pObj->remainingTime));
} else {
pObj->progress = 0;
pObj->remainingTime = 0;
}
tEndDecode(&decoder);

View File

@ -0,0 +1,893 @@
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "audit.h"
#include "mndConfig.h"
#include "mndDnode.h"
#include "mndPrivilege.h"
#include "mndTrans.h"
#include "mndUser.h"
#include "tutil.h"
#define CFG_VER_NUMBER 1
#define CFG_RESERVE_SIZE 63
#define CFG_ALTER_TIMEOUT 3 * 1000
static int32_t mndMCfgGetValInt32(SMCfgDnodeReq *pInMCfgReq, int32_t optLen, int32_t *pOutValue);
static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq);
static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq);
static int32_t mndProcessConfigDnodeRsp(SRpcMsg *pRsp);
static int32_t mndProcessConfigReq(SRpcMsg *pReq);
static int32_t mndInitWriteCfg(SMnode *pMnode);
static int32_t mndTryRebuildCfg(SMnode *pMnode);
static int32_t initConfigArrayFromSdb(SMnode *pMnode, SArray *array);
static void cfgArrayCleanUp(SArray *array);
static void cfgObjArrayCleanUp(SArray *array);
static int32_t mndConfigUpdateTrans(SMnode *pMnode, const char *name, char *pValue, ECfgDataType dtype,
int32_t tsmmConfigVersion);
int32_t mndSetCreateConfigCommitLogs(STrans *pTrans, SConfigObj *obj);
int32_t mndInitConfig(SMnode *pMnode) {
int32_t code = 0;
SSdbTable table = {.sdbType = SDB_CFG,
.keyType = SDB_KEY_BINARY,
.encodeFp = (SdbEncodeFp)mnCfgActionEncode,
.decodeFp = (SdbDecodeFp)mndCfgActionDecode,
.insertFp = (SdbInsertFp)mndCfgActionInsert,
.updateFp = (SdbUpdateFp)mndCfgActionUpdate,
.deleteFp = (SdbDeleteFp)mndCfgActionDelete,
.deployFp = (SdbDeployFp)mndCfgActionDeploy,
.prepareFp = (SdbPrepareFp)mndCfgActionPrepare};
mndSetMsgHandle(pMnode, TDMT_MND_CONFIG, mndProcessConfigReq);
mndSetMsgHandle(pMnode, TDMT_MND_CONFIG_DNODE, mndProcessConfigDnodeReq);
mndSetMsgHandle(pMnode, TDMT_DND_CONFIG_DNODE_RSP, mndProcessConfigDnodeRsp);
mndSetMsgHandle(pMnode, TDMT_MND_SHOW_VARIABLES, mndProcessShowVariablesReq);
return sdbSetTable(pMnode->pSdb, table);
}
SSdbRaw *mnCfgActionEncode(SConfigObj *obj) {
int32_t code = 0;
int32_t lino = 0;
void *buf = NULL;
SSdbRaw *pRaw = NULL;
SEncoder encoder;
tEncoderInit(&encoder, NULL, 0);
if ((code = tEncodeSConfigObj(&encoder, obj)) < 0) {
tEncoderClear(&encoder);
TSDB_CHECK_CODE(code, lino, _over);
}
int32_t tlen = encoder.pos;
tEncoderClear(&encoder);
int32_t size = sizeof(int32_t) + tlen;
pRaw = sdbAllocRaw(SDB_CFG, CFG_VER_NUMBER, size);
TSDB_CHECK_NULL(pRaw, code, lino, _over, terrno);
buf = taosMemoryMalloc(tlen);
TSDB_CHECK_NULL(buf, code, lino, _over, terrno);
tEncoderInit(&encoder, buf, tlen);
if ((code = tEncodeSConfigObj(&encoder, obj)) < 0) {
tEncoderClear(&encoder);
TSDB_CHECK_CODE(code, lino, _over);
}
tEncoderClear(&encoder);
int32_t dataPos = 0;
SDB_SET_INT32(pRaw, dataPos, tlen, _over);
SDB_SET_BINARY(pRaw, dataPos, buf, tlen, _over);
SDB_SET_DATALEN(pRaw, dataPos, _over);
_over:
taosMemoryFreeClear(buf);
if (code != TSDB_CODE_SUCCESS) {
mError("cfg:%s, failed to encode to raw:%p at line:%d since %s", obj->name, pRaw, lino, tstrerror(code));
sdbFreeRaw(pRaw);
terrno = code;
return NULL;
}
terrno = 0;
mTrace("cfg:%s, encode to raw:%p, row:%p", obj->name, pRaw, obj);
return pRaw;
}
SSdbRow *mndCfgActionDecode(SSdbRaw *pRaw) {
int32_t code = 0;
int32_t lino = 0;
SSdbRow *pRow = NULL;
SConfigObj *pObj = NULL;
void *buf = NULL;
int8_t sver = 0;
int32_t tlen;
int32_t dataPos = 0;
code = sdbGetRawSoftVer(pRaw, &sver);
TSDB_CHECK_CODE(code, lino, _over);
if (sver != CFG_VER_NUMBER) {
terrno = TSDB_CODE_SDB_INVALID_DATA_VER;
goto _over;
}
pRow = sdbAllocRow(sizeof(SConfigObj));
TSDB_CHECK_NULL(pRow, code, lino, _over, terrno);
pObj = sdbGetRowObj(pRow);
TSDB_CHECK_NULL(pObj, code, lino, _over, terrno);
SDB_GET_INT32(pRaw, dataPos, &tlen, _over);
buf = taosMemoryMalloc(tlen + 1);
TSDB_CHECK_NULL(buf, code, lino, _over, terrno);
SDB_GET_BINARY(pRaw, dataPos, buf, tlen, _over);
SDecoder decoder;
tDecoderInit(&decoder, buf, tlen + 1);
code = tDecodeSConfigObj(&decoder, pObj);
tDecoderClear(&decoder);
if (code < 0) {
tFreeSConfigObj(pObj);
}
_over:
taosMemoryFreeClear(buf);
if (code != TSDB_CODE_SUCCESS) {
mError("cfg:%s, failed to decode from raw:%p since %s at:%d", pObj->name, pRaw, tstrerror(code), lino);
taosMemoryFreeClear(pRow);
terrno = code;
return NULL;
} else {
mTrace("config:%s, decode from raw:%p, row:%p", pObj->name, pRaw, pObj);
terrno = 0;
return pRow;
}
}
static int32_t mndCfgActionInsert(SSdb *pSdb, SConfigObj *obj) {
mTrace("cfg:%s, perform insert action, row:%p", obj->name, obj);
return 0;
}
static int32_t mndCfgActionDelete(SSdb *pSdb, SConfigObj *obj) {
mTrace("cfg:%s, perform delete action, row:%p", obj->name, obj);
tFreeSConfigObj(obj);
return 0;
}
static int32_t mndCfgActionUpdate(SSdb *pSdb, SConfigObj *pOld, SConfigObj *pNew) {
mTrace("cfg:%s, perform update action, old row:%p new row:%p", pOld->name, pOld, pNew);
switch (pNew->dtype) {
case CFG_DTYPE_NONE:
break;
case CFG_DTYPE_BOOL:
pOld->bval = pNew->bval;
break;
case CFG_DTYPE_INT32:
pOld->i32 = pNew->i32;
break;
case CFG_DTYPE_INT64:
pOld->i64 = pNew->i64;
break;
case CFG_DTYPE_FLOAT:
case CFG_DTYPE_DOUBLE:
pOld->fval = pNew->fval;
break;
case CFG_DTYPE_STRING:
case CFG_DTYPE_DIR:
case CFG_DTYPE_LOCALE:
case CFG_DTYPE_CHARSET:
case CFG_DTYPE_TIMEZONE:
taosMemoryFree(pOld->str);
pOld->str = taosStrdup(pNew->str);
if (pOld->str == NULL) {
return terrno;
}
break;
}
return TSDB_CODE_SUCCESS;
}
static int32_t mndCfgActionDeploy(SMnode *pMnode) { return mndInitWriteCfg(pMnode); }
static int32_t mndCfgActionPrepare(SMnode *pMnode) { return mndTryRebuildCfg(pMnode); }
static int32_t mndProcessConfigReq(SRpcMsg *pReq) {
SMnode *pMnode = pReq->info.node;
SConfigReq configReq = {0};
int32_t code = TSDB_CODE_SUCCESS;
SArray *array = NULL;
code = tDeserializeSConfigReq(pReq->pCont, pReq->contLen, &configReq);
if (code != 0) {
mError("failed to deserialize config req, since %s", terrstr());
goto _OVER;
}
SConfigObj *vObj = sdbAcquire(pMnode->pSdb, SDB_CFG, "tsmmConfigVersion");
if (vObj == NULL) {
mInfo("failed to acquire mnd config version, since %s", terrstr());
goto _OVER;
}
array = taosArrayInit(16, sizeof(SConfigItem));
if (array == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _OVER;
}
SConfigRsp configRsp = {0};
configRsp.forceReadConfig = configReq.forceReadConfig;
configRsp.cver = vObj->i32;
if (configRsp.forceReadConfig) {
// compare config array from configReq with current config array
if (compareSConfigItemArrays(taosGetGlobalCfg(tsCfg), configReq.array, array)) {
configRsp.array = array;
} else {
configRsp.isConifgVerified = 1;
}
} else {
if (configReq.cver == vObj->i32) {
configRsp.isVersionVerified = 1;
} else {
code = initConfigArrayFromSdb(pMnode, array);
if (code != 0) {
mError("failed to init config array from sdb, since %s", terrstr());
goto _OVER;
}
configRsp.array = array;
}
}
int32_t contLen = tSerializeSConfigRsp(NULL, 0, &configRsp);
if (contLen < 0) {
code = contLen;
goto _OVER;
}
void *pHead = rpcMallocCont(contLen);
if (pHead == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _OVER;
}
contLen = tSerializeSConfigRsp(pHead, contLen, &configRsp);
if (contLen < 0) {
rpcFreeCont(pHead);
code = contLen;
goto _OVER;
}
pReq->info.rspLen = contLen;
pReq->info.rsp = pHead;
_OVER:
if (code != 0) {
mError("failed to process config req, since %s", tstrerror(code));
}
sdbRelease(pMnode->pSdb, vObj);
cfgArrayCleanUp(array);
return TSDB_CODE_SUCCESS;
}
int32_t mndInitWriteCfg(SMnode *pMnode) {
int code = 0;
size_t sz = 0;
mInfo("init write cfg to sdb");
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL, "init-write-config");
if (pTrans == NULL) {
mError("failed to init write cfg in create trans, since %s", terrstr());
goto _OVER;
}
// encode mnd config version
SConfigObj *versionObj = mndInitConfigVersion();
if ((code = mndSetCreateConfigCommitLogs(pTrans, versionObj)) != 0) {
mError("failed to init mnd config version, since %s", tstrerror(code));
tFreeSConfigObj(versionObj);
taosMemoryFree(versionObj);
goto _OVER;
}
tFreeSConfigObj(versionObj);
taosMemoryFree(versionObj);
sz = taosArrayGetSize(taosGetGlobalCfg(tsCfg));
for (int i = 0; i < sz; ++i) {
SConfigItem *item = taosArrayGet(taosGetGlobalCfg(tsCfg), i);
SConfigObj *obj = mndInitConfigObj(item);
if (obj == NULL) {
code = terrno;
goto _OVER;
}
if ((code = mndSetCreateConfigCommitLogs(pTrans, obj)) != 0) {
mError("failed to init mnd config:%s, since %s", item->name, tstrerror(code));
tFreeSConfigObj(obj);
taosMemoryFree(obj);
goto _OVER;
}
tFreeSConfigObj(obj);
taosMemoryFree(obj);
}
if ((code = mndTransPrepare(pMnode, pTrans)) != 0) goto _OVER;
_OVER:
if (code != 0) {
mError("failed to init write cfg, since %s", tstrerror(code));
}
mndTransDrop(pTrans);
return code;
}
int32_t mndTryRebuildCfg(SMnode *pMnode) {
int32_t code = 0;
int32_t sz = -1;
STrans *pTrans = NULL;
SAcctObj *vObj = NULL, *obj = NULL;
SArray *addArray = NULL;
vObj = sdbAcquire(pMnode->pSdb, SDB_CFG, "tsmmConfigVersion");
if (vObj == NULL) {
if ((code = mndInitWriteCfg(pMnode)) < 0) goto _exit;
mInfo("failed to acquire mnd config version, try to rebuild config in sdb.");
} else {
sz = taosArrayGetSize(taosGetGlobalCfg(tsCfg));
addArray = taosArrayInit(4, sizeof(SConfigObj));
for (int i = 0; i < sz; ++i) {
SConfigItem *item = taosArrayGet(taosGetGlobalCfg(tsCfg), i);
obj = sdbAcquire(pMnode->pSdb, SDB_CFG, item->name);
if (obj == NULL) {
SConfigObj *newObj = mndInitConfigObj(item);
if (newObj == NULL) {
code = terrno;
goto _exit;
}
if (NULL == taosArrayPush(addArray, newObj)) {
code = terrno;
goto _exit;
}
} else {
sdbRelease(pMnode->pSdb, obj);
}
}
int32_t addSize = taosArrayGetSize(addArray);
if (addSize > 0) {
pTrans = mndTransCreate(pMnode, TRN_POLICY_RETRY, TRN_CONFLICT_NOTHING, NULL, "add-config");
if (pTrans == NULL) {
code = terrno;
goto _exit;
}
for (int i = 0; i < addSize; ++i) {
SConfigObj *AddObj = taosArrayGet(addArray, i);
if ((code = mndSetCreateConfigCommitLogs(pTrans, AddObj)) != 0) goto _exit;
}
if ((code = mndTransPrepare(pMnode, pTrans)) != 0) goto _exit;
mInfo("add new config to sdb, nums:%d", addSize);
}
}
_exit:
if (code != 0) {
mError("failed to try rebuild config in sdb, since %s", tstrerror(code));
}
sdbRelease(pMnode->pSdb, vObj);
sdbRelease(pMnode->pSdb, obj);
cfgObjArrayCleanUp(addArray);
mndTransDrop(pTrans);
TAOS_RETURN(code);
}
int32_t mndSetCreateConfigCommitLogs(STrans *pTrans, SConfigObj *item) {
int32_t code = 0;
SSdbRaw *pCommitRaw = mnCfgActionEncode(item);
if (pCommitRaw == NULL) {
code = terrno;
TAOS_RETURN(code);
}
if ((code = mndTransAppendCommitlog(pTrans, pCommitRaw) != 0)) TAOS_RETURN(code);
if ((code = sdbSetRawStatus(pCommitRaw, SDB_STATUS_READY)) != 0) TAOS_RETURN(code);
return TSDB_CODE_SUCCESS;
}
static int32_t mndMCfg2DCfg(SMCfgDnodeReq *pMCfgReq, SDCfgDnodeReq *pDCfgReq) {
int32_t code = 0;
char *p = pMCfgReq->config;
while (*p) {
if (*p == ' ') {
break;
}
p++;
}
size_t optLen = p - pMCfgReq->config;
strncpy(pDCfgReq->config, pMCfgReq->config, optLen);
pDCfgReq->config[optLen] = 0;
if (' ' == pMCfgReq->config[optLen]) {
// 'key value'
if (strlen(pMCfgReq->value) != 0) goto _err;
(void)strcpy(pDCfgReq->value, p + 1);
} else {
// 'key' 'value'
if (strlen(pMCfgReq->value) == 0) goto _err;
(void)strcpy(pDCfgReq->value, pMCfgReq->value);
}
TAOS_RETURN(code);
_err:
mError("dnode:%d, failed to config since invalid conf:%s", pMCfgReq->dnodeId, pMCfgReq->config);
code = TSDB_CODE_INVALID_CFG;
TAOS_RETURN(code);
}
static int32_t mndSendCfgDnodeReq(SMnode *pMnode, int32_t dnodeId, SDCfgDnodeReq *pDcfgReq) {
int32_t code = -1;
SSdb *pSdb = pMnode->pSdb;
void *pIter = NULL;
int64_t curMs = taosGetTimestampMs();
while (1) {
SDnodeObj *pDnode = NULL;
pIter = sdbFetch(pSdb, SDB_DNODE, pIter, (void **)&pDnode);
if (pIter == NULL) break;
if (pDnode->id == dnodeId || dnodeId == -1 || dnodeId == 0) {
bool online = mndIsDnodeOnline(pDnode, curMs);
if (!online) {
mWarn("dnode:%d, is offline, skip to send config req", pDnode->id);
continue;
}
SEpSet epSet = mndGetDnodeEpset(pDnode);
int32_t bufLen = tSerializeSDCfgDnodeReq(NULL, 0, pDcfgReq);
void *pBuf = rpcMallocCont(bufLen);
if (pBuf == NULL) {
sdbCancelFetch(pMnode->pSdb, pIter);
sdbRelease(pMnode->pSdb, pDnode);
code = TSDB_CODE_OUT_OF_MEMORY;
return code;
}
if ((bufLen = tSerializeSDCfgDnodeReq(pBuf, bufLen, pDcfgReq)) <= 0) {
sdbCancelFetch(pMnode->pSdb, pIter);
sdbRelease(pMnode->pSdb, pDnode);
code = bufLen;
rpcFreeCont(pBuf);
return code;
}
mInfo("dnode:%d, send config req to dnode, config:%s value:%s", pDnode->id, pDcfgReq->config, pDcfgReq->value);
SRpcMsg rpcMsg = {.msgType = TDMT_DND_CONFIG_DNODE, .pCont = pBuf, .contLen = bufLen};
SRpcMsg rpcRsp = {0};
code = rpcSendRecvWithTimeout(pMnode->msgCb.statusRpc, &epSet, &rpcMsg, &rpcRsp, NULL, CFG_ALTER_TIMEOUT);
if (code != 0) {
mError("failed to send config req to dnode:%d, since %s", pDnode->id, tstrerror(code));
sdbCancelFetch(pMnode->pSdb, pIter);
sdbRelease(pMnode->pSdb, pDnode);
return code;
}
code = rpcRsp.code;
if (code != 0) {
mError("failed to alter config %s,on dnode:%d, since %s", pDcfgReq->config, pDnode->id, tstrerror(code));
sdbCancelFetch(pMnode->pSdb, pIter);
sdbRelease(pMnode->pSdb, pDnode);
return code;
}
rpcFreeCont(rpcRsp.pCont);
}
sdbRelease(pSdb, pDnode);
}
if (code == -1) {
code = TSDB_CODE_MND_DNODE_NOT_EXIST;
}
TAOS_RETURN(code);
}
static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
int32_t code = 0;
int32_t lino = -1;
SMnode *pMnode = pReq->info.node;
SMCfgDnodeReq cfgReq = {0};
SConfigObj *vObj = sdbAcquire(pMnode->pSdb, SDB_CFG, "tsmmConfigVersion");
if (vObj == NULL) {
goto _err_out;
}
TAOS_CHECK_RETURN(tDeserializeSMCfgDnodeReq(pReq->pCont, pReq->contLen, &cfgReq));
int8_t updateIpWhiteList = 0;
mInfo("dnode:%d, start to config, option:%s, value:%s", cfgReq.dnodeId, cfgReq.config, cfgReq.value);
if ((code = mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_CONFIG_DNODE)) != 0) {
goto _err_out;
}
SDCfgDnodeReq dcfgReq = {0};
if (strcasecmp(cfgReq.config, "resetlog") == 0) {
tstrncpy(dcfgReq.config, "resetlog", 9);
goto _send_req;
#ifdef TD_ENTERPRISE
} else if (strncasecmp(cfgReq.config, "s3blocksize", 12) == 0) {
int32_t optLen = strlen("s3blocksize");
int32_t flag = -1;
int32_t code = mndMCfgGetValInt32(&cfgReq, optLen, &flag);
if (code < 0) {
goto _err_out;
}
if (flag > 1024 * 1024 || (flag > -1 && flag < 1024) || flag < -1) {
mError("dnode:%d, failed to config s3blocksize since value:%d. Valid range: -1 or [1024, 1024 * 1024]",
cfgReq.dnodeId, flag);
code = TSDB_CODE_INVALID_CFG;
goto _err_out;
}
tstrncpy(dcfgReq.config, "s3blocksize", 12);
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag);
#endif
} else {
TAOS_CHECK_GOTO(mndMCfg2DCfg(&cfgReq, &dcfgReq), &lino, _err_out);
if (strlen(dcfgReq.config) > TSDB_DNODE_CONFIG_LEN) {
mError("dnode:%d, failed to config since config is too long", cfgReq.dnodeId);
code = TSDB_CODE_INVALID_CFG;
goto _err_out;
}
if (strncasecmp(dcfgReq.config, "enableWhiteList", strlen("enableWhiteList")) == 0) {
updateIpWhiteList = 1;
}
CfgAlterType alterType = (cfgReq.dnodeId == 0 || cfgReq.dnodeId == -1) ? CFG_ALTER_ALL_DNODES : CFG_ALTER_DNODE;
TAOS_CHECK_GOTO(cfgCheckRangeForDynUpdate(taosGetCfg(), dcfgReq.config, dcfgReq.value, true, alterType), &lino,
_err_out);
}
SConfigItem *pItem = cfgGetItem(taosGetCfg(), dcfgReq.config);
// Update config in sdb.
if (pItem == NULL) {
mError("failed to find config:%s while process config dnode req", cfgReq.config);
code = TSDB_CODE_CFG_NOT_FOUND;
goto _err_out;
}
if (pItem->category == CFG_CATEGORY_GLOBAL) {
TAOS_CHECK_GOTO(mndConfigUpdateTrans(pMnode, dcfgReq.config, dcfgReq.value, pItem->dtype, ++vObj->i32), &lino,
_err_out);
}
_send_req :
{ // audit
char obj[50] = {0};
(void)sprintf(obj, "%d", cfgReq.dnodeId);
auditRecord(pReq, pMnode->clusterId, "alterDnode", obj, "", cfgReq.sql, cfgReq.sqlLen);
}
dcfgReq.version = vObj->i32;
code = mndSendCfgDnodeReq(pMnode, cfgReq.dnodeId, &dcfgReq);
if (code != 0) {
mError("failed to send config req to dnode:%d, since %s", cfgReq.dnodeId, tstrerror(code));
goto _err_out;
}
// dont care suss or succ;
if (updateIpWhiteList) mndRefreshUserIpWhiteList(pMnode);
tFreeSMCfgDnodeReq(&cfgReq);
sdbRelease(pMnode->pSdb, vObj);
TAOS_RETURN(code);
_err_out:
mError("failed to process config dnode req, since %s", tstrerror(code));
tFreeSMCfgDnodeReq(&cfgReq);
sdbRelease(pMnode->pSdb, vObj);
TAOS_RETURN(code);
}
static int32_t mndProcessConfigDnodeRsp(SRpcMsg *pRsp) {
mInfo("config rsp from dnode");
return 0;
}
// get int32_t value from 'SMCfgDnodeReq'
static int32_t mndMCfgGetValInt32(SMCfgDnodeReq *pMCfgReq, int32_t optLen, int32_t *pOutValue) {
int32_t code = 0;
if (' ' != pMCfgReq->config[optLen] && 0 != pMCfgReq->config[optLen]) {
goto _err;
}
if (' ' == pMCfgReq->config[optLen]) {
// 'key value'
if (strlen(pMCfgReq->value) != 0) goto _err;
*pOutValue = taosStr2Int32(pMCfgReq->config + optLen + 1, NULL, 10);
} else {
// 'key' 'value'
if (strlen(pMCfgReq->value) == 0) goto _err;
*pOutValue = taosStr2Int32(pMCfgReq->value, NULL, 10);
}
TAOS_RETURN(code);
_err:
mError(" failed to set config since:%s", tstrerror(code));
TAOS_RETURN(code);
}
static int32_t mndConfigUpdateTrans(SMnode *pMnode, const char *name, char *pValue, ECfgDataType dtype,
int32_t tsmmConfigVersion) {
int32_t code = -1;
int32_t lino = -1;
SConfigObj *pVersion = taosMemoryMalloc(sizeof(SConfigObj)), *pObj = taosMemoryMalloc(sizeof(SConfigObj));
if (pVersion == NULL || pObj == NULL) {
code = terrno;
goto _OVER;
}
tstrncpy(pVersion->name, "tsmmConfigVersion", CFG_NAME_MAX_LEN);
pVersion->dtype = CFG_DTYPE_INT32;
pVersion->i32 = tsmmConfigVersion;
pObj->dtype = dtype;
tstrncpy(pObj->name, name, CFG_NAME_MAX_LEN);
TAOS_CHECK_GOTO(mndUpdateObj(pObj, name, pValue), &lino, _OVER);
STrans *pTrans = mndTransCreate(pMnode, TRN_POLICY_ROLLBACK, TRN_CONFLICT_NOTHING, NULL, "update-config");
if (pTrans == NULL) {
code = terrno;
goto _OVER;
}
mInfo("trans:%d, used to update config:%s to value:%s", pTrans->id, name, pValue);
TAOS_CHECK_GOTO(mndSetCreateConfigCommitLogs(pTrans, pVersion), &lino, _OVER);
TAOS_CHECK_GOTO(mndSetCreateConfigCommitLogs(pTrans, pObj), &lino, _OVER);
if ((code = mndTransPrepare(pMnode, pTrans)) != 0) goto _OVER;
code = 0;
_OVER:
if (code != 0) {
mError("failed to update config:%s to value:%s, since %s", name, pValue, tstrerror(code));
}
mndTransDrop(pTrans);
tFreeSConfigObj(pVersion);
taosMemoryFree(pVersion);
tFreeSConfigObj(pObj);
taosMemoryFree(pObj);
return code;
}
static int32_t initConfigArrayFromSdb(SMnode *pMnode, SArray *array) {
int32_t code = 0;
SSdb *pSdb = pMnode->pSdb;
void *pIter = NULL;
SConfigObj *obj = NULL;
while (1) {
pIter = sdbFetch(pSdb, SDB_CFG, pIter, (void **)&obj);
if (pIter == NULL) break;
if (obj == NULL) {
code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit;
}
if (strcasecmp(obj->name, "tsmmConfigVersion") == 0) {
sdbRelease(pSdb, obj);
continue;
}
SConfigItem item = {0};
item.dtype = obj->dtype;
item.name = taosStrdup(obj->name);
if (item.name == NULL) {
code = terrno;
sdbCancelFetch(pSdb, pIter);
sdbRelease(pSdb, obj);
goto _exit;
}
switch (obj->dtype) {
case CFG_DTYPE_NONE:
break;
case CFG_DTYPE_BOOL:
item.bval = obj->bval;
break;
case CFG_DTYPE_INT32:
item.i32 = obj->i32;
break;
case CFG_DTYPE_INT64:
item.i64 = obj->i64;
break;
case CFG_DTYPE_FLOAT:
case CFG_DTYPE_DOUBLE:
item.fval = obj->fval;
break;
case CFG_DTYPE_STRING:
case CFG_DTYPE_DIR:
case CFG_DTYPE_LOCALE:
case CFG_DTYPE_CHARSET:
case CFG_DTYPE_TIMEZONE:
item.str = taosStrdup(obj->str);
if (item.str == NULL) {
sdbCancelFetch(pSdb, pIter);
sdbRelease(pSdb, obj);
code = terrno;
goto _exit;
}
break;
}
if (taosArrayPush(array, &item) == NULL) {
sdbCancelFetch(pSdb, pIter);
sdbRelease(pSdb, obj);
code = TSDB_CODE_OUT_OF_MEMORY;
goto _exit;
break;
}
sdbRelease(pSdb, obj);
}
_exit:
if (code != 0) {
mError("failed to init config array from sdb, since %s", tstrerror(code));
}
return code;
}
static void cfgArrayCleanUp(SArray *array) {
if (array == NULL) {
return;
}
int32_t sz = taosArrayGetSize(array);
for (int32_t i = 0; i < sz; ++i) {
SConfigItem *item = taosArrayGet(array, i);
if (item->dtype == CFG_DTYPE_STRING || item->dtype == CFG_DTYPE_DIR || item->dtype == CFG_DTYPE_LOCALE ||
item->dtype == CFG_DTYPE_CHARSET || item->dtype == CFG_DTYPE_TIMEZONE) {
taosMemoryFreeClear(item->str);
}
taosMemoryFreeClear(item->name);
}
taosArrayDestroy(array);
}
static void cfgObjArrayCleanUp(SArray *array) {
if (array == NULL) {
return;
}
int32_t sz = taosArrayGetSize(array);
for (int32_t i = 0; i < sz; ++i) {
SConfigObj *obj = taosArrayGet(array, i);
tFreeSConfigObj(obj);
taosMemoryFree(obj);
}
taosArrayDestroy(array);
}
SArray *initVariablesFromItems(SArray *pItems) {
if (pItems == NULL) {
return NULL;
}
int32_t sz = taosArrayGetSize(pItems);
SArray *pInfos = taosArrayInit(sz, sizeof(SVariablesInfo));
if (pInfos == NULL) {
mError("failed to init array while init variables from items, since %s", tstrerror(terrno));
return NULL;
}
for (int32_t i = 0; i < sz; ++i) {
SConfigItem *pItem = taosArrayGet(pItems, i);
SVariablesInfo info = {0};
strcpy(info.name, pItem->name);
// init info value
switch (pItem->dtype) {
case CFG_DTYPE_NONE:
break;
case CFG_DTYPE_BOOL:
sprintf(info.value, "%d", pItem->bval);
break;
case CFG_DTYPE_INT32:
sprintf(info.value, "%d", pItem->i32);
break;
case CFG_DTYPE_INT64:
sprintf(info.value, "%" PRId64, pItem->i64);
break;
case CFG_DTYPE_FLOAT:
case CFG_DTYPE_DOUBLE:
sprintf(info.value, "%f", pItem->fval);
break;
case CFG_DTYPE_STRING:
case CFG_DTYPE_DIR:
case CFG_DTYPE_LOCALE:
case CFG_DTYPE_CHARSET:
case CFG_DTYPE_TIMEZONE:
sprintf(info.value, "%s", pItem->str);
break;
}
// init info scope
switch (pItem->scope) {
case CFG_SCOPE_SERVER:
strcpy(info.scope, "server");
break;
case CFG_SCOPE_CLIENT:
strcpy(info.scope, "client");
break;
case CFG_SCOPE_BOTH:
strcpy(info.scope, "both");
break;
default:
strcpy(info.scope, "unknown");
break;
}
// init info category
switch (pItem->category) {
case CFG_CATEGORY_GLOBAL:
strcpy(info.category, "global");
break;
case CFG_CATEGORY_LOCAL:
strcpy(info.category, "local");
break;
default:
strcpy(info.category, "unknown");
break;
}
if (NULL == taosArrayPush(pInfos, &info)) {
mError("failed to push info to array while init variables from items,since %s", tstrerror(terrno));
taosArrayDestroy(pInfos);
return NULL;
}
}
return pInfos;
}
static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq) {
SShowVariablesRsp rsp = {0};
int32_t code = -1;
if ((code = mndCheckOperPrivilege(pReq->info.node, pReq->info.conn.user, MND_OPER_SHOW_VARIABLES)) != 0) {
goto _OVER;
}
SVariablesInfo info = {0};
rsp.variables = initVariablesFromItems(taosGetGlobalCfg(tsCfg));
if (rsp.variables == NULL) {
code = terrno;
goto _OVER;
}
int32_t rspLen = tSerializeSShowVariablesRsp(NULL, 0, &rsp);
void *pRsp = rpcMallocCont(rspLen);
if (pRsp == NULL) {
code = terrno;
goto _OVER;
}
if ((rspLen = tSerializeSShowVariablesRsp(pRsp, rspLen, &rsp)) <= 0) {
rpcFreeCont(pRsp);
code = rspLen;
goto _OVER;
}
pReq->info.rspLen = rspLen;
pReq->info.rsp = pRsp;
code = 0;
_OVER:
if (code != 0) {
mError("failed to get show variables info since %s", tstrerror(code));
}
tFreeSShowVariablesRsp(&rsp);
TAOS_RETURN(code);
}

View File

@ -14,11 +14,12 @@
*/
#define _DEFAULT_SOURCE
#include "mndDb.h"
#include "audit.h"
#include "command.h"
#include "mndArbGroup.h"
#include "mndCluster.h"
#include "mndConfig.h"
#include "mndDb.h"
#include "mndDnode.h"
#include "mndIndex.h"
#include "mndPrivilege.h"
@ -37,7 +38,7 @@
#include "tjson.h"
#define DB_VER_NUMBER 1
#define DB_RESERVE_SIZE 27
#define DB_RESERVE_SIZE 14
static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw);
static int32_t mndDbActionInsert(SSdb *pSdb, SDbObj *pDb);
@ -151,6 +152,10 @@ SSdbRaw *mndDbActionEncode(SDbObj *pDb) {
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.withArbitrator, _OVER)
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.encryptAlgorithm, _OVER)
SDB_SET_INT32(pRaw, dataPos, pDb->tsmaVersion, _OVER);
SDB_SET_INT8(pRaw, dataPos, pDb->cfg.compactTimeOffset, _OVER)
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.compactStartTime, _OVER)
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.compactEndTime, _OVER)
SDB_SET_INT32(pRaw, dataPos, pDb->cfg.compactInterval, _OVER)
SDB_SET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER)
SDB_SET_DATALEN(pRaw, dataPos, _OVER)
@ -250,6 +255,10 @@ static SSdbRow *mndDbActionDecode(SSdbRaw *pRaw) {
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.withArbitrator, _OVER)
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.encryptAlgorithm, _OVER)
SDB_GET_INT32(pRaw, dataPos, &pDb->tsmaVersion, _OVER);
SDB_GET_INT8(pRaw, dataPos, &pDb->cfg.compactTimeOffset, _OVER)
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.compactStartTime, _OVER)
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.compactEndTime, _OVER)
SDB_GET_INT32(pRaw, dataPos, &pDb->cfg.compactInterval, _OVER)
SDB_GET_RESERVE(pRaw, dataPos, DB_RESERVE_SIZE, _OVER)
taosInitRWLatch(&pDb->lock);
@ -365,6 +374,10 @@ static int32_t mndDbActionUpdate(SSdb *pSdb, SDbObj *pOld, SDbObj *pNew) {
pOld->cfg.s3KeepLocal = pNew->cfg.s3KeepLocal;
pOld->cfg.s3Compact = pNew->cfg.s3Compact;
pOld->cfg.withArbitrator = pNew->cfg.withArbitrator;
pOld->cfg.compactInterval = pNew->cfg.compactInterval;
pOld->cfg.compactStartTime = pNew->cfg.compactStartTime;
pOld->cfg.compactEndTime = pNew->cfg.compactEndTime;
pOld->cfg.compactTimeOffset = pNew->cfg.compactTimeOffset;
pOld->compactStartTime = pNew->compactStartTime;
pOld->tsmaVersion = pNew->tsmaVersion;
taosWUnLockLatch(&pOld->lock);
@ -800,6 +813,10 @@ static int32_t mndCreateDb(SMnode *pMnode, SRpcMsg *pReq, SCreateDbReq *pCreate,
.tsdbPageSize = pCreate->tsdbPageSize,
.withArbitrator = pCreate->withArbitrator,
.encryptAlgorithm = pCreate->encryptAlgorithm,
.compactInterval = pCreate->compactInterval,
.compactStartTime = pCreate->compactStartTime,
.compactEndTime = pCreate->compactEndTime,
.compactTimeOffset = pCreate->compactTimeOffset,
};
dbObj.cfg.numOfRetensions = pCreate->numOfRetensions;
@ -1143,6 +1160,34 @@ static int32_t mndSetDbCfgFromAlterDbReq(SDbObj *pDb, SAlterDbReq *pAlter) {
code = 0;
}
if (pAlter->compactInterval >= TSDB_DEFAULT_COMPACT_INTERVAL && pAlter->compactInterval != pDb->cfg.compactInterval) {
pDb->cfg.compactInterval = pAlter->compactInterval;
pDb->vgVersion++;
code = 0;
}
if (pAlter->compactStartTime != pDb->cfg.compactStartTime &&
(pAlter->compactStartTime == TSDB_DEFAULT_COMPACT_START_TIME ||
pAlter->compactStartTime <= -pDb->cfg.daysPerFile)) {
pDb->cfg.compactStartTime = pAlter->compactStartTime;
pDb->vgVersion++;
code = 0;
}
if (pAlter->compactEndTime != pDb->cfg.compactEndTime &&
(pAlter->compactEndTime == TSDB_DEFAULT_COMPACT_END_TIME || pAlter->compactEndTime <= -pDb->cfg.daysPerFile)) {
pDb->cfg.compactEndTime = pAlter->compactEndTime;
pDb->vgVersion++;
code = 0;
}
if (pAlter->compactTimeOffset >= TSDB_MIN_COMPACT_TIME_OFFSET &&
pAlter->compactTimeOffset != pDb->cfg.compactTimeOffset) {
pDb->cfg.compactTimeOffset = pAlter->compactTimeOffset;
pDb->vgVersion++;
code = 0;
}
TAOS_RETURN(code);
}
@ -1376,6 +1421,18 @@ static void mndDumpDbCfgInfo(SDbCfgRsp *cfgRsp, SDbObj *pDb) {
cfgRsp->s3Compact = pDb->cfg.s3Compact;
cfgRsp->withArbitrator = pDb->cfg.withArbitrator;
cfgRsp->encryptAlgorithm = pDb->cfg.encryptAlgorithm;
cfgRsp->compactInterval = pDb->cfg.compactInterval;
cfgRsp->compactStartTime = pDb->cfg.compactStartTime;
cfgRsp->compactEndTime = pDb->cfg.compactEndTime;
if (cfgRsp->compactInterval > 0) {
if (cfgRsp->compactStartTime == 0) {
cfgRsp->compactStartTime = -cfgRsp->daysToKeep2;
}
if (cfgRsp->compactEndTime == 0) {
cfgRsp->compactEndTime = -cfgRsp->daysPerFile;
}
}
cfgRsp->compactTimeOffset = pDb->cfg.compactTimeOffset;
}
static int32_t mndProcessGetDbCfgReq(SRpcMsg *pReq) {

View File

@ -13,9 +13,10 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _DEFAULT_SOURCE
#include "mndDef.h"
#include "mndConsumer.h"
#include "mndDef.h"
#include "taoserror.h"
#include "tunit.h"
static void *freeStreamTasks(SArray *pTaskLevel);
@ -72,7 +73,7 @@ int32_t tEncodeSStreamObj(SEncoder *pEncoder, const SStreamObj *pObj) {
TAOS_CHECK_RETURN(tEncodeI32(pEncoder, innerSz));
for (int32_t j = 0; j < innerSz; j++) {
SStreamTask *pTask = taosArrayGetP(pArray, j);
if (pTask->ver < SSTREAM_TASK_SUBTABLE_CHANGED_VER){
if (pTask->ver < SSTREAM_TASK_SUBTABLE_CHANGED_VER) {
pTask->ver = SSTREAM_TASK_VER;
}
TAOS_CHECK_RETURN(tEncodeStreamTask(pEncoder, pTask));
@ -273,9 +274,9 @@ void *tDecodeSMqVgEp(const void *buf, SMqVgEp *pVgEp, int8_t sver) {
static void *topicNameDup(void *p) { return taosStrdup((char *)p); }
int32_t tNewSMqConsumerObj(int64_t consumerId, char *cgroup, int8_t updateType,
char *topic, SCMSubscribeReq *subscribe, SMqConsumerObj** ppConsumer) {
int32_t code = 0;
int32_t tNewSMqConsumerObj(int64_t consumerId, char *cgroup, int8_t updateType, char *topic, SCMSubscribeReq *subscribe,
SMqConsumerObj **ppConsumer) {
int32_t code = 0;
SMqConsumerObj *pConsumer = taosMemoryCalloc(1, sizeof(SMqConsumerObj));
if (pConsumer == NULL) {
code = terrno;
@ -294,30 +295,30 @@ int32_t tNewSMqConsumerObj(int64_t consumerId, char *cgroup, int8_t updateType,
pConsumer->createTime = taosGetTimestampMs();
pConsumer->updateType = updateType;
if (updateType == CONSUMER_ADD_REB){
if (updateType == CONSUMER_ADD_REB) {
pConsumer->rebNewTopics = taosArrayInit(0, sizeof(void *));
if(pConsumer->rebNewTopics == NULL){
if (pConsumer->rebNewTopics == NULL) {
code = terrno;
goto END;
}
char* topicTmp = taosStrdup(topic);
char *topicTmp = taosStrdup(topic);
if (taosArrayPush(pConsumer->rebNewTopics, &topicTmp) == NULL) {
code = terrno;
goto END;
}
}else if (updateType == CONSUMER_REMOVE_REB) {
} else if (updateType == CONSUMER_REMOVE_REB) {
pConsumer->rebRemovedTopics = taosArrayInit(0, sizeof(void *));
if(pConsumer->rebRemovedTopics == NULL){
if (pConsumer->rebRemovedTopics == NULL) {
code = terrno;
goto END;
}
char* topicTmp = taosStrdup(topic);
char *topicTmp = taosStrdup(topic);
if (taosArrayPush(pConsumer->rebRemovedTopics, &topicTmp) == NULL) {
code = terrno;
goto END;
}
}else if (updateType == CONSUMER_INSERT_SUB){
} else if (updateType == CONSUMER_INSERT_SUB) {
tstrncpy(pConsumer->clientId, subscribe->clientId, tListLen(pConsumer->clientId));
pConsumer->withTbName = subscribe->withTbName;
pConsumer->autoCommit = subscribe->autoCommit;
@ -329,13 +330,13 @@ int32_t tNewSMqConsumerObj(int64_t consumerId, char *cgroup, int8_t updateType,
tstrncpy(pConsumer->fqdn, subscribe->fqdn, TSDB_FQDN_LEN);
pConsumer->rebNewTopics = taosArrayDup(subscribe->topicNames, topicNameDup);
if (pConsumer->rebNewTopics == NULL){
if (pConsumer->rebNewTopics == NULL) {
code = terrno;
goto END;
}
pConsumer->assignedTopics = subscribe->topicNames;
subscribe->topicNames = NULL;
}else if (updateType == CONSUMER_UPDATE_SUB){
} else if (updateType == CONSUMER_UPDATE_SUB) {
pConsumer->assignedTopics = subscribe->topicNames;
subscribe->topicNames = NULL;
}
@ -504,12 +505,12 @@ void *tDecodeSMqConsumerObj(const void *buf, SMqConsumerObj *pConsumer, int8_t s
buf = taosDecodeFixedI32(buf, &pConsumer->autoCommitInterval);
buf = taosDecodeFixedI32(buf, &pConsumer->resetOffsetCfg);
}
if (sver > 2){
if (sver > 2) {
buf = taosDecodeFixedI32(buf, &pConsumer->maxPollIntervalMs);
buf = taosDecodeFixedI32(buf, &pConsumer->sessionTimeoutMs);
buf = taosDecodeStringTo(buf, pConsumer->user);
buf = taosDecodeStringTo(buf, pConsumer->fqdn);
} else{
} else {
pConsumer->maxPollIntervalMs = DEFAULT_MAX_POLL_INTERVAL;
pConsumer->sessionTimeoutMs = DEFAULT_SESSION_TIMEOUT;
}
@ -517,7 +518,7 @@ void *tDecodeSMqConsumerObj(const void *buf, SMqConsumerObj *pConsumer, int8_t s
return (void *)buf;
}
int32_t tEncodeOffRows(void **buf, SArray *offsetRows){
int32_t tEncodeOffRows(void **buf, SArray *offsetRows) {
int32_t tlen = 0;
int32_t szVgs = taosArrayGetSize(offsetRows);
tlen += taosEncodeFixedI32(buf, szVgs);
@ -545,11 +546,10 @@ int32_t tEncodeSMqConsumerEp(void **buf, const SMqConsumerEp *pConsumerEp) {
tlen += taosEncodeFixedI64(buf, pConsumerEp->consumerId);
tlen += taosEncodeArray(buf, pConsumerEp->vgs, (FEncode)tEncodeSMqVgEp);
return tlen + tEncodeOffRows(buf, pConsumerEp->offsetRows);
}
void *tDecodeOffRows(const void *buf, SArray **offsetRows, int8_t sver){
void *tDecodeOffRows(const void *buf, SArray **offsetRows, int8_t sver) {
int32_t szVgs = 0;
buf = taosDecodeFixedI32(buf, &szVgs);
if (szVgs > 0) {
@ -568,7 +568,7 @@ void *tDecodeOffRows(const void *buf, SArray **offsetRows, int8_t sver){
} else {
// do nothing
}
if(sver > 2){
if (sver > 2) {
buf = taosDecodeFixedI64(buf, &offRows->ever);
}
}
@ -587,7 +587,7 @@ void *tDecodeSMqConsumerEp(const void *buf, SMqConsumerEp *pConsumerEp, int8_t s
}
int32_t tNewSubscribeObj(const char *key, SMqSubscribeObj **ppSub) {
int32_t code = 0;
int32_t code = 0;
SMqSubscribeObj *pSubObj = taosMemoryCalloc(1, sizeof(SMqSubscribeObj));
MND_TMQ_NULL_CHECK(pSubObj);
@ -598,7 +598,7 @@ int32_t tNewSubscribeObj(const char *key, SMqSubscribeObj **ppSub) {
MND_TMQ_NULL_CHECK(pSubObj->consumerHash);
pSubObj->unassignedVgs = taosArrayInit(0, POINTER_BYTES);
MND_TMQ_NULL_CHECK(pSubObj->unassignedVgs);
if (ppSub){
if (ppSub) {
*ppSub = pSubObj;
}
return code;
@ -609,7 +609,7 @@ END:
}
int32_t tCloneSubscribeObj(const SMqSubscribeObj *pSub, SMqSubscribeObj **ppSub) {
int32_t code = 0;
int32_t code = 0;
SMqSubscribeObj *pSubNew = taosMemoryMalloc(sizeof(SMqSubscribeObj));
if (pSubNew == NULL) {
code = terrno;
@ -730,6 +730,188 @@ void *tDecodeSubscribeObj(const void *buf, SMqSubscribeObj *pSub, int8_t sver) {
return (void *)buf;
}
SConfigObj *mndInitConfigObj(SConfigItem *pItem) {
SConfigObj *pObj = taosMemoryCalloc(1, sizeof(SConfigObj));
if (pObj == NULL) {
return NULL;
}
strncpy(pObj->name, pItem->name, CFG_NAME_MAX_LEN);
pObj->dtype = pItem->dtype;
switch (pItem->dtype) {
case CFG_DTYPE_NONE:
break;
case CFG_DTYPE_BOOL:
pObj->bval = pItem->bval;
break;
case CFG_DTYPE_INT32:
pObj->i32 = pItem->i32;
break;
case CFG_DTYPE_INT64:
pObj->i64 = pItem->i64;
break;
case CFG_DTYPE_FLOAT:
case CFG_DTYPE_DOUBLE:
pObj->fval = pItem->fval;
break;
case CFG_DTYPE_STRING:
case CFG_DTYPE_DIR:
case CFG_DTYPE_LOCALE:
case CFG_DTYPE_CHARSET:
case CFG_DTYPE_TIMEZONE:
pObj->str = taosStrdup(pItem->str);
if (pObj->str == NULL) {
taosMemoryFree(pObj);
return NULL;
}
break;
}
return pObj;
}
int32_t mndUpdateObj(SConfigObj *pObjNew, const char *name, char *value) {
int32_t code = 0;
switch (pObjNew->dtype) {
case CFG_DTYPE_BOOL: {
bool tmp = false;
if (strcasecmp(value, "true") == 0) {
tmp = true;
}
if (atoi(value) > 0) {
tmp = true;
}
pObjNew->bval = tmp;
break;
}
case CFG_DTYPE_INT32: {
int32_t ival;
TAOS_CHECK_RETURN(taosStrHumanToInt32(value, &ival));
pObjNew->i32 = ival;
break;
}
case CFG_DTYPE_INT64: {
int64_t ival;
TAOS_CHECK_RETURN(taosStrHumanToInt64(value, &ival));
pObjNew->i64 = ival;
break;
}
case CFG_DTYPE_FLOAT:
case CFG_DTYPE_DOUBLE: {
float dval = 0;
TAOS_CHECK_RETURN(parseCfgReal(value, &dval));
pObjNew->fval = dval;
break;
}
case CFG_DTYPE_DIR:
case CFG_DTYPE_TIMEZONE:
case CFG_DTYPE_CHARSET:
case CFG_DTYPE_LOCALE:
case CFG_DTYPE_STRING: {
pObjNew->str = taosStrdup(value);
if (pObjNew->str == NULL) {
code = terrno;
return code;
}
break;
}
case CFG_DTYPE_NONE:
break;
default:
code = TSDB_CODE_INVALID_CFG;
break;
}
return code;
}
SConfigObj *mndInitConfigVersion() {
SConfigObj *pObj = taosMemoryCalloc(1, sizeof(SConfigObj));
if (pObj == NULL) {
return NULL;
}
tstrncpy(pObj->name, "tsmmConfigVersion", CFG_NAME_MAX_LEN);
pObj->dtype = CFG_DTYPE_INT32;
pObj->i32 = 0;
return pObj;
}
int32_t tEncodeSConfigObj(SEncoder *pEncoder, const SConfigObj *pObj) {
TAOS_CHECK_RETURN(tStartEncode(pEncoder));
TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pObj->name));
TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pObj->dtype));
switch (pObj->dtype) {
case CFG_DTYPE_BOOL:
TAOS_CHECK_RETURN(tEncodeI8(pEncoder, pObj->bval));
break;
case CFG_DTYPE_INT32:
TAOS_CHECK_RETURN(tEncodeI32(pEncoder, pObj->i32));
break;
case CFG_DTYPE_INT64:
TAOS_CHECK_RETURN(tEncodeI64(pEncoder, pObj->i64));
break;
case CFG_DTYPE_FLOAT:
case CFG_DTYPE_DOUBLE:
TAOS_CHECK_RETURN(tEncodeFloat(pEncoder, pObj->fval));
break;
case CFG_DTYPE_STRING:
case CFG_DTYPE_DIR:
case CFG_DTYPE_LOCALE:
case CFG_DTYPE_CHARSET:
case CFG_DTYPE_TIMEZONE:
if (pObj->str != NULL) {
TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, pObj->str));
} else {
TAOS_CHECK_RETURN(tEncodeCStr(pEncoder, ""));
}
break;
default:
break;
}
tEndEncode(pEncoder);
return pEncoder->pos;
}
int32_t tDecodeSConfigObj(SDecoder *pDecoder, SConfigObj *pObj) {
TAOS_CHECK_RETURN(tStartDecode(pDecoder));
TAOS_CHECK_RETURN(tDecodeCStrTo(pDecoder, pObj->name));
TAOS_CHECK_RETURN(tDecodeI32(pDecoder, (int32_t *)&pObj->dtype));
switch (pObj->dtype) {
case CFG_DTYPE_NONE:
break;
case CFG_DTYPE_BOOL:
TAOS_CHECK_RETURN(tDecodeBool(pDecoder, &pObj->bval));
break;
case CFG_DTYPE_INT32:
TAOS_CHECK_RETURN(tDecodeI32(pDecoder, &pObj->i32));
break;
case CFG_DTYPE_INT64:
TAOS_CHECK_RETURN(tDecodeI64(pDecoder, &pObj->i64));
break;
case CFG_DTYPE_FLOAT:
case CFG_DTYPE_DOUBLE:
TAOS_CHECK_RETURN(tDecodeFloat(pDecoder, &pObj->fval));
break;
case CFG_DTYPE_STRING:
case CFG_DTYPE_DIR:
case CFG_DTYPE_LOCALE:
case CFG_DTYPE_CHARSET:
case CFG_DTYPE_TIMEZONE:
TAOS_CHECK_RETURN(tDecodeCStrAlloc(pDecoder, &pObj->str));
break;
}
tEndDecode(pDecoder);
TAOS_RETURN(TSDB_CODE_SUCCESS);
}
void tFreeSConfigObj(SConfigObj *obj) {
if (obj == NULL) {
return;
}
if (obj->dtype == CFG_DTYPE_STRING || obj->dtype == CFG_DTYPE_DIR || obj->dtype == CFG_DTYPE_LOCALE ||
obj->dtype == CFG_DTYPE_CHARSET || obj->dtype == CFG_DTYPE_TIMEZONE) {
taosMemoryFree(obj->str);
}
}
// SMqSubActionLogEntry *tCloneSMqSubActionLogEntry(SMqSubActionLogEntry *pEntry) {
// SMqSubActionLogEntry *pEntryNew = taosMemoryMalloc(sizeof(SMqSubActionLogEntry));
// if (pEntryNew == NULL) return NULL;

View File

@ -28,6 +28,7 @@
#include "mndUser.h"
#include "mndVgroup.h"
#include "taos_monitor.h"
#include "tconfig.h"
#include "tjson.h"
#include "tmisce.h"
#include "tunit.h"
@ -76,12 +77,9 @@ static int32_t mndDnodeActionInsert(SSdb *pSdb, SDnodeObj *pDnode);
static int32_t mndDnodeActionDelete(SSdb *pSdb, SDnodeObj *pDnode);
static int32_t mndDnodeActionUpdate(SSdb *pSdb, SDnodeObj *pOld, SDnodeObj *pNew);
static int32_t mndProcessDnodeListReq(SRpcMsg *pReq);
static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq);
static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq);
static int32_t mndProcessDropDnodeReq(SRpcMsg *pReq);
static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq);
static int32_t mndProcessConfigDnodeRsp(SRpcMsg *pRsp);
static int32_t mndProcessStatusReq(SRpcMsg *pReq);
static int32_t mndProcessNotifyReq(SRpcMsg *pReq);
static int32_t mndProcessRestoreDnodeReq(SRpcMsg *pReq);
@ -96,8 +94,6 @@ static void mndCancelGetNextConfig(SMnode *pMnode, void *pIter);
static int32_t mndRetrieveDnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pBlock, int32_t rows);
static void mndCancelGetNextDnode(SMnode *pMnode, void *pIter);
static int32_t mndMCfgGetValInt32(SMCfgDnodeReq *pInMCfgReq, int32_t optLen, int32_t *pOutValue);
#ifdef _GRANT
int32_t mndUpdClusterInfo(SRpcMsg *pReq);
#else
@ -118,12 +114,9 @@ int32_t mndInitDnode(SMnode *pMnode) {
mndSetMsgHandle(pMnode, TDMT_MND_CREATE_DNODE, mndProcessCreateDnodeReq);
mndSetMsgHandle(pMnode, TDMT_MND_DROP_DNODE, mndProcessDropDnodeReq);
mndSetMsgHandle(pMnode, TDMT_MND_CONFIG_DNODE, mndProcessConfigDnodeReq);
mndSetMsgHandle(pMnode, TDMT_DND_CONFIG_DNODE_RSP, mndProcessConfigDnodeRsp);
mndSetMsgHandle(pMnode, TDMT_MND_STATUS, mndProcessStatusReq);
mndSetMsgHandle(pMnode, TDMT_MND_NOTIFY, mndProcessNotifyReq);
mndSetMsgHandle(pMnode, TDMT_MND_DNODE_LIST, mndProcessDnodeListReq);
mndSetMsgHandle(pMnode, TDMT_MND_SHOW_VARIABLES, mndProcessShowVariablesReq);
mndSetMsgHandle(pMnode, TDMT_MND_RESTORE_DNODE, mndProcessRestoreDnodeReq);
mndSetMsgHandle(pMnode, TDMT_MND_STATIS, mndProcessStatisReq);
mndSetMsgHandle(pMnode, TDMT_MND_AUDIT, mndProcessAuditReq);
@ -1084,124 +1077,6 @@ static void getSlowLogScopeString(int32_t scope, char *result) {
}
}
static int32_t mndProcessShowVariablesReq(SRpcMsg *pReq) {
SShowVariablesRsp rsp = {0};
int32_t code = -1;
if (mndCheckOperPrivilege(pReq->info.node, pReq->info.conn.user, MND_OPER_SHOW_VARIABLES) != 0) {
goto _OVER;
}
rsp.variables = taosArrayInit(16, sizeof(SVariablesInfo));
if (NULL == rsp.variables) {
mError("failed to alloc SVariablesInfo array while process show variables req");
code = terrno;
goto _OVER;
}
SVariablesInfo info = {0};
(void)strcpy(info.name, "statusInterval");
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%d", tsStatusInterval);
(void)strcpy(info.scope, "server");
// fill info.info
if (taosArrayPush(rsp.variables, &info) == NULL) {
code = terrno;
goto _OVER;
}
(void)strcpy(info.name, "timezone");
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%s", tsTimezoneStr);
(void)strcpy(info.scope, "both");
if (taosArrayPush(rsp.variables, &info) == NULL) {
code = terrno;
goto _OVER;
}
(void)strcpy(info.name, "locale");
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%s", tsLocale);
(void)strcpy(info.scope, "both");
if (taosArrayPush(rsp.variables, &info) == NULL) {
code = terrno;
goto _OVER;
}
(void)strcpy(info.name, "charset");
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%s", tsCharset);
(void)strcpy(info.scope, "both");
if (taosArrayPush(rsp.variables, &info) == NULL) {
code = terrno;
goto _OVER;
}
(void)strcpy(info.name, "monitor");
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%d", tsEnableMonitor);
(void)strcpy(info.scope, "server");
if (taosArrayPush(rsp.variables, &info) == NULL) {
code = terrno;
goto _OVER;
}
(void)strcpy(info.name, "monitorInterval");
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%d", tsMonitorInterval);
(void)strcpy(info.scope, "server");
if (taosArrayPush(rsp.variables, &info) == NULL) {
code = terrno;
goto _OVER;
}
(void)strcpy(info.name, "slowLogThreshold");
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%d", tsSlowLogThreshold);
(void)strcpy(info.scope, "server");
if (taosArrayPush(rsp.variables, &info) == NULL) {
code = terrno;
goto _OVER;
}
(void)strcpy(info.name, "slowLogMaxLen");
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%d", tsSlowLogMaxLen);
(void)strcpy(info.scope, "server");
if (taosArrayPush(rsp.variables, &info) == NULL) {
code = terrno;
goto _OVER;
}
char scopeStr[64] = {0};
getSlowLogScopeString(tsSlowLogScope, scopeStr);
(void)strcpy(info.name, "slowLogScope");
(void)snprintf(info.value, TSDB_CONFIG_VALUE_LEN, "%s", scopeStr);
(void)strcpy(info.scope, "server");
if (taosArrayPush(rsp.variables, &info) == NULL) {
code = terrno;
goto _OVER;
}
int32_t rspLen = tSerializeSShowVariablesRsp(NULL, 0, &rsp);
void *pRsp = rpcMallocCont(rspLen);
if (pRsp == NULL) {
code = terrno;
goto _OVER;
}
if ((rspLen = tSerializeSShowVariablesRsp(pRsp, rspLen, &rsp)) <= 0) {
code = rspLen;
goto _OVER;
}
pReq->info.rspLen = rspLen;
pReq->info.rsp = pRsp;
code = 0;
_OVER:
if (code != 0) {
mError("failed to get show variables info since %s", tstrerror(code));
}
tFreeSShowVariablesRsp(&rsp);
TAOS_RETURN(code);
}
static int32_t mndProcessCreateDnodeReq(SRpcMsg *pReq) {
SMnode *pMnode = pReq->info.node;
int32_t code = -1;
@ -1438,144 +1313,6 @@ _OVER:
TAOS_RETURN(code);
}
static int32_t mndMCfg2DCfg(SMCfgDnodeReq *pMCfgReq, SDCfgDnodeReq *pDCfgReq) {
int32_t code = 0;
char *p = pMCfgReq->config;
while (*p) {
if (*p == ' ') {
break;
}
p++;
}
size_t optLen = p - pMCfgReq->config;
tstrncpy(pDCfgReq->config, pMCfgReq->config, optLen + 1);
pDCfgReq->config[optLen] = 0;
if (' ' == pMCfgReq->config[optLen]) {
// 'key value'
if (strlen(pMCfgReq->value) != 0) goto _err;
(void)strcpy(pDCfgReq->value, p + 1);
} else {
// 'key' 'value'
if (strlen(pMCfgReq->value) == 0) goto _err;
(void)strcpy(pDCfgReq->value, pMCfgReq->value);
}
TAOS_RETURN(code);
_err:
mError("dnode:%d, failed to config since invalid conf:%s", pMCfgReq->dnodeId, pMCfgReq->config);
code = TSDB_CODE_INVALID_CFG;
TAOS_RETURN(code);
}
static int32_t mndSendCfgDnodeReq(SMnode *pMnode, int32_t dnodeId, SDCfgDnodeReq *pDcfgReq) {
int32_t code = -1;
SSdb *pSdb = pMnode->pSdb;
void *pIter = NULL;
while (1) {
SDnodeObj *pDnode = NULL;
pIter = sdbFetch(pSdb, SDB_DNODE, pIter, (void **)&pDnode);
if (pIter == NULL) break;
if (pDnode->id == dnodeId || dnodeId == -1 || dnodeId == 0) {
SEpSet epSet = mndGetDnodeEpset(pDnode);
int32_t bufLen = tSerializeSDCfgDnodeReq(NULL, 0, pDcfgReq);
void *pBuf = rpcMallocCont(bufLen);
if (pBuf != NULL) {
if ((bufLen = tSerializeSDCfgDnodeReq(pBuf, bufLen, pDcfgReq)) <= 0) {
code = bufLen;
return code;
}
mInfo("dnode:%d, send config req to dnode, config:%s value:%s", dnodeId, pDcfgReq->config, pDcfgReq->value);
SRpcMsg rpcMsg = {.msgType = TDMT_DND_CONFIG_DNODE, .pCont = pBuf, .contLen = bufLen};
code = tmsgSendReq(&epSet, &rpcMsg);
}
}
sdbRelease(pSdb, pDnode);
}
if (code == -1) {
code = TSDB_CODE_MND_DNODE_NOT_EXIST;
}
TAOS_RETURN(code);
}
static int32_t mndProcessConfigDnodeReq(SRpcMsg *pReq) {
int32_t code = 0;
SMnode *pMnode = pReq->info.node;
SMCfgDnodeReq cfgReq = {0};
TAOS_CHECK_RETURN(tDeserializeSMCfgDnodeReq(pReq->pCont, pReq->contLen, &cfgReq));
int8_t updateIpWhiteList = 0;
mInfo("dnode:%d, start to config, option:%s, value:%s", cfgReq.dnodeId, cfgReq.config, cfgReq.value);
if ((code = mndCheckOperPrivilege(pMnode, pReq->info.conn.user, MND_OPER_CONFIG_DNODE)) != 0) {
tFreeSMCfgDnodeReq(&cfgReq);
TAOS_RETURN(code);
}
SDCfgDnodeReq dcfgReq = {0};
if (strcasecmp(cfgReq.config, "resetlog") == 0) {
(void)strcpy(dcfgReq.config, "resetlog");
#ifdef TD_ENTERPRISE
} else if (strncasecmp(cfgReq.config, "s3blocksize", 11) == 0) {
int32_t optLen = strlen("s3blocksize");
int32_t flag = -1;
int32_t code = mndMCfgGetValInt32(&cfgReq, optLen, &flag);
if (code < 0) return code;
if (flag > 1024 * 1024 || (flag > -1 && flag < 1024) || flag < -1) {
mError("dnode:%d, failed to config s3blocksize since value:%d. Valid range: -1 or [1024, 1024 * 1024]",
cfgReq.dnodeId, flag);
code = TSDB_CODE_INVALID_CFG;
tFreeSMCfgDnodeReq(&cfgReq);
TAOS_RETURN(code);
}
strcpy(dcfgReq.config, "s3blocksize");
snprintf(dcfgReq.value, TSDB_DNODE_VALUE_LEN, "%d", flag);
#endif
} else {
TAOS_CHECK_GOTO(mndMCfg2DCfg(&cfgReq, &dcfgReq), NULL, _err_out);
if (strlen(dcfgReq.config) > TSDB_DNODE_CONFIG_LEN) {
mError("dnode:%d, failed to config since config is too long", cfgReq.dnodeId);
code = TSDB_CODE_INVALID_CFG;
goto _err_out;
}
if (strncasecmp(dcfgReq.config, "enableWhiteList", strlen("enableWhiteList")) == 0) {
updateIpWhiteList = 1;
}
TAOS_CHECK_GOTO(cfgCheckRangeForDynUpdate(taosGetCfg(), dcfgReq.config, dcfgReq.value, true), NULL, _err_out);
}
{ // audit
char obj[50] = {0};
(void)sprintf(obj, "%d", cfgReq.dnodeId);
auditRecord(pReq, pMnode->clusterId, "alterDnode", obj, "", cfgReq.sql, cfgReq.sqlLen);
}
tFreeSMCfgDnodeReq(&cfgReq);
code = mndSendCfgDnodeReq(pMnode, cfgReq.dnodeId, &dcfgReq);
// dont care suss or succ;
if (updateIpWhiteList) mndRefreshUserIpWhiteList(pMnode);
TAOS_RETURN(code);
_err_out:
tFreeSMCfgDnodeReq(&cfgReq);
TAOS_RETURN(code);
}
static int32_t mndProcessConfigDnodeRsp(SRpcMsg *pRsp) {
mInfo("config rsp from dnode");
return 0;
}
static int32_t mndProcessCreateEncryptKeyReqImpl(SRpcMsg *pReq, int32_t dnodeId, SDCfgDnodeReq *pDcfgReq) {
int32_t code = 0;
SMnode *pMnode = pReq->info.node;
@ -1871,39 +1608,6 @@ static void mndCancelGetNextDnode(SMnode *pMnode, void *pIter) {
sdbCancelFetchByType(pSdb, pIter, SDB_DNODE);
}
// get int32_t value from 'SMCfgDnodeReq'
static int32_t mndMCfgGetValInt32(SMCfgDnodeReq *pMCfgReq, int32_t optLen, int32_t *pOutValue) {
int32_t code = 0;
if (' ' != pMCfgReq->config[optLen] && 0 != pMCfgReq->config[optLen]) {
goto _err;
}
if (' ' == pMCfgReq->config[optLen]) {
// 'key value'
if (strlen(pMCfgReq->value) != 0) goto _err;
code = taosStr2int32(pMCfgReq->config + optLen + 1, pOutValue);
if (code != 0) {
mError("dnode:%d, failed to get cfg since %s", pMCfgReq->dnodeId, tstrerror(code));
goto _err;
}
} else {
// 'key' 'value'
if (strlen(pMCfgReq->value) == 0) goto _err;
code = taosStr2int32(pMCfgReq->value, pOutValue);
if (code != 0) {
mError("dnode:%d, failed to get cfg since %s", pMCfgReq->dnodeId, tstrerror(code));
goto _err;
}
}
TAOS_RETURN(code);
_err:
mError("dnode:%d, failed to config since invalid conf:%s", pMCfgReq->dnodeId, pMCfgReq->config);
code = TSDB_CODE_INVALID_CFG;
TAOS_RETURN(code);
}
SArray *mndGetAllDnodeFqdns(SMnode *pMnode) {
SDnodeObj *pObj = NULL;
void *pIter = NULL;

View File

@ -20,6 +20,7 @@
#include "mndCluster.h"
#include "mndCompact.h"
#include "mndCompactDetail.h"
#include "mndConfig.h"
#include "mndConsumer.h"
#include "mndDb.h"
#include "mndDnode.h"
@ -611,6 +612,7 @@ static int32_t mndInitSteps(SMnode *pMnode) {
TAOS_CHECK_RETURN(mndAllocStep(pMnode, "mnode-snode", mndInitSnode, mndCleanupSnode));
TAOS_CHECK_RETURN(mndAllocStep(pMnode, "mnode-anode", mndInitAnode, mndCleanupAnode));
TAOS_CHECK_RETURN(mndAllocStep(pMnode, "mnode-arbgroup", mndInitArbGroup, mndCleanupArbGroup));
TAOS_CHECK_RETURN(mndAllocStep(pMnode, "mnode-config", mndInitConfig, NULL));
TAOS_CHECK_RETURN(mndAllocStep(pMnode, "mnode-dnode", mndInitDnode, mndCleanupDnode));
TAOS_CHECK_RETURN(mndAllocStep(pMnode, "mnode-user", mndInitUser, mndCleanupUser));
TAOS_CHECK_RETURN(mndAllocStep(pMnode, "mnode-grant", mndInitGrant, mndCleanupGrant));
@ -637,7 +639,6 @@ static int32_t mndInitSteps(SMnode *pMnode) {
TAOS_CHECK_RETURN(mndAllocStep(pMnode, "mnode-query", mndInitQuery, mndCleanupQuery));
TAOS_CHECK_RETURN(mndAllocStep(pMnode, "mnode-sync", mndInitSync, mndCleanupSync));
TAOS_CHECK_RETURN(mndAllocStep(pMnode, "mnode-telem", mndInitTelem, mndCleanupTelem));
return 0;
}
@ -796,6 +797,12 @@ int32_t mndStart(SMnode *pMnode) {
return -1;
}
mndSetRestored(pMnode, true);
} else {
if (sdbPrepare(pMnode->pSdb) != 0) {
mError("failed to prepare sdb while start mnode");
return -1;
}
mndSetRestored(pMnode, true);
}
grantReset(pMnode, TSDB_GRANT_ALL, 0);

View File

@ -248,6 +248,10 @@ bool mndIsMnode(SMnode *pMnode, int32_t dnodeId) {
}
void mndGetMnodeEpSet(SMnode *pMnode, SEpSet *pEpSet) {
if (pMnode == NULL || pEpSet == NULL) {
return;
}
SSdb *pSdb = pMnode->pSdb;
int32_t totalMnodes = sdbGetSize(pSdb, SDB_MNODE);
if (totalMnodes == 0) {
@ -920,7 +924,9 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
SColumnInfoData *pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->id, false);
if (code != 0) {
mError("mnode:%d, failed to set col data val since %s", pObj->id, terrstr());
mError("mnode:%d, failed to set col data val since %s", pObj->id, tstrerror(code));
sdbCancelFetch(pSdb, pShow->pIter);
sdbRelease(pSdb, pObj);
goto _out;
}
@ -930,7 +936,9 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
code = colDataSetVal(pColInfo, numOfRows, b1, false);
if (code != 0) {
mError("mnode:%d, failed to set col data val since %s", pObj->id, terrstr());
mError("mnode:%d, failed to set col data val since %s", pObj->id, tstrerror(code));
sdbCancelFetch(pSdb, pShow->pIter);
sdbRelease(pSdb, pObj);
goto _out;
}
@ -950,10 +958,8 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
STR_WITH_MAXSIZE_TO_VARSTR(b2, role, pShow->pMeta->pSchemas[cols].bytes);
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
code = colDataSetVal(pColInfo, numOfRows, (const char *)b2, false);
if (code != 0) {
mError("mnode:%d, failed to set col data val since %s", pObj->id, terrstr());
goto _out;
}
if (code != 0) goto _err;
const char *status = "ready";
if (objStatus == SDB_STATUS_CREATING) status = "creating";
if (objStatus == SDB_STATUS_DROPPING) status = "dropping";
@ -962,25 +968,16 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
STR_WITH_MAXSIZE_TO_VARSTR(b3, status, pShow->pMeta->pSchemas[cols].bytes);
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
code = colDataSetVal(pColInfo, numOfRows, (const char *)b3, false);
if (code != 0) {
mError("mnode:%d, failed to set col data val since %s", pObj->id, terrstr());
goto _out;
}
if (code != 0) goto _err;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
code = colDataSetVal(pColInfo, numOfRows, (const char *)&pObj->createdTime, false);
if (code != 0) {
mError("mnode:%d, failed to set col data val since %s", pObj->id, terrstr());
goto _out;
}
if (code != 0) goto _err;
int64_t roleTimeMs = (isDnodeOnline) ? pObj->roleTimeMs : 0;
pColInfo = taosArrayGet(pBlock->pDataBlock, cols++);
code = colDataSetVal(pColInfo, numOfRows, (const char *)&roleTimeMs, false);
if (code != 0) {
mError("mnode:%d, failed to set col data val since %s", pObj->id, terrstr());
goto _out;
}
if (code != 0) goto _err;
numOfRows++;
sdbRelease(pSdb, pObj);
@ -991,6 +988,13 @@ static int32_t mndRetrieveMnodes(SRpcMsg *pReq, SShowObj *pShow, SSDataBlock *pB
_out:
sdbRelease(pSdb, pSelfObj);
return numOfRows;
_err:
mError("mnode:%d, failed to set col data val since %s", pObj->id, tstrerror(code));
sdbCancelFetch(pSdb, pShow->pIter);
sdbRelease(pSdb, pObj);
sdbRelease(pSdb, pSelfObj);
return numOfRows;
}
static void mndCancelGetNextMnode(SMnode *pMnode, void *pIter) {

View File

@ -144,6 +144,8 @@ static int32_t convertToRetrieveType(char *name, int32_t len) {
type = TSDB_MGMT_TABLE_TSMAS;
} else if (strncasecmp(name, TSDB_INS_DISK_USAGE, len) == 0) {
type = TSDB_MGMT_TABLE_USAGE;
} else if (strncasecmp(name, TSDB_INS_TABLE_FILESETS, len) == 0) {
type = TSDB_MGMT_TABLE_FILESETS;
} else {
mError("invalid show name:%s len:%d", name, len);
}

View File

@ -2343,7 +2343,7 @@ int32_t mndProcessStreamReqCheckpoint(SRpcMsg *pReq) {
}
int32_t total = taosArrayGetSize(*pReqTaskList);
if (total == numOfTasks) { // all tasks has send the reqs
if (total == numOfTasks) { // all tasks have sent the reqs
int64_t checkpointId = mndStreamGenChkptId(pMnode, false);
mInfo("stream:0x%" PRIx64 " all tasks req checkpoint, start checkpointId:%" PRId64, req.streamId, checkpointId);

View File

@ -15,6 +15,8 @@
#include "mndStream.h"
#include "mndTrans.h"
#include "mndMnode.h"
#include "tmisce.h"
typedef struct SFailedCheckpointInfo {
int64_t streamUid;
@ -31,7 +33,7 @@ static int32_t setNodeEpsetExpiredFlag(const SArray *pNodeList);
static int32_t suspendAllStreams(SMnode *pMnode, SRpcHandleInfo *info);
static bool validateHbMsg(const SArray *pNodeList, int32_t vgId);
static void cleanupAfterProcessHbMsg(SStreamHbMsg *pReq, SArray *pFailedChkptList, SArray *pOrphanTasks);
static void doSendHbMsgRsp(int32_t code, SRpcHandleInfo *pRpcInfo, int32_t vgId, int32_t msgId);
static void doSendHbMsgRsp(int32_t code, SRpcHandleInfo *pRpcInfo, SEpSet* pEpset, int32_t vgId, int32_t msgId);
static void checkforOrphanTask(SMnode* pMnode, STaskStatusEntry* p, SArray* pOrphanTasks);
void updateStageInfo(STaskStatusEntry *pTaskEntry, int64_t stage) {
@ -329,6 +331,8 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
SArray *pFailedChkpt = NULL;
SArray *pOrphanTasks = NULL;
int32_t code = 0;
SDecoder decoder = {0};
SEpSet mnodeEpset = {0};
if ((code = grantCheckExpire(TSDB_GRANT_STREAMS)) < 0) {
if (suspendAllStreams(pMnode, &pReq->info) < 0) {
@ -336,7 +340,6 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
}
}
SDecoder decoder = {0};
tDecoderInit(&decoder, pReq->pCont, pReq->contLen);
if (tDecodeStreamHbMsg(&decoder, &req) < 0) {
@ -357,13 +360,15 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
TAOS_RETURN(terrno);
}
mndGetMnodeEpSet(pMnode, &mnodeEpset);
streamMutexLock(&execInfo.lock);
mndInitStreamExecInfo(pMnode, &execInfo);
if (!validateHbMsg(execInfo.pNodeList, req.vgId)) {
mError("vgId:%d not exists in nodeList buf, discarded", req.vgId);
doSendHbMsgRsp(terrno, &pReq->info, req.vgId, req.msgId);
doSendHbMsgRsp(terrno, &pReq->info, &mnodeEpset, req.vgId, req.msgId);
streamMutexUnlock(&execInfo.lock);
cleanupAfterProcessHbMsg(&req, pFailedChkpt, pOrphanTasks);
@ -383,9 +388,9 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
if ((pEntry->lastHbMsgId == req.msgId) && (pEntry->lastHbMsgTs == req.ts)) {
mError("vgId:%d HbMsgId:%d already handled, bh msg discard, and send HbRsp", pEntry->nodeId, req.msgId);
// return directly and after the vnode to continue to send the next HbMsg.
// return directly and allow the vnode to continue to send the next HbMsg.
terrno = TSDB_CODE_SUCCESS;
doSendHbMsgRsp(terrno, &pReq->info, req.vgId, req.msgId);
doSendHbMsgRsp(terrno, &pReq->info, &mnodeEpset, req.vgId, req.msgId);
streamMutexUnlock(&execInfo.lock);
cleanupAfterProcessHbMsg(&req, pFailedChkpt, pOrphanTasks);
@ -529,7 +534,7 @@ int32_t mndProcessStreamHb(SRpcMsg *pReq) {
streamMutexUnlock(&execInfo.lock);
doSendHbMsgRsp(TSDB_CODE_SUCCESS, &pReq->info, req.vgId, req.msgId);
doSendHbMsgRsp(TSDB_CODE_SUCCESS, &pReq->info, &mnodeEpset, req.vgId, req.msgId);
cleanupAfterProcessHbMsg(&req, pFailedChkpt, pOrphanTasks);
return code;
@ -552,12 +557,13 @@ void cleanupAfterProcessHbMsg(SStreamHbMsg *pReq, SArray *pFailedChkptList, SArr
taosArrayDestroy(pOrphanTasks);
}
void doSendHbMsgRsp(int32_t code, SRpcHandleInfo *pRpcInfo, int32_t vgId, int32_t msgId) {
void doSendHbMsgRsp(int32_t code, SRpcHandleInfo *pRpcInfo, SEpSet* pMndEpset, int32_t vgId, int32_t msgId) {
int32_t ret = 0;
int32_t tlen = 0;
void *buf = NULL;
const SMStreamHbRspMsg msg = {.msgId = msgId};
SMStreamHbRspMsg msg = {.msgId = msgId};//, .mndEpset = *pMndEpset};
epsetAssign(&msg.mndEpset, pMndEpset);
tEncodeSize(tEncodeStreamHbRsp, &msg, tlen, ret);
if (ret < 0) {

View File

@ -108,30 +108,94 @@ static bool checkStatusForEachReplica(SVgObj *pVgroup) {
return true;
}
int32_t mndTakeVgroupSnapshot(SMnode *pMnode, bool *allReady, SArray **pList) {
static int32_t mndAddSnodeInfo(SMnode *pMnode, SArray *pVgroupList) {
SSnodeObj *pObj = NULL;
void *pIter = NULL;
int32_t code = 0;
while (1) {
pIter = sdbFetch(pMnode->pSdb, SDB_SNODE, pIter, (void **)&pObj);
if (pIter == NULL) {
break;
}
SNodeEntry entry = {.nodeId = SNODE_HANDLE};
code = addEpIntoEpSet(&entry.epset, pObj->pDnode->fqdn, pObj->pDnode->port);
if (code) {
sdbRelease(pMnode->pSdb, pObj);
sdbCancelFetch(pMnode->pSdb, pIter);
mError("failed to extract epset for fqdn:%s during task vgroup snapshot", pObj->pDnode->fqdn);
return code;
}
char buf[256] = {0};
code = epsetToStr(&entry.epset, buf, tListLen(buf));
if (code != 0) { // print error and continue
mError("failed to convert epset to str, code:%s", tstrerror(code));
}
void *p = taosArrayPush(pVgroupList, &entry);
if (p == NULL) {
code = terrno;
sdbRelease(pMnode->pSdb, pObj);
sdbCancelFetch(pMnode->pSdb, pIter);
mError("failed to put entry in vgroup list, nodeId:%d code:%s", entry.nodeId, tstrerror(code));
return code;
} else {
mDebug("take snode snapshot, nodeId:%d %s", entry.nodeId, buf);
}
sdbRelease(pMnode->pSdb, pObj);
}
return code;
}
static int32_t mndCheckMnodeStatus(SMnode* pMnode) {
int32_t code = 0;
ESdbStatus objStatus;
void *pIter = NULL;
SMnodeObj *pObj = NULL;
while (1) {
pIter = sdbFetchAll(pMnode->pSdb, SDB_MNODE, pIter, (void **)&pObj, &objStatus, true);
if (pIter == NULL) {
break;
}
if (pObj->syncState != TAOS_SYNC_STATE_LEADER && pObj->syncState != TAOS_SYNC_STATE_FOLLOWER) {
mDebug("mnode sync state:%d not leader/follower", pObj->syncState);
sdbRelease(pMnode->pSdb, pObj);
sdbCancelFetch(pMnode->pSdb, pIter);
return TSDB_CODE_FAILED;
}
if (objStatus != SDB_STATUS_READY) {
mWarn("mnode status:%d not ready", objStatus);
sdbRelease(pMnode->pSdb, pObj);
sdbCancelFetch(pMnode->pSdb, pIter);
return TSDB_CODE_FAILED;
}
sdbRelease(pMnode->pSdb, pObj);
}
return TSDB_CODE_SUCCESS;
}
static int32_t mndCheckAndAddVgroupsInfo(SMnode *pMnode, SArray *pVgroupList, bool* allReady) {
SSdb *pSdb = pMnode->pSdb;
void *pIter = NULL;
SVgObj *pVgroup = NULL;
int32_t code = 0;
SArray *pVgroupList = NULL;
SHashObj *pHash = NULL;
pVgroupList = taosArrayInit(4, sizeof(SNodeEntry));
if (pVgroupList == NULL) {
mError("failed to prepare arraylist during take vgroup snapshot, code:%s", tstrerror(terrno));
code = terrno;
goto _err;
}
pHash = taosHashInit(10, taosGetDefaultHashFunction(TSDB_DATA_TYPE_BIGINT), false, HASH_NO_LOCK);
if (pHash == NULL) {
mError("failed to prepare hashmap during take vgroup snapshot, code:%s", tstrerror(terrno));
code = terrno;
goto _err;
return terrno;
}
*allReady = true;
while (1) {
pIter = sdbFetch(pSdb, SDB_VGROUP, pIter, (void **)&pVgroup);
if (pIter == NULL) {
@ -148,7 +212,7 @@ int32_t mndTakeVgroupSnapshot(SMnode *pMnode, bool *allReady, SArray **pList) {
mError("failed to put info into hashmap during task vgroup snapshot, code:%s", tstrerror(code));
sdbRelease(pSdb, pVgroup);
sdbCancelFetch(pSdb, pIter);
goto _err; // take snapshot failed, and not all ready
goto _end; // take snapshot failed, and not all ready
}
} else {
if (*pReplica != pVgroup->replica) {
@ -158,7 +222,7 @@ int32_t mndTakeVgroupSnapshot(SMnode *pMnode, bool *allReady, SArray **pList) {
}
}
// if not all ready till now, no need to check the remaining vgroups.
// if not all ready till now, no need to check the remaining vgroups,
// but still we need to put the info of the existed vgroups into the snapshot list
if (*allReady) {
*allReady = checkStatusForEachReplica(pVgroup);
@ -176,7 +240,7 @@ int32_t mndTakeVgroupSnapshot(SMnode *pMnode, bool *allReady, SArray **pList) {
code = terrno;
sdbRelease(pSdb, pVgroup);
sdbCancelFetch(pSdb, pIter);
goto _err;
goto _end;
} else {
mDebug("take node snapshot, nodeId:%d %s", entry.nodeId, buf);
}
@ -184,51 +248,49 @@ int32_t mndTakeVgroupSnapshot(SMnode *pMnode, bool *allReady, SArray **pList) {
sdbRelease(pSdb, pVgroup);
}
SSnodeObj *pObj = NULL;
while (1) {
pIter = sdbFetch(pSdb, SDB_SNODE, pIter, (void **)&pObj);
if (pIter == NULL) {
break;
}
_end:
taosHashCleanup(pHash);
return code;
}
SNodeEntry entry = {.nodeId = SNODE_HANDLE};
code = addEpIntoEpSet(&entry.epset, pObj->pDnode->fqdn, pObj->pDnode->port);
if (code) {
sdbRelease(pSdb, pObj);
sdbCancelFetch(pSdb, pIter);
mError("failed to extract epset for fqdn:%s during task vgroup snapshot", pObj->pDnode->fqdn);
goto _err;
}
int32_t mndTakeVgroupSnapshot(SMnode *pMnode, bool *allReady, SArray **pList) {
int32_t code = 0;
SArray *pVgroupList = NULL;
char buf[256] = {0};
code = epsetToStr(&entry.epset, buf, tListLen(buf));
if (code != 0) { // print error and continue
mError("failed to convert epset to str, code:%s", tstrerror(code));
}
*pList = NULL;
*allReady = true;
void *p = taosArrayPush(pVgroupList, &entry);
if (p == NULL) {
code = terrno;
sdbRelease(pSdb, pObj);
sdbCancelFetch(pSdb, pIter);
mError("failed to put entry in vgroup list, nodeId:%d code:%s", entry.nodeId, tstrerror(code));
goto _err;
} else {
mDebug("take snode snapshot, nodeId:%d %s", entry.nodeId, buf);
}
pVgroupList = taosArrayInit(4, sizeof(SNodeEntry));
if (pVgroupList == NULL) {
mError("failed to prepare arraylist during take vgroup snapshot, code:%s", tstrerror(terrno));
code = terrno;
goto _err;
}
sdbRelease(pSdb, pObj);
// 1. check for all vnodes status
code = mndCheckAndAddVgroupsInfo(pMnode, pVgroupList, allReady);
if (code) {
goto _err;
}
// 2. add snode info
code = mndAddSnodeInfo(pMnode, pVgroupList);
if (code) {
goto _err;
}
// 3. check for mnode status
code = mndCheckMnodeStatus(pMnode);
if (code != TSDB_CODE_SUCCESS) {
*allReady = false;
}
*pList = pVgroupList;
taosHashCleanup(pHash);
return code;
_err:
*allReady = false;
taosArrayDestroy(pVgroupList);
taosHashCleanup(pHash);
return code;
}

View File

@ -57,8 +57,6 @@ TEST_F(MndTestProfile, 01_ConnectMsg) {
EXPECT_NE(connectRsp.connId, 0);
EXPECT_EQ(connectRsp.superUser, 1);
EXPECT_EQ(connectRsp.epSet.inUse, 0);
EXPECT_EQ(connectRsp.epSet.numOfEps, 1);
EXPECT_EQ(connectRsp.epSet.eps[0].port, 9031);
EXPECT_STREQ(connectRsp.epSet.eps[0].fqdn, "localhost");

View File

@ -56,10 +56,12 @@ extern "C" {
}
#define SDB_GET_INT64(pData, dataPos, val, pos) SDB_GET_VAL(pData, dataPos, val, pos, sdbGetRawInt64, int64_t)
#define SDB_GET_FLOAT(pData, dataPos, val, pos) SDB_GET_VAL(pData, dataPos, val, pos, sdbGetRawFloat, float)
#define SDB_GET_INT32(pData, dataPos, val, pos) SDB_GET_VAL(pData, dataPos, val, pos, sdbGetRawInt32, int32_t)
#define SDB_GET_INT16(pData, dataPos, val, pos) SDB_GET_VAL(pData, dataPos, val, pos, sdbGetRawInt16, int16_t)
#define SDB_GET_INT8(pData, dataPos, val, pos) SDB_GET_VAL(pData, dataPos, val, pos, sdbGetRawInt8, int8_t)
#define SDB_GET_UINT8(pData, dataPos, val, pos) SDB_GET_VAL(pData, dataPos, val, pos, sdbGetRawUInt8, uint8_t)
#define SDB_GET_BOOL(pData, dataPos, val, pos) SDB_GET_VAL(pData, dataPos, val, pos, sdbGetRawBool, bool)
#define SDB_GET_RESERVE(pRaw, dataPos, valLen, pos) \
{ \
@ -81,6 +83,8 @@ extern "C" {
#define SDB_SET_INT16(pRaw, dataPos, val, pos) SDB_SET_VAL(pRaw, dataPos, val, pos, sdbSetRawInt16, int16_t)
#define SDB_SET_INT8(pRaw, dataPos, val, pos) SDB_SET_VAL(pRaw, dataPos, val, pos, sdbSetRawInt8, int8_t)
#define SDB_SET_UINT8(pRaw, dataPos, val, pos) SDB_SET_VAL(pRaw, dataPos, val, pos, sdbSetRawUInt8, uint8_t)
#define SDB_SET_FLOAT(pRaw, dataPos, val, pos) SDB_SET_VAL(pRaw, dataPos, val, pos, sdbSetRawFloat, float)
#define SDB_SET_BOOL(pRaw, dataPos, val, pos) SDB_SET_VAL(pRaw, dataPos, val, pos, sdbSetRawBool, bool)
#define SDB_SET_BINARY(pRaw, dataPos, val, valLen, pos) \
{ \
@ -113,6 +117,7 @@ typedef int32_t (*SdbInsertFp)(SSdb *pSdb, void *pObj);
typedef int32_t (*SdbUpdateFp)(SSdb *pSdb, void *pSrcObj, void *pDstObj);
typedef int32_t (*SdbDeleteFp)(SSdb *pSdb, void *pObj, bool callFunc);
typedef int32_t (*SdbDeployFp)(SMnode *pMnode);
typedef int32_t (*SdbPrepareFp)(SMnode *pMnode);
typedef int32_t (*SdbValidateFp)(SMnode *pMnode, void *pTrans, SSdbRaw *pRaw);
typedef SSdbRow *(*SdbDecodeFp)(SSdbRaw *pRaw);
typedef SSdbRaw *(*SdbEncodeFp)(void *pObj);
@ -162,7 +167,8 @@ typedef enum {
SDB_GRANT = 26, // grant log
SDB_ARBGROUP = 27,
SDB_ANODE = 28,
SDB_MAX = 29
SDB_CFG = 29,
SDB_MAX = 30
} ESdbType;
typedef struct SSdbRaw {
@ -202,6 +208,7 @@ typedef struct SSdb {
SdbUpdateFp updateFps[SDB_MAX];
SdbDeleteFp deleteFps[SDB_MAX];
SdbDeployFp deployFps[SDB_MAX];
SdbPrepareFp prepareFps[SDB_MAX];
SdbEncodeFp encodeFps[SDB_MAX];
SdbDecodeFp decodeFps[SDB_MAX];
SdbValidateFp validateFps[SDB_MAX];
@ -218,6 +225,7 @@ typedef struct {
ESdbType sdbType;
EKeyType keyType;
SdbDeployFp deployFp;
SdbPrepareFp prepareFp;
SdbEncodeFp encodeFp;
SdbDecodeFp decodeFp;
SdbInsertFp insertFp;
@ -265,6 +273,14 @@ int32_t sdbSetTable(SSdb *pSdb, SSdbTable table);
*/
int32_t sdbDeploy(SSdb *pSdb);
/**
* @brief prepare the initial rows of sdb.
*
* @param pSdb The sdb object.
* @return int32_t 0 for success, -1 for failure.
*/
int32_t sdbPrepare(SSdb *pSdb);
/**
* @brief Load sdb from file.
*
@ -373,7 +389,7 @@ int32_t sdbGetSize(SSdb *pSdb, ESdbType type);
/**
* @brief get valid number of rows, removed rows are ignored
*/
int32_t sdbGetValidSize(SSdb* pSdb, ESdbType type);
int32_t sdbGetValidSize(SSdb *pSdb, ESdbType type);
/**
* @brief Get the max id of the table, keyType of table should be INT32
@ -407,17 +423,21 @@ SSdbRaw *sdbAllocRaw(ESdbType type, int8_t sver, int32_t dataLen);
void sdbFreeRaw(SSdbRaw *pRaw);
int32_t sdbSetRawInt8(SSdbRaw *pRaw, int32_t dataPos, int8_t val);
int32_t sdbSetRawUInt8(SSdbRaw *pRaw, int32_t dataPos, uint8_t val);
int32_t sdbSetRawBool(SSdbRaw *pRaw, int32_t dataPos, bool val);
int32_t sdbSetRawInt16(SSdbRaw *pRaw, int32_t dataPos, int16_t val);
int32_t sdbSetRawInt32(SSdbRaw *pRaw, int32_t dataPos, int32_t val);
int32_t sdbSetRawInt64(SSdbRaw *pRaw, int32_t dataPos, int64_t val);
int32_t sdbSetRawFloat(SSdbRaw *pRaw, int32_t dataPos, float val);
int32_t sdbSetRawBinary(SSdbRaw *pRaw, int32_t dataPos, const char *pVal, int32_t valLen);
int32_t sdbSetRawDataLen(SSdbRaw *pRaw, int32_t dataLen);
int32_t sdbSetRawStatus(SSdbRaw *pRaw, ESdbStatus status);
int32_t sdbGetRawInt8(SSdbRaw *pRaw, int32_t dataPos, int8_t *val);
int32_t sdbGetRawUInt8(SSdbRaw *pRaw, int32_t dataPos, uint8_t *val);
int32_t sdbGetRawBool(SSdbRaw *pRaw, int32_t dataPos, bool *val);
int32_t sdbGetRawInt16(SSdbRaw *pRaw, int32_t dataPos, int16_t *val);
int32_t sdbGetRawInt32(SSdbRaw *pRaw, int32_t dataPos, int32_t *val);
int32_t sdbGetRawInt64(SSdbRaw *pRaw, int32_t dataPos, int64_t *val);
int32_t sdbGetRawFloat(SSdbRaw *pRaw, int32_t dataPos, float *val);
int32_t sdbGetRawBinary(SSdbRaw *pRaw, int32_t dataPos, char *pVal, int32_t valLen);
int32_t sdbGetRawSoftVer(SSdbRaw *pRaw, int8_t *sver);
int32_t sdbGetRawTotalSize(SSdbRaw *pRaw);

View File

@ -127,6 +127,7 @@ int32_t sdbSetTable(SSdb *pSdb, SSdbTable table) {
pSdb->deployFps[sdbType] = table.deployFp;
pSdb->encodeFps[sdbType] = table.encodeFp;
pSdb->decodeFps[sdbType] = table.decodeFp;
pSdb->prepareFps[sdbType] = table.prepareFp;
pSdb->validateFps[sdbType] = table.validateFp;
int32_t hashType = 0;

View File

@ -48,6 +48,26 @@ static int32_t sdbDeployData(SSdb *pSdb) {
return 0;
}
static int32_t sdbPrepareData(SSdb *pSdb) {
int32_t code = 0;
mInfo("start to prepare sdb");
for (int32_t i = SDB_MAX - 1; i >= 0; --i) {
SdbPrepareFp fp = pSdb->prepareFps[i];
if (fp == NULL) continue;
mInfo("start to prepare sdb:%s", sdbTableName(i));
code = (*fp)(pSdb->pMnode);
if (code != 0) {
mError("failed to prepare sdb:%s since %s", sdbTableName(i), tstrerror(code));
return -1;
}
}
mInfo("sdb prepare success");
return 0;
}
static void sdbResetData(SSdb *pSdb) {
mInfo("start to reset sdb");
@ -395,7 +415,7 @@ static int32_t sdbReadFileImp(SSdb *pSdb) {
code = sdbWriteWithoutFree(pSdb, pRaw);
if (code != 0) {
mError("failed to read sdb file:%s since %s", file, terrstr());
mError("failed to exec sdbWrite while read sdb file:%s since %s", file, terrstr());
goto _OVER;
}
}
@ -646,6 +666,15 @@ int32_t sdbDeploy(SSdb *pSdb) {
return 0;
}
int32_t sdbPrepare(SSdb *pSdb) {
int32_t code = 0;
code = sdbPrepareData(pSdb);
if (code != 0) {
TAOS_RETURN(code);
}
return 0;
}
static SSdbIter *sdbCreateIter(SSdb *pSdb) {
SSdbIter *pIter = taosMemoryCalloc(1, sizeof(SSdbIter));
if (pIter == NULL) {

View File

@ -76,6 +76,8 @@ const char *sdbTableName(ESdbType type) {
return "arb_group";
case SDB_ANODE:
return "anode";
case SDB_CFG:
return "config";
default:
return "undefine";
}
@ -259,6 +261,9 @@ static int32_t sdbDeleteRow(SSdb *pSdb, SHashObj *hash, SSdbRaw *pRaw, SSdbRow *
}
int32_t sdbWriteWithoutFree(SSdb *pSdb, SSdbRaw *pRaw) {
if (pRaw->type == SDB_CFG) {
mTrace("sdb write cfg");
}
SHashObj *hash = sdbGetHash(pSdb, pRaw->type);
if (hash == NULL) return terrno;
@ -444,7 +449,7 @@ void *sdbFetchAll(SSdb *pSdb, ESdbType type, void *pIter, void **ppObj, ESdbStat
void sdbCancelFetch(SSdb *pSdb, void *pIter) {
if (pIter == NULL) return;
SSdbRow *pRow = *(SSdbRow **)pIter;
SSdbRow *pRow = *(SSdbRow **)pIter;
mTrace("cancel fetch row:%p", pRow);
SHashObj *hash = sdbGetHash(pSdb, pRow->type);
if (hash == NULL) return;
@ -532,12 +537,12 @@ int64_t sdbGetTableVer(SSdb *pSdb, ESdbType type) {
}
bool countValid(SMnode *pMnode, void *pObj, void *p1, void *p2, void *p3) {
int32_t* pInt = p1;
int32_t *pInt = p1;
(*pInt) += 1;
return true;
}
int32_t sdbGetValidSize(SSdb* pSdb, ESdbType type) {
int32_t sdbGetValidSize(SSdb *pSdb, ESdbType type) {
int32_t num = 0;
sdbTraverse(pSdb, type, countValid, &num, 0, 0);
return num;

View File

@ -84,6 +84,14 @@ int32_t sdbSetRawUInt8(SSdbRaw *pRaw, int32_t dataPos, uint8_t val) {
return 0;
}
int32_t sdbSetRawBool(SSdbRaw *pRaw, int32_t dataPos, bool val) {
if (val) {
return sdbSetRawUInt8(pRaw, dataPos, 1);
} else {
return sdbSetRawUInt8(pRaw, dataPos, 0);
}
}
int32_t sdbSetRawInt32(SSdbRaw *pRaw, int32_t dataPos, int32_t val) {
int32_t code = 0;
if (pRaw == NULL) {
@ -132,6 +140,22 @@ int32_t sdbSetRawInt64(SSdbRaw *pRaw, int32_t dataPos, int64_t val) {
return 0;
}
int32_t sdbSetRawFloat(SSdbRaw *pRaw, int32_t dataPos, float val) {
int32_t code = 0;
if (pRaw == NULL) {
code = TSDB_CODE_INVALID_PTR;
TAOS_RETURN(code);
}
if (dataPos + sizeof(float) > pRaw->dataLen) {
code = TSDB_CODE_SDB_INVALID_DATA_LEN;
TAOS_RETURN(code);
}
*(int64_t *)(pRaw->pData + dataPos) = val;
return 0;
}
int32_t sdbSetRawBinary(SSdbRaw *pRaw, int32_t dataPos, const char *pVal, int32_t valLen) {
int32_t code = 0;
if (pRaw == NULL) {
@ -214,6 +238,21 @@ int32_t sdbGetRawUInt8(SSdbRaw *pRaw, int32_t dataPos, uint8_t *val) {
return 0;
}
int32_t sdbGetRawBool(SSdbRaw *pRaw, int32_t dataPos, bool *val) {
int32_t code = 0;
uint8_t v = 0;
code = sdbGetRawUInt8(pRaw, dataPos, &v);
if (code != TSDB_CODE_SUCCESS) {
return code;
}
if (v) {
*val = true;
} else {
*val = false;
}
return TSDB_CODE_SUCCESS;
}
int32_t sdbGetRawInt32(SSdbRaw *pRaw, int32_t dataPos, int32_t *val) {
int32_t code = 0;
if (pRaw == NULL) {
@ -262,6 +301,22 @@ int32_t sdbGetRawInt64(SSdbRaw *pRaw, int32_t dataPos, int64_t *val) {
return 0;
}
int32_t sdbGetRawFloat(SSdbRaw *pRaw, int32_t dataPos, float *val) {
int32_t code = 0;
if (pRaw == NULL) {
code = TSDB_CODE_INVALID_PTR;
TAOS_RETURN(code);
}
if (dataPos + sizeof(float) > pRaw->dataLen) {
code = TSDB_CODE_SDB_INVALID_DATA_LEN;
TAOS_RETURN(code);
}
*val = *(int64_t *)(pRaw->pData + dataPos);
return 0;
}
int32_t sdbGetRawBinary(SSdbRaw *pRaw, int32_t dataPos, char *pVal, int32_t valLen) {
int32_t code = 0;
if (pRaw == NULL) {

View File

@ -341,6 +341,12 @@ struct SVnodeCfg {
#define TABLE_IS_COL_COMPRESSED(FLG) (((FLG) & (TABLE_COL_COMPRESSED)) != 0)
#define TABLE_SET_COL_COMPRESSED(FLG) ((FLG) |= TABLE_COL_COMPRESSED)
struct SFileSetReader;
int32_t tsdbFileSetReaderOpen(void *pVnode, struct SFileSetReader **ppReader);
int32_t tsdbFileSetReaderNext(struct SFileSetReader *pReader);
int32_t tsdbFileSetGetEntryField(struct SFileSetReader *pReader, const char *field, void *value);
void tsdbFileSetReaderClose(struct SFileSetReader **ppReader);
#ifdef __cplusplus
}
#endif

View File

@ -250,6 +250,7 @@ void *tsdbTbDataIterDestroy(STbDataIter *pIter);
void tsdbTbDataIterOpen(STbData *pTbData, STsdbRowKey *pFrom, int8_t backward, STbDataIter *pIter);
bool tsdbTbDataIterNext(STbDataIter *pIter);
void tsdbMemTableCountRows(SMemTable *pMemTable, SSHashObj *pTableMap, int64_t *rowsNum);
int32_t tsdbMemTableSaveToCache(SMemTable *pMemTable, void *func);
// STbData
int32_t tsdbGetNRowsInTbData(STbData *pTbData);
@ -335,7 +336,6 @@ struct STsdbFS {
typedef struct {
rocksdb_t *db;
rocksdb_comparator_t *my_comparator;
rocksdb_cache_t *blockcache;
rocksdb_block_based_table_options_t *tableoptions;
rocksdb_options_t *options;
rocksdb_flushoptions_t *flushoptions;
@ -347,6 +347,7 @@ typedef struct {
tb_uid_t suid;
tb_uid_t uid;
STSchema *pTSchema;
SArray *ctxArray;
} SRocksCache;
typedef struct {
@ -379,7 +380,7 @@ struct STsdb {
struct {
SVHashTable *ht;
SArray *arr;
} * commitInfo;
} *commitInfo;
};
struct TSDBKEY {
@ -1082,6 +1083,9 @@ void tsdbRemoveFile(const char *path);
} \
} while (0)
int32_t tsdbInit();
void tsdbCleanUp();
#ifdef __cplusplus
}
#endif

View File

@ -197,7 +197,7 @@ static int32_t metaOpenImpl(SVnode *pVnode, SMeta **ppMeta, const char *metaDir,
code = tdbTbOpen("suid.idx", sizeof(tb_uid_t), 0, uidIdxKeyCmpr, pMeta->pEnv, &pMeta->pSuidIdx, 0);
TSDB_CHECK_CODE(code, lino, _exit);
sprintf(indexFullPath, "%s/%s", pMeta->path, "invert");
(void)tsnprintf(indexFullPath, sizeof(indexFullPath), "%s/%s", pMeta->path, "invert");
ret = taosMkDir(indexFullPath);
SIndexOpts opts = {.cacheSize = 8 * 1024 * 1024};
@ -209,7 +209,7 @@ static int32_t metaOpenImpl(SVnode *pVnode, SMeta **ppMeta, const char *metaDir,
// open pTtlMgr ("ttlv1.idx")
char logPrefix[128] = {0};
sprintf(logPrefix, "vgId:%d", TD_VID(pVnode));
(void)tsnprintf(logPrefix, sizeof(logPrefix), "vgId:%d", TD_VID(pVnode));
code = ttlMgrOpen(&pMeta->pTtlMgr, pMeta->pEnv, 0, logPrefix, tsTtlFlushThreshold);
TSDB_CHECK_CODE(code, lino, _exit);

View File

@ -164,7 +164,7 @@ int metaGetTableSzNameByUid(void *meta, uint64_t uid, char *tbName) {
metaReaderClear(&mr);
return code;
}
strncpy(tbName, mr.me.name, TSDB_TABLE_NAME_LEN);
tstrncpy(tbName, mr.me.name, TSDB_TABLE_NAME_LEN);
metaReaderClear(&mr);
return 0;

File diff suppressed because it is too large Load Diff

View File

@ -1239,3 +1239,146 @@ void tsdbFinishTaskOnFileSet(STsdb *tsdb, int32_t fid) {
}
}
}
struct SFileSetReader {
STsdb *pTsdb;
STFileSet *pFileSet;
int32_t fid;
int64_t startTime;
int64_t endTime;
int64_t lastCompactTime;
int64_t totalSize;
};
int32_t tsdbFileSetReaderOpen(void *pVnode, struct SFileSetReader **ppReader) {
if (pVnode == NULL || ppReader == NULL) {
return TSDB_CODE_INVALID_PARA;
}
STsdb *pTsdb = ((SVnode *)pVnode)->pTsdb;
(*ppReader) = taosMemoryCalloc(1, sizeof(struct SFileSetReader));
if (*ppReader == NULL) {
tsdbError("vgId:%d %s failed at %s:%d since %s", TD_VID(pTsdb->pVnode), __func__, __FILE__, __LINE__,
tstrerror(terrno));
return terrno;
}
(*ppReader)->pTsdb = pTsdb;
(*ppReader)->fid = INT32_MIN;
(*ppReader)->pFileSet = NULL;
return TSDB_CODE_SUCCESS;
}
static int32_t tsdbFileSetReaderNextNoLock(struct SFileSetReader *pReader) {
STsdb *pTsdb = pReader->pTsdb;
int32_t code = TSDB_CODE_SUCCESS;
tsdbTFileSetClear(&pReader->pFileSet);
STFileSet *fset = &(STFileSet){
.fid = pReader->fid,
};
STFileSet **fsetPtr = TARRAY2_SEARCH(pReader->pTsdb->pFS->fSetArr, &fset, tsdbTFileSetCmprFn, TD_GT);
if (fsetPtr == NULL) {
pReader->fid = INT32_MAX;
return TSDB_CODE_NOT_FOUND;
}
// ref file set
code = tsdbTFileSetInitRef(pReader->pTsdb, *fsetPtr, &pReader->pFileSet);
if (code) return code;
// get file set details
pReader->fid = pReader->pFileSet->fid;
tsdbFidKeyRange(pReader->fid, pTsdb->keepCfg.days, pTsdb->keepCfg.precision, &pReader->startTime, &pReader->endTime);
pReader->lastCompactTime = 0; // TODO
pReader->totalSize = 0;
for (int32_t i = 0; i < TSDB_FTYPE_MAX; i++) {
STFileObj *fobj = pReader->pFileSet->farr[i];
if (fobj) {
pReader->totalSize += fobj->f->size;
}
}
SSttLvl *lvl;
TARRAY2_FOREACH(pReader->pFileSet->lvlArr, lvl) {
STFileObj *fobj;
TARRAY2_FOREACH(lvl->fobjArr, fobj) { pReader->totalSize += fobj->f->size; }
}
return code;
}
int32_t tsdbFileSetReaderNext(struct SFileSetReader *pReader) {
int32_t code = TSDB_CODE_SUCCESS;
(void)taosThreadMutexLock(&pReader->pTsdb->mutex);
code = tsdbFileSetReaderNextNoLock(pReader);
(void)taosThreadMutexUnlock(&pReader->pTsdb->mutex);
return code;
}
int32_t tsdbFileSetGetEntryField(struct SFileSetReader *pReader, const char *field, void *value) {
const char *fieldName;
if (pReader->fid == INT32_MIN || pReader->fid == INT32_MAX) {
return TSDB_CODE_INVALID_PARA;
}
fieldName = "fileset_id";
if (strncmp(field, fieldName, strlen(fieldName) + 1) == 0) {
*(int32_t *)value = pReader->fid;
return TSDB_CODE_SUCCESS;
}
fieldName = "start_time";
if (strncmp(field, fieldName, strlen(fieldName) + 1) == 0) {
*(int64_t *)value = pReader->startTime;
return TSDB_CODE_SUCCESS;
}
fieldName = "end_time";
if (strncmp(field, fieldName, strlen(fieldName) + 1) == 0) {
*(int64_t *)value = pReader->endTime;
return TSDB_CODE_SUCCESS;
}
fieldName = "total_size";
if (strncmp(field, fieldName, strlen(fieldName) + 1) == 0) {
*(int64_t *)value = pReader->totalSize;
return TSDB_CODE_SUCCESS;
}
fieldName = "last_compact_time";
if (strncmp(field, fieldName, strlen(fieldName) + 1) == 0) {
*(int64_t *)value = pReader->lastCompactTime;
return TSDB_CODE_SUCCESS;
}
fieldName = "should_compact";
if (strncmp(field, fieldName, strlen(fieldName) + 1) == 0) {
*(char *)value = 0; // TODO
return TSDB_CODE_SUCCESS;
}
fieldName = "details";
if (strncmp(field, fieldName, strlen(fieldName) + 1) == 0) {
// TODO
return TSDB_CODE_SUCCESS;
}
return TSDB_CODE_INVALID_PARA;
}
void tsdbFileSetReaderClose(struct SFileSetReader **ppReader) {
if (ppReader == NULL || *ppReader == NULL) {
return;
}
tsdbTFileSetClear(&(*ppReader)->pFileSet);
taosMemoryFree(*ppReader);
*ppReader = NULL;
return;
}

View File

@ -325,6 +325,27 @@ void tsdbMemTableCountRows(SMemTable *pMemTable, SSHashObj *pTableMap, int64_t *
taosRUnLockLatch(&pMemTable->latch);
}
typedef int32_t (*__tsdb_cache_update)(SMemTable *imem, int64_t suid, int64_t uid);
int32_t tsdbMemTableSaveToCache(SMemTable *pMemTable, void *func) {
int32_t code = 0;
__tsdb_cache_update cb = (__tsdb_cache_update)func;
for (int32_t i = 0; i < pMemTable->nBucket; ++i) {
STbData *pTbData = pMemTable->aBucket[i];
while (pTbData) {
code = (*cb)(pMemTable, pTbData->suid, pTbData->uid);
if (code) {
TAOS_RETURN(code);
}
pTbData = pTbData->next;
}
}
return code;
}
static int32_t tsdbMemTableRehash(SMemTable *pMemTable) {
int32_t code = 0;
@ -659,7 +680,7 @@ static int32_t tsdbInsertColDataToTable(SMemTable *pMemTable, STbData *pTbData,
pTbData->maxKey = key.key.ts;
}
if (!TSDB_CACHE_NO(pMemTable->pTsdb->pVnode->config)) {
if (!TSDB_CACHE_NO(pMemTable->pTsdb->pVnode->config) && !tsUpdateCacheBatch) {
if (tsdbCacheColFormatUpdate(pMemTable->pTsdb, pTbData->suid, pTbData->uid, pBlockData) != 0) {
tsdbError("vgId:%d, failed to update cache data from table suid:%" PRId64 " uid:%" PRId64 " at version %" PRId64,
TD_VID(pMemTable->pTsdb->pVnode), pTbData->suid, pTbData->uid, version);
@ -721,7 +742,7 @@ static int32_t tsdbInsertRowDataToTable(SMemTable *pMemTable, STbData *pTbData,
if (key.key.ts >= pTbData->maxKey) {
pTbData->maxKey = key.key.ts;
}
if (!TSDB_CACHE_NO(pMemTable->pTsdb->pVnode->config)) {
if (!TSDB_CACHE_NO(pMemTable->pTsdb->pVnode->config) && !tsUpdateCacheBatch) {
TAOS_UNUSED(tsdbCacheRowFormatUpdate(pMemTable->pTsdb, pTbData->suid, pTbData->uid, version, nRow, aRow));
}

View File

@ -18,6 +18,22 @@
extern int32_t tsdbOpenCompMonitor(STsdb *tsdb);
extern void tsdbCloseCompMonitor(STsdb *tsdb);
extern int32_t tsdbInitCompact();
extern void tsdbCleanupCompact();
int32_t tsdbInit() {
#ifdef TD_ENTERPRISE
return tsdbInitCompact();
#endif
return 0;
}
void tsdbCleanUp() {
#ifdef TD_ENTERPRISE
tsdbCleanupCompact();
#endif
return;
}
void tsdbSetKeepCfg(STsdb *pTsdb, STsdbCfg *pCfg) {
STsdbKeepCfg *pKeepCfg = &pTsdb->keepCfg;

View File

@ -104,7 +104,7 @@ int32_t tsdbOpenFile(const char *path, STsdb *pTsdb, int32_t flag, STsdbFD **ppF
}
pFD->path = (char *)&pFD[1];
strcpy(pFD->path, path);
tstrncpy(pFD->path, path, strlen(path) + 1);
pFD->szPage = szPage;
pFD->flag = flag;
pFD->szPage = szPage;
@ -174,7 +174,6 @@ static int32_t tsdbWriteFilePage(STsdbFD *pFD, int32_t encryptAlgorithm, char *e
opts.source = pFD->pBuf + count;
opts.result = PacketData;
opts.unitLen = 128;
// strncpy(opts.key, tsEncryptKey, 16);
tstrncpy(opts.key, encryptKey, ENCRYPT_KEY_LEN + 1);
NewLen = CBC_Encrypt(&opts);
@ -248,7 +247,6 @@ static int32_t tsdbReadFilePage(STsdbFD *pFD, int64_t pgno, int32_t encryptAlgor
opts.source = pFD->pBuf + count;
opts.result = PacketData;
opts.unitLen = 128;
// strncpy(opts.key, tsEncryptKey, 16);
tstrncpy(opts.key, encryptKey, ENCRYPT_KEY_LEN + 1);
NewLen = CBC_Decrypt(&opts);

View File

@ -330,7 +330,7 @@ static int32_t vnodeAsyncInit(SVAsync **async, const char *label) {
return terrno;
}
strcpy((char *)((*async) + 1), label);
tstrncpy((char *)((*async) + 1), label, strlen(label) + 1);
(*async)->label = (const char *)((*async) + 1);
(void)taosThreadMutexInit(&(*async)->mutex, NULL);

View File

@ -303,7 +303,7 @@ int vnodeDecodeConfig(const SJson *pJson, void *pObj) {
if (tsEncryptKey[0] == 0) {
return terrno = TSDB_CODE_DNODE_INVALID_ENCRYPTKEY;
} else {
strncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
tstrncpy(pCfg->tdbEncryptKey, tsEncryptKey, ENCRYPT_KEY_LEN);
}
}
#endif

View File

@ -103,11 +103,11 @@ static int32_t vnodeGetBufPoolToUse(SVnode *pVnode) {
}
code = taosThreadCondTimedWait(&pVnode->poolNotEmpty, &pVnode->mutex, &ts);
if (code && code != TSDB_CODE_TIMEOUT_ERROR) {
TSDB_CHECK_CODE(code, lino, _exit);
// ignore timeout error and retry
if (code == TSDB_CODE_TIMEOUT_ERROR) {
code = TSDB_CODE_SUCCESS;
}
code = 0;
TSDB_CHECK_CODE(code, lino, _exit);
}
}
}

View File

@ -63,6 +63,12 @@ void initTsdbReaderAPI(TsdReader* pReader) {
pReader->tsdSetFilesetDelimited = (void (*)(void*))tsdbSetFilesetDelimited;
pReader->tsdSetSetNotifyCb = (void (*)(void*, TsdReaderNotifyCbFn, void*))tsdbReaderSetNotifyCb;
// file set iterate
pReader->fileSetReaderOpen = tsdbFileSetReaderOpen;
pReader->fileSetReadNext = tsdbFileSetReaderNext;
pReader->fileSetGetEntryField = tsdbFileSetGetEntryField;
pReader->fileSetReaderClose = tsdbFileSetReaderClose;
}
void initMetadataAPI(SStoreMeta* pMeta) {

View File

@ -15,6 +15,7 @@
#include "cos.h"
#include "monitor.h"
#include "tsdb.h"
#include "vnd.h"
static volatile int32_t VINIT = 0;
@ -26,6 +27,7 @@ int vnodeInit(int nthreads, StopDnodeFp stopDnodeFp) {
TAOS_CHECK_RETURN(vnodeAsyncOpen(nthreads));
TAOS_CHECK_RETURN(walInit(stopDnodeFp));
TAOS_CHECK_RETURN(tsdbInit());
monInitVnode();
@ -34,6 +36,7 @@ int vnodeInit(int nthreads, StopDnodeFp stopDnodeFp) {
void vnodeCleanup() {
if (atomic_val_compare_exchange_32(&VINIT, 1, 0) == 0) return;
tsdbCleanUp();
vnodeAsyncClose();
walCleanUp();
smaCleanUp();

View File

@ -168,7 +168,7 @@ int32_t vnodeAlterReplica(const char *path, SAlterVnodeReplicaReq *pReq, int32_t
static int32_t vnodeVgroupIdLen(int32_t vgId) {
char tmp[TSDB_FILENAME_LEN];
sprintf(tmp, "%d", vgId);
(void)tsnprintf(tmp, TSDB_FILENAME_LEN, "%d", vgId);
return strlen(tmp);
}
@ -199,7 +199,7 @@ int32_t vnodeRenameVgroupId(const char *srcPath, const char *dstPath, int32_t sr
char *tsdbFilePrefixPos = strstr(oldRname, tsdbFilePrefix);
if (tsdbFilePrefixPos == NULL) continue;
int32_t tsdbFileVgId = 0; // atoi(tsdbFilePrefixPos + prefixLen);
int32_t tsdbFileVgId = 0;
ret = taosStr2int32(tsdbFilePrefixPos + prefixLen, &tsdbFileVgId);
if (ret != 0) {
vError("vgId:%d, failed to get tsdb file vgid since %s", dstVgId, tstrerror(ret));
@ -417,7 +417,7 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC
}
pVnode->path = (char *)&pVnode[1];
strcpy(pVnode->path, path);
tstrncpy(pVnode->path, path, strlen(path) + 1);
pVnode->config = info.config;
pVnode->state.committed = info.state.committed;
pVnode->state.commitTerm = info.state.commitTerm;
@ -472,7 +472,7 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC
}
// open wal
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_WAL_DIR);
(void)tsnprintf(tdir, sizeof(tdir), "%s%s%s", dir, TD_DIRSEP, VNODE_WAL_DIR);
ret = taosRealPath(tdir, NULL, sizeof(tdir));
TAOS_UNUSED(ret);
@ -484,7 +484,7 @@ SVnode *vnodeOpen(const char *path, int32_t diskPrimary, STfs *pTfs, SMsgCb msgC
}
// open tq
sprintf(tdir, "%s%s%s", dir, TD_DIRSEP, VNODE_TQ_DIR);
(void)tsnprintf(tdir, sizeof(tdir), "%s%s%s", dir, TD_DIRSEP, VNODE_TQ_DIR);
ret = taosRealPath(tdir, NULL, sizeof(tdir));
TAOS_UNUSED(ret);

View File

@ -71,11 +71,11 @@ int32_t vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
if (infoReq.option == REQ_OPT_TBUID) reqTbUid = true;
metaRsp.dbId = pVnode->config.dbId;
(void)strcpy(metaRsp.tbName, infoReq.tbName);
tstrncpy(metaRsp.tbName, infoReq.tbName, TSDB_TABLE_NAME_LEN);
(void)memcpy(metaRsp.dbFName, infoReq.dbFName, sizeof(metaRsp.dbFName));
if (!reqTbUid) {
TAOS_UNUSED(sprintf(tableFName, "%s.%s", infoReq.dbFName, infoReq.tbName));
(void)tsnprintf(tableFName, TSDB_TABLE_FNAME_LEN, "%s.%s", infoReq.dbFName, infoReq.tbName);
code = vnodeValidateTableHash(pVnode, tableFName);
if (code) {
goto _exit4;
@ -105,7 +105,7 @@ int32_t vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
metaRsp.tuid = mer1.me.uid;
if (mer1.me.type == TSDB_SUPER_TABLE) {
(void)strcpy(metaRsp.stbName, mer1.me.name);
tstrncpy(metaRsp.stbName, mer1.me.name, TSDB_TABLE_NAME_LEN);
schema = mer1.me.stbEntry.schemaRow;
schemaTag = mer1.me.stbEntry.schemaTag;
metaRsp.suid = mer1.me.uid;
@ -113,7 +113,7 @@ int32_t vnodeGetTableMeta(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
metaReaderDoInit(&mer2, pVnode->pMeta, META_READER_NOLOCK);
if (metaReaderGetTableEntryByUid(&mer2, mer1.me.ctbEntry.suid) < 0) goto _exit2;
(void)strcpy(metaRsp.stbName, mer2.me.name);
tstrncpy(metaRsp.stbName, mer2.me.name, TSDB_TABLE_NAME_LEN);
metaRsp.suid = mer2.me.uid;
schema = mer2.me.stbEntry.schemaRow;
schemaTag = mer2.me.stbEntry.schemaTag;
@ -220,10 +220,10 @@ int32_t vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
goto _exit;
}
(void)strcpy(cfgRsp.tbName, cfgReq.tbName);
tstrncpy(cfgRsp.tbName, cfgReq.tbName, TSDB_TABLE_NAME_LEN);
(void)memcpy(cfgRsp.dbFName, cfgReq.dbFName, sizeof(cfgRsp.dbFName));
(void)sprintf(tableFName, "%s.%s", cfgReq.dbFName, cfgReq.tbName);
(void)tsnprintf(tableFName, TSDB_TABLE_FNAME_LEN, "%s.%s", cfgReq.dbFName, cfgReq.tbName);
code = vnodeValidateTableHash(pVnode, tableFName);
if (code) {
goto _exit;
@ -246,7 +246,7 @@ int32_t vnodeGetTableCfg(SVnode *pVnode, SRpcMsg *pMsg, bool direct) {
metaReaderDoInit(&mer2, pVnode->pMeta, META_READER_LOCK);
if (metaReaderGetTableEntryByUid(&mer2, mer1.me.ctbEntry.suid) < 0) goto _exit;
(void)strcpy(cfgRsp.stbName, mer2.me.name);
tstrncpy(cfgRsp.stbName, mer2.me.name, TSDB_TABLE_NAME_LEN);
schema = mer2.me.stbEntry.schemaRow;
schemaTag = mer2.me.stbEntry.schemaTag;
cfgRsp.ttl = mer1.me.ctbEntry.ttlDays;

View File

@ -968,7 +968,7 @@ void vnodeUpdateMetaRsp(SVnode *pVnode, STableMetaRsp *pMetaRsp) {
return;
}
strcpy(pMetaRsp->dbFName, pVnode->config.dbname);
tstrncpy(pMetaRsp->dbFName, pVnode->config.dbname, TSDB_DB_FNAME_LEN);
pMetaRsp->dbId = pVnode->config.dbId;
pMetaRsp->vgId = TD_VID(pVnode);
pMetaRsp->precision = pVnode->config.tsdbCfg.precision;
@ -1216,7 +1216,7 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq,
rcode = -1;
goto _exit;
}
strcpy(str, pCreateReq->name);
tstrncpy(str, pCreateReq->name, TSDB_TABLE_FNAME_LEN);
if (taosArrayPush(tbNames, &str) == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
rcode = -1;
@ -1225,7 +1225,7 @@ static int32_t vnodeProcessCreateTbReq(SVnode *pVnode, int64_t ver, void *pReq,
}
// validate hash
sprintf(tbName, "%s.%s", pVnode->config.dbname, pCreateReq->name);
(void)tsnprintf(tbName, TSDB_TABLE_FNAME_LEN, "%s.%s", pVnode->config.dbname, pCreateReq->name);
if (vnodeValidateTableHash(pVnode, tbName) < 0) {
cRsp.code = TSDB_CODE_VND_HASH_MISMATCH;
if (taosArrayPush(rsp.pArray, &cRsp) == NULL) {
@ -1518,7 +1518,7 @@ static int32_t vnodeProcessDropTbReq(SVnode *pVnode, int64_t ver, void *pReq, in
pRsp->code = terrno;
goto _exit;
}
strcpy(str, pDropTbReq->name);
tstrncpy(str, pDropTbReq->name, TSDB_TABLE_FNAME_LEN);
if (taosArrayPush(tbNames, &str) == NULL) {
terrno = TSDB_CODE_OUT_OF_MEMORY;
pRsp->code = terrno;

View File

@ -13,8 +13,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "command.h"
#include "catalog.h"
#include "command.h"
#include "commandInt.h"
#include "scheduler.h"
#include "systable.h"
@ -54,7 +54,7 @@ static int32_t buildRetrieveTableRsp(SSDataBlock* pBlock, int32_t numOfCols, SRe
(*pRsp)->numOfCols = htonl(numOfCols);
int32_t len = blockEncode(pBlock, (*pRsp)->data + PAYLOAD_PREFIX_LEN, dataEncodeBufSize, numOfCols);
if(len < 0) {
if (len < 0) {
taosMemoryFree(*pRsp);
*pRsp = NULL;
return terrno;
@ -223,7 +223,7 @@ static int32_t execDescribe(bool sysInfoUser, SNode* pStmt, SRetrieveTableRsp**
if (NULL == pDesc || NULL == pDesc->pMeta) {
return TSDB_CODE_INVALID_PARA;
}
int32_t numOfRows = TABLE_TOTAL_COL_NUM(pDesc->pMeta);
int32_t numOfRows = TABLE_TOTAL_COL_NUM(pDesc->pMeta);
SSDataBlock* pBlock = NULL;
int32_t code = buildDescResultDataBlock(&pBlock);
@ -411,11 +411,17 @@ static int32_t setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName,
char keep0Str[128] = {0};
char keep1Str[128] = {0};
char keep2Str[128] = {0};
char compactIntervalStr[13] = {0};
char compactStartTimeStr[13] = {0};
char compactEndTimeStr[13] = {0};
int32_t lenDuration = formatDurationOrKeep(durationStr, sizeof(durationStr), pCfg->daysPerFile);
int32_t lenKeep0 = formatDurationOrKeep(keep0Str, sizeof(keep0Str), pCfg->daysToKeep0);
int32_t lenKeep1 = formatDurationOrKeep(keep1Str, sizeof(keep1Str), pCfg->daysToKeep1);
int32_t lenKeep2 = formatDurationOrKeep(keep2Str, sizeof(keep2Str), pCfg->daysToKeep2);
UNUSED(formatDurationOrKeep(compactIntervalStr, sizeof(compactIntervalStr), pCfg->compactInterval));
UNUSED(formatDurationOrKeep(compactStartTimeStr, sizeof(compactStartTimeStr), pCfg->compactStartTime));
UNUSED(formatDurationOrKeep(compactEndTimeStr, sizeof(compactEndTimeStr), pCfg->compactEndTime));
if (IS_SYS_DBNAME(dbName)) {
len += tsnprintf(buf2 + VARSTR_HEADER_SIZE, SHOW_CREATE_DB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE,
@ -428,13 +434,15 @@ static int32_t setCreateDBResultIntoDataBlock(SSDataBlock* pBlock, char* dbName,
"PRECISION '%s' REPLICA %d "
"WAL_LEVEL %d VGROUPS %d SINGLE_STABLE %d TABLE_PREFIX %d TABLE_SUFFIX %d TSDB_PAGESIZE %d "
"WAL_RETENTION_PERIOD %d WAL_RETENTION_SIZE %" PRId64
" KEEP_TIME_OFFSET %d ENCRYPT_ALGORITHM '%s' S3_CHUNKPAGES %d S3_KEEPLOCAL %dm S3_COMPACT %d",
" KEEP_TIME_OFFSET %dh ENCRYPT_ALGORITHM '%s' S3_CHUNKPAGES %d S3_KEEPLOCAL %dm S3_COMPACT %d "
"COMPACT_INTERVAL %s COMPACT_TIME_RANGE %s,%s COMPACT_TIME_OFFSET %"PRIi8 "h",
dbName, pCfg->buffer, pCfg->cacheSize, cacheModelStr(pCfg->cacheLast), pCfg->compression, durationStr,
pCfg->walFsyncPeriod, pCfg->maxRows, pCfg->minRows, pCfg->sstTrigger, keep0Str, keep1Str, keep2Str,
pCfg->pages, pCfg->pageSize, prec, pCfg->replications, pCfg->walLevel, pCfg->numOfVgroups,
1 == pCfg->numOfStables, hashPrefix, pCfg->hashSuffix, pCfg->tsdbPageSize, pCfg->walRetentionPeriod,
pCfg->walRetentionSize, pCfg->keepTimeOffset, encryptAlgorithmStr(pCfg->encryptAlgorithm),
pCfg->s3ChunkSize, pCfg->s3KeepLocal, pCfg->s3Compact);
pCfg->s3ChunkSize, pCfg->s3KeepLocal, pCfg->s3Compact, compactIntervalStr, compactStartTimeStr,
compactEndTimeStr, pCfg->compactTimeOffset);
if (pRetentions) {
len += tsnprintf(buf2 + VARSTR_HEADER_SIZE + len, SHOW_CREATE_DB_RESULT_FIELD2_LEN - VARSTR_HEADER_SIZE,
@ -726,7 +734,8 @@ static void appendTableOptions(char* buf, int32_t* len, SDbCfgInfo* pDbCfg, STab
}
}
static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, SDbCfgInfo* pDbCfg, char* tbName, STableCfg* pCfg, void* charsetCxt) {
static int32_t setCreateTBResultIntoDataBlock(SSDataBlock* pBlock, SDbCfgInfo* pDbCfg, char* tbName, STableCfg* pCfg,
void* charsetCxt) {
int32_t code = TSDB_CODE_SUCCESS;
QRY_ERR_RET(blockDataEnsureCapacity(pBlock, 1));
pBlock->info.rows = 1;
@ -905,7 +914,7 @@ static int32_t execAlterLocal(SAlterLocalStmt* pStmt) {
goto _return;
}
if (cfgCheckRangeForDynUpdate(tsCfg, pStmt->config, pStmt->value, false)) {
if (cfgCheckRangeForDynUpdate(tsCfg, pStmt->config, pStmt->value, false, CFG_ALTER_LOCAL)) {
return terrno;
}
@ -960,6 +969,12 @@ static int32_t buildLocalVariablesResultDataBlock(SSDataBlock** pOutput) {
goto _exit;
}
infoData.info.type = TSDB_DATA_TYPE_VARCHAR;
infoData.info.bytes = SHOW_LOCAL_VARIABLES_RESULT_FIELD5_LEN;
if (taosArrayPush(pBlock->pDataBlock, &infoData) == NULL) {
goto _exit;
}
*pOutput = pBlock;
_exit:
@ -1058,7 +1073,8 @@ static int32_t execShowCreateView(SShowCreateViewStmt* pStmt, SRetrieveTableRsp*
return code;
}
int32_t qExecCommand(int64_t* pConnId, bool sysInfoUser, SNode* pStmt, SRetrieveTableRsp** pRsp, int8_t biMode, void* charsetCxt) {
int32_t qExecCommand(int64_t* pConnId, bool sysInfoUser, SNode* pStmt, SRetrieveTableRsp** pRsp, int8_t biMode,
void* charsetCxt) {
switch (nodeType(pStmt)) {
case QUERY_NODE_DESCRIBE_STMT:
return execDescribe(sysInfoUser, pStmt, pRsp, biMode);

View File

@ -76,6 +76,9 @@ typedef struct SSysTableScanInfo {
STableListInfo* pTableListInfo;
SReadHandle* pHandle;
SStorageAPI* pAPI;
// file set iterate
struct SFileSetReader* pFileSetReader;
} SSysTableScanInfo;
typedef struct {
@ -2210,6 +2213,258 @@ static SSDataBlock* sysTableScanUserSTables(SOperatorInfo* pOperator) {
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
}
static int32_t doSetQueryFileSetRow() {
int32_t code = TSDB_CODE_SUCCESS;
int32_t lino = 0;
// TODO
_exit:
return code;
}
static SSDataBlock* sysTableBuildUserFileSets(SOperatorInfo* pOperator) {
int32_t code = TSDB_CODE_SUCCESS;
int32_t lino = 0;
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
SStorageAPI* pAPI = &pTaskInfo->storageAPI;
SSysTableScanInfo* pInfo = pOperator->info;
SSDataBlock* p = NULL;
// open cursor if not opened
if (pInfo->pFileSetReader == NULL) {
code = pAPI->tsdReader.fileSetReaderOpen(pInfo->readHandle.vnode, &pInfo->pFileSetReader);
QUERY_CHECK_CODE(code, lino, _end);
}
blockDataCleanup(pInfo->pRes);
int32_t numOfRows = 0;
const char* db = NULL;
int32_t vgId = 0;
pAPI->metaFn.getBasicInfo(pInfo->readHandle.vnode, &db, &vgId, NULL, NULL);
SName sn = {0};
char dbname[TSDB_DB_FNAME_LEN + VARSTR_HEADER_SIZE] = {0};
code = tNameFromString(&sn, db, T_NAME_ACCT | T_NAME_DB);
QUERY_CHECK_CODE(code, lino, _end);
code = tNameGetDbName(&sn, varDataVal(dbname));
QUERY_CHECK_CODE(code, lino, _end);
varDataSetLen(dbname, strlen(varDataVal(dbname)));
p = buildInfoSchemaTableMetaBlock(TSDB_INS_TABLE_FILESETS);
QUERY_CHECK_NULL(p, code, lino, _end, terrno);
code = blockDataEnsureCapacity(p, pOperator->resultInfo.capacity);
QUERY_CHECK_CODE(code, lino, _end);
char n[TSDB_TABLE_NAME_LEN + VARSTR_HEADER_SIZE] = {0};
int32_t ret = 0;
// loop to query each entry
for (;;) {
int32_t ret = pAPI->tsdReader.fileSetReadNext(pInfo->pFileSetReader);
if (ret) {
if (ret == TSDB_CODE_NOT_FOUND) {
// no more scan entry
break;
} else {
code = ret;
QUERY_CHECK_CODE(code, lino, _end);
}
}
// fill the data block
{
SColumnInfoData* pColInfoData;
int32_t index = 0;
// db_name
pColInfoData = taosArrayGet(p->pDataBlock, index++);
QUERY_CHECK_NULL(pColInfoData, code, lino, _end, terrno);
code = colDataSetVal(pColInfoData, numOfRows, db, false);
QUERY_CHECK_CODE(code, lino, _end);
// vgroup_id
pColInfoData = taosArrayGet(p->pDataBlock, index++);
QUERY_CHECK_NULL(pColInfoData, code, lino, _end, terrno);
code = colDataSetVal(pColInfoData, numOfRows, (char*)&vgId, false);
QUERY_CHECK_CODE(code, lino, _end);
// fileset_id
int32_t filesetId = 0;
code = pAPI->tsdReader.fileSetGetEntryField(pInfo->pFileSetReader, "fileset_id", &filesetId);
QUERY_CHECK_CODE(code, lino, _end);
pColInfoData = taosArrayGet(p->pDataBlock, index++);
QUERY_CHECK_NULL(pColInfoData, code, lino, _end, terrno);
code = colDataSetVal(pColInfoData, numOfRows, (char*)&filesetId, false);
QUERY_CHECK_CODE(code, lino, _end);
// start_time
int64_t startTime = 0;
code = pAPI->tsdReader.fileSetGetEntryField(pInfo->pFileSetReader, "start_time", &startTime);
QUERY_CHECK_CODE(code, lino, _end);
pColInfoData = taosArrayGet(p->pDataBlock, index++);
QUERY_CHECK_NULL(pColInfoData, code, lino, _end, terrno);
code = colDataSetVal(pColInfoData, numOfRows, (char*)&startTime, false);
QUERY_CHECK_CODE(code, lino, _end);
// end_time
int64_t endTime = 0;
code = pAPI->tsdReader.fileSetGetEntryField(pInfo->pFileSetReader, "end_time", &endTime);
QUERY_CHECK_CODE(code, lino, _end);
pColInfoData = taosArrayGet(p->pDataBlock, index++);
QUERY_CHECK_NULL(pColInfoData, code, lino, _end, terrno);
code = colDataSetVal(pColInfoData, numOfRows, (char*)&endTime, false);
QUERY_CHECK_CODE(code, lino, _end);
// total_size
int64_t totalSize = 0;
code = pAPI->tsdReader.fileSetGetEntryField(pInfo->pFileSetReader, "total_size", &totalSize);
QUERY_CHECK_CODE(code, lino, _end);
pColInfoData = taosArrayGet(p->pDataBlock, index++);
QUERY_CHECK_NULL(pColInfoData, code, lino, _end, terrno);
code = colDataSetVal(pColInfoData, numOfRows, (char*)&totalSize, false);
QUERY_CHECK_CODE(code, lino, _end);
// last_compact
int64_t lastCompacat = 0;
code = pAPI->tsdReader.fileSetGetEntryField(pInfo->pFileSetReader, "last_compact_time", &lastCompacat);
QUERY_CHECK_CODE(code, lino, _end);
pColInfoData = taosArrayGet(p->pDataBlock, index++);
QUERY_CHECK_NULL(pColInfoData, code, lino, _end, terrno);
code = colDataSetVal(pColInfoData, numOfRows, (char*)&lastCompacat, false);
QUERY_CHECK_CODE(code, lino, _end);
// shold_compact
bool shouldCompact = false;
code = pAPI->tsdReader.fileSetGetEntryField(pInfo->pFileSetReader, "should_compact", &shouldCompact);
QUERY_CHECK_CODE(code, lino, _end);
pColInfoData = taosArrayGet(p->pDataBlock, index++);
QUERY_CHECK_NULL(pColInfoData, code, lino, _end, terrno);
code = colDataSetVal(pColInfoData, numOfRows, (char*)&shouldCompact, false);
QUERY_CHECK_CODE(code, lino, _end);
// // details
// const char* details = NULL;
// code = pAPI->tsdReader.fileSetGetEntryField(pInfo->pFileSetReader, "details", &details);
// QUERY_CHECK_CODE(code, lino, _end);
// pColInfoData = taosArrayGet(p->pDataBlock, index++);
// QUERY_CHECK_NULL(pColInfoData, code, lino, _end, terrno);
// code = colDataSetVal(pColInfoData, numOfRows, (char*)&vgId, false);
// QUERY_CHECK_CODE(code, lino, _end);
}
// check capacity
if (++numOfRows >= pOperator->resultInfo.capacity) {
p->info.rows = numOfRows;
pInfo->pRes->info.rows = numOfRows;
code = relocateColumnData(pInfo->pRes, pInfo->matchInfo.pList, p->pDataBlock, false);
QUERY_CHECK_CODE(code, lino, _end);
code = doFilter(pInfo->pRes, pOperator->exprSupp.pFilterInfo, NULL);
QUERY_CHECK_CODE(code, lino, _end);
blockDataCleanup(p);
numOfRows = 0;
if (pInfo->pRes->info.rows > 0) {
break;
}
}
}
if (numOfRows > 0) {
p->info.rows = numOfRows;
pInfo->pRes->info.rows = numOfRows;
code = relocateColumnData(pInfo->pRes, pInfo->matchInfo.pList, p->pDataBlock, false);
QUERY_CHECK_CODE(code, lino, _end);
code = doFilter(pInfo->pRes, pOperator->exprSupp.pFilterInfo, NULL);
QUERY_CHECK_CODE(code, lino, _end);
blockDataCleanup(p);
numOfRows = 0;
}
blockDataDestroy(p);
p = NULL;
pInfo->loadInfo.totalRows += pInfo->pRes->info.rows;
_end:
if (code != TSDB_CODE_SUCCESS) {
qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
blockDataDestroy(p);
pTaskInfo->code = code;
pAPI->tsdReader.fileSetReaderClose(&pInfo->pFileSetReader);
T_LONG_JMP(pTaskInfo->env, code);
}
return (pInfo->pRes->info.rows == 0) ? NULL : pInfo->pRes;
}
static SSDataBlock* sysTableScanUserFileSets(SOperatorInfo* pOperator) {
int32_t code = TSDB_CODE_SUCCESS;
int32_t lino = 0;
SSysTableScanInfo* pInfo = pOperator->info;
SExecTaskInfo* pTaskInfo = pOperator->pTaskInfo;
SNode* pCondition = pInfo->pCondition;
if (pOperator->status == OP_EXEC_DONE) {
return NULL;
}
if (pInfo->readHandle.mnd != NULL) {
// do nothing on mnode
qTrace("This operator do nothing on mnode, task id:%s", GET_TASKID(pTaskInfo));
return NULL;
} else {
#if 0
if (pInfo->showRewrite == false) {
if (pCondition != NULL && pInfo->pIdx == NULL) {
SSTabFltArg arg = {
.pMeta = pInfo->readHandle.vnode, .pVnode = pInfo->readHandle.vnode, .pAPI = &pTaskInfo->storageAPI};
SSysTableIndex* idx = taosMemoryMalloc(sizeof(SSysTableIndex));
QUERY_CHECK_NULL(idx, code, lino, _end, terrno);
idx->init = 0;
idx->uids = taosArrayInit(128, sizeof(int64_t));
QUERY_CHECK_NULL(idx->uids, code, lino, _end, terrno);
idx->lastIdx = 0;
pInfo->pIdx = idx; // set idx arg
int flt = optSysTabFilte(&arg, pCondition, idx->uids);
if (flt == 0) {
pInfo->pIdx->init = 1;
SSDataBlock* blk = sysTableBuildUserTablesByUids(pOperator);
return blk;
} else if ((flt == -1) || (flt == -2)) {
qDebug("%s failed to get sys table info by idx, scan sys table one by one", GET_TASKID(pTaskInfo));
}
} else if (pCondition != NULL && (pInfo->pIdx != NULL && pInfo->pIdx->init == 1)) {
SSDataBlock* blk = sysTableBuildUserTablesByUids(pOperator);
return blk;
}
}
#endif
return sysTableBuildUserFileSets(pOperator);
}
_end:
if (code != TSDB_CODE_SUCCESS) {
qError("%s failed at line %d since %s", __func__, lino, tstrerror(code));
pTaskInfo->code = code;
T_LONG_JMP(pTaskInfo->env, code);
}
return NULL;
}
static int32_t getSysTableDbNameColId(const char* pTable) {
// if (0 == strcmp(TSDB_INS_TABLE_INDEXES, pTable)) {
// return 1;
@ -2309,6 +2564,8 @@ static int32_t doSysTableScanNext(SOperatorInfo* pOperator, SSDataBlock** ppRes)
pBlock = sysTableScanUserSTables(pOperator);
} else if (strncasecmp(name, TSDB_INS_DISK_USAGE, TSDB_TABLE_FNAME_LEN) == 0) {
pBlock = sysTableScanUsage(pOperator);
} else if (strncasecmp(name, TSDB_INS_TABLE_FILESETS, TSDB_TABLE_FNAME_LEN) == 0) {
pBlock = sysTableScanUserFileSets(pOperator);
} else { // load the meta from mnode of the given epset
pBlock = sysTableScanFromMNode(pOperator, pInfo, name, pTaskInfo);
}
@ -2529,7 +2786,8 @@ int32_t createSysTableScanOperatorInfo(void* readHandle, SSystemTableScanPhysiNo
QUERY_CHECK_CODE(code, lino, _error);
if (strncasecmp(name, TSDB_INS_TABLE_TABLES, TSDB_TABLE_FNAME_LEN) == 0 ||
strncasecmp(name, TSDB_INS_TABLE_TAGS, TSDB_TABLE_FNAME_LEN) == 0) {
strncasecmp(name, TSDB_INS_TABLE_TAGS, TSDB_TABLE_FNAME_LEN) == 0 ||
strncasecmp(name, TSDB_INS_TABLE_FILESETS, TSDB_TABLE_FNAME_LEN) == 0) {
pInfo->readHandle = *(SReadHandle*)readHandle;
} else {
if (tsem_init(&pInfo->ready, 0, 0) != TSDB_CODE_SUCCESS) {

View File

@ -2450,13 +2450,21 @@ static int32_t doSaveCurrentVal(SqlFunctionCtx* pCtx, int32_t rowIndex, int64_t
SFirstLastRes* pInfo = GET_ROWCELL_INTERBUF(pResInfo);
if (IS_VAR_DATA_TYPE(type)) {
pInfo->bytes = varDataTLen(pData);
if (type == TSDB_DATA_TYPE_JSON) {
pInfo->bytes = getJsonValueLen(pData);
} else {
pInfo->bytes = varDataTLen(pData);
}
}
(void)memcpy(pInfo->buf, pData, pInfo->bytes);
if (pkData != NULL) {
if (IS_VAR_DATA_TYPE(pInfo->pkType)) {
pInfo->pkBytes = varDataTLen(pkData);
if (pInfo->pkType == TSDB_DATA_TYPE_JSON) {
pInfo->pkBytes = getJsonValueLen(pkData);
} else {
pInfo->pkBytes = varDataTLen(pkData);
}
}
(void)memcpy(pInfo->buf + pInfo->bytes, pkData, pInfo->pkBytes);
pInfo->pkData = pInfo->buf + pInfo->bytes;
@ -2985,7 +2993,11 @@ static int32_t doSaveLastrow(SqlFunctionCtx* pCtx, char* pData, int32_t rowIndex
pInfo->isNull = false;
if (IS_VAR_DATA_TYPE(pInputCol->info.type)) {
pInfo->bytes = varDataTLen(pData);
if (pInputCol->info.type == TSDB_DATA_TYPE_JSON) {
pInfo->bytes = getJsonValueLen(pData);
} else {
pInfo->bytes = varDataTLen(pData);
}
}
(void)memcpy(pInfo->buf, pData, pInfo->bytes);
@ -2994,7 +3006,11 @@ static int32_t doSaveLastrow(SqlFunctionCtx* pCtx, char* pData, int32_t rowIndex
if (pCtx->hasPrimaryKey && !colDataIsNull_s(pkCol, rowIndex)) {
char* pkData = colDataGetData(pkCol, rowIndex);
if (IS_VAR_DATA_TYPE(pInfo->pkType)) {
pInfo->pkBytes = varDataTLen(pkData);
if (pInfo->pkType == TSDB_DATA_TYPE_JSON) {
pInfo->pkBytes = getJsonValueLen(pkData);
} else {
pInfo->pkBytes = varDataTLen(pkData);
}
}
(void)memcpy(pInfo->buf + pInfo->bytes, pkData, pInfo->pkBytes);
pInfo->pkData = pInfo->buf + pInfo->bytes;
@ -5874,7 +5890,11 @@ void modeFunctionCleanupExt(SqlFunctionCtx* pCtx) {
static int32_t saveModeTupleData(SqlFunctionCtx* pCtx, char* data, SModeInfo* pInfo, STuplePos* pPos) {
if (IS_VAR_DATA_TYPE(pInfo->colType)) {
(void)memcpy(pInfo->buf, data, varDataTLen(data));
if (pInfo->colType == TSDB_DATA_TYPE_JSON) {
(void)memcpy(pInfo->buf, data, getJsonValueLen(data));
} else {
(void)memcpy(pInfo->buf, data, varDataTLen(data));
}
} else {
(void)memcpy(pInfo->buf, data, pInfo->colBytes);
}
@ -5884,7 +5904,16 @@ static int32_t saveModeTupleData(SqlFunctionCtx* pCtx, char* data, SModeInfo* pI
static int32_t doModeAdd(SModeInfo* pInfo, int32_t rowIndex, SqlFunctionCtx* pCtx, char* data) {
int32_t code = TSDB_CODE_SUCCESS;
int32_t hashKeyBytes = IS_STR_DATA_TYPE(pInfo->colType) ? varDataTLen(data) : pInfo->colBytes;
int32_t hashKeyBytes;
if (IS_VAR_DATA_TYPE(pInfo->colType)) {
if (pInfo->colType == TSDB_DATA_TYPE_JSON) {
hashKeyBytes = getJsonValueLen(data);
} else {
hashKeyBytes = varDataTLen(data);
}
} else {
hashKeyBytes = pInfo->colBytes;
}
SModeItem* pHashItem = (SModeItem*)taosHashGet(pInfo->pHash, data, hashKeyBytes);
if (pHashItem == NULL) {
@ -6769,14 +6798,32 @@ static void doSaveRateInfo(SRateInfo* pRateInfo, bool isFirst, int64_t ts, char*
pRateInfo->firstValue = v;
pRateInfo->firstKey = ts;
if (pRateInfo->firstPk) {
int32_t pkBytes = IS_VAR_DATA_TYPE(pRateInfo->pkType) ? varDataTLen(pk) : pRateInfo->pkBytes;
int32_t pkBytes;
if (IS_VAR_DATA_TYPE(pRateInfo->pkType)) {
if (pRateInfo->pkType == TSDB_DATA_TYPE_JSON) {
pkBytes = getJsonValueLen(pk);
} else {
pkBytes = varDataTLen(pk);
}
} else {
pkBytes = pRateInfo->pkBytes;
}
(void)memcpy(pRateInfo->firstPk, pk, pkBytes);
}
} else {
pRateInfo->lastValue = v;
pRateInfo->lastKey = ts;
if (pRateInfo->lastPk) {
int32_t pkBytes = IS_VAR_DATA_TYPE(pRateInfo->pkType) ? varDataTLen(pk) : pRateInfo->pkBytes;
int32_t pkBytes;
if (IS_VAR_DATA_TYPE(pRateInfo->pkType)) {
if (pRateInfo->pkType == TSDB_DATA_TYPE_JSON) {
pkBytes = getJsonValueLen(pk);
} else {
pkBytes = varDataTLen(pk);
}
} else {
pkBytes = pRateInfo->pkBytes;
}
(void)memcpy(pRateInfo->lastPk, pk, pkBytes);
}
}

View File

@ -99,8 +99,8 @@ static int32_t initWktRegex(pcre2_code **ppRegex, pcre2_match_data **ppMatchData
return terrno;
}
(void)sprintf(
wktPatternWithSpace,
(void)tsnprintf(
wktPatternWithSpace, 4 * 1024,
"^( *)point( *)z?m?( *)((empty)|(\\(( *)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "
"*)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?){1,3}( *)\\)))|linestring( *)z?m?( "
"*)((empty)|(\\(( *)(([-+]?[0-9]+\\.?[0-9]*)|([-+]?[0-9]*\\.?[0-9]+))(e[-+]?[0-9]+)?(( "

Some files were not shown because too many files have changed in this diff Show More