Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical...

52
Data Warehouse Service Troubleshooting Issue 06 Date 2020-11-16 HUAWEI TECHNOLOGIES CO., LTD.

Transcript of Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical...

Page 1: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

Data Warehouse Service

Troubleshooting

Issue 06

Date 2020-11-16

HUAWEI TECHNOLOGIES CO., LTD.

Page 2: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

Copyright © Huawei Technologies Co., Ltd. 2021. All rights reserved.

No part of this document may be reproduced or transmitted in any form or by any means without priorwritten consent of Huawei Technologies Co., Ltd. Trademarks and Permissions

and other Huawei trademarks are trademarks of Huawei Technologies Co., Ltd.All other trademarks and trade names mentioned in this document are the property of their respectiveholders. NoticeThe purchased products, services and features are stipulated by the contract made between Huawei andthe customer. All or part of the products, services and features described in this document may not bewithin the purchase scope or the usage scope. Unless otherwise specified in the contract, all statements,information, and recommendations in this document are provided "AS IS" without warranties, guaranteesor representations of any kind, either express or implied.

The information in this document is subject to change without notice. Every effort has been made in thepreparation of this document to ensure accuracy of the contents, but all statements, information, andrecommendations in this document do not constitute a warranty of any kind, express or implied.

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. i

Page 3: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

Contents

1 Database Connection..............................................................................................................11.1 Database Cannot Be Connected Using the gsql Client.............................................................................................. 11.2 Failed to Ping the Access Address of a Cluster............................................................................................................. 31.3 An Error Indicating Too Many Client Connections Is Reported When a User Connects to aGaussDB(DWS) Database............................................................................................................................................................41.4 How to Unlock an Account.................................................................................................................................................. 5

2 Data Import and Export......................................................................................................... 72.1 Data Import and Export Faults with GDS....................................................................................................................... 72.2 When a Common User Executes or Deletes the Statement for Creating a GDS/OBS Foreign Table, anError Is Reported, Indicating That the User Does Not Have the Permission or Has Insufficient Permission............................................................................................................................................................................................................ 132.3 During Execution of the SQL Statement for Creating an OBS Foreign Table, OBS Access Is Denied..... 132.4 Failed to Create a GDS Foreign Table and An Error Was Reported Indicating That ROUNDROBIN IsNot Supported............................................................................................................................................................................... 142.5 Disk Usage Increases After Data Fails to Be Imported Using GDS......................................................................152.6 Data to Be Imported Contains Chinese When the DLF Service Is Used to Create a GaussDB(DWS)Foreign Table................................................................................................................................................................................. 152.7 "ERROR: invalid byte sequence for encoding 'UTF8': 0x00" Is Reported When Data Is Imported toGaussDB(DWS) Using COPY FROM.......................................................................................................................................162.8 Failed to Import an MRS Data Source Through a Foreign Table......................................................................... 16

3 Database Use..........................................................................................................................183.1 After the Permission for Querying Tables in a Schema Is Granted to a User, the User Still CannotQuery the Tables.......................................................................................................................................................................... 183.2 "Connection reset by peer" Is Displayed When a User Executes an SQL Statement.................................... 193.3 "failed to find conversion function from unknown to text" Is Displayed When a User Executes theSELECT Statement........................................................................................................................................................................193.4 Is a Field Name Enclosed with Double Quotation Marks in an SQL Statement Case-sensitive?............. 203.5 VARCHAR(18) Cannot Store Eight Chinese Characters........................................................................................... 203.6 The Byte Type Is Returned After a Table Field of the Character Type Is Read In Java................................. 213.7 When the ODBC Driver of GaussDB(DWS) Is Used, Content of Fields of the Character Type in the SQLQuery Result Is Truncated......................................................................................................................................................... 213.8 Failed to Execute "merge into update" for Multiple Tables...................................................................................223.9 "ERROR:start value of partition 'XX' NOT EQUAL up-boundary of last partition." Is Displayed WhenOperations Related to Table Partitions Are Performed.................................................................................................. 223.10 Different Data Is Displayed for the Same Table Queried By Multiple Users.................................................23

Data Warehouse ServiceTroubleshooting Contents

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. ii

Page 4: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

3.11 When a User Specifies Only an Index Name to Modify the Index, A Message Indicating That theIndex Does Not Exist Is Displayed.......................................................................................................................................... 243.12 Reindexing Fails.................................................................................................................................................................. 253.13 An Error Occurs During the Integer Conversion...................................................................................................... 253.14 A View Failed to Be Queried...........................................................................................................................................253.15 An Error Is Reported When Data is Inserted or Updated, Indicating That the Distribution Key CannotBe Updated.....................................................................................................................................................................................263.16 DROP TABLE Fails to Be Executed................................................................................................................................ 263.17 Failed to Delete a Database and an Error Was Reported Indicating That a Session Is Connected tothe Database................................................................................................................................................................................. 273.18 Failed to Run the "create extension" Command and An Error Indicating No Permission Was Reported............................................................................................................................................................................................................ 283.19 Checking Lock Waits......................................................................................................................................................... 283.20 Global SQL Query...............................................................................................................................................................293.21 What Should I Do If an Authentication or Mechanisms Error Is Reported When Connecting toGaussDB(DWS)?........................................................................................................................................................................... 31

4 Database Performance and Resources............................................................................. 324.1 A Data Warehouse Cluster Becomes Read-Only and Is Locked, so Data Cannot be Written to It.......... 324.2 Slow Response to a Query Statement........................................................................................................................... 334.3 Analyzing the Status of a Query Statement................................................................................................................344.4 Analyzing Whether a Query Statement Is Blocked...................................................................................................354.5 The Database Does Not Respond and the SQL Statement Is Quickly Terminated........................................364.6 Forcibly Terminating a Session......................................................................................................................................... 364.7 Low Query Efficiency........................................................................................................................................................... 374.8 SQL Execution Is Slow with Low Performance and Sometimes Does Not End After a Long Period ofTime.................................................................................................................................................................................................. 384.9 It Takes a Long Time to Execute SQL Statements That Could be Executed Quickly Before.......................394.10 During SQL Execution, a Table Deadlock Occurs and An Error Stating LOCK_WAIT_TIMEOUT IsReported.......................................................................................................................................................................................... 404.11 An Error Indicating Insufficient Memory Is Reported During SQL Execution................................................404.12 Writing Data to GaussDB(DWS) Is Slow and Client Data Is Stacked.............................................................. 414.13 Error LOCK_WAIT_TIMEOUT Is Reported When VACUUM FULL Is Executed................................................424.14 VACUUM Is Executed After Table Data Deletion, But the Space Is Not Released.......................................424.15 Table Size Does not Change After VACUUM FULL Is Executed on the Table................................................434.16 Memory Overflow Occurs in a Cluster........................................................................................................................43

5 Database Parameter Modification.................................................................................... 455.1 How to Change a Database's Default Time Zone When the Database Time Is Different from theSystem Time...................................................................................................................................................................................45

A Change History...................................................................................................................... 47

Data Warehouse ServiceTroubleshooting Contents

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. iii

Page 5: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

1 Database Connection

1.1 Database Cannot Be Connected Using the gsqlClient

SymptomUsers fail to connect to the database by running gsql on the client.

Cause Analysis● The number of system connections exceeds the upper threshold. The

following error information is displayed:gsql -d human_resource user1 -p 8000gsql: FATAL: sorry, too many clients already

● Users do not have the access permission for the database. The following errorinformation is displayed.gsql -d human_resource user1 -p 8000gsql: FATAL: permission denied for database "human_resource"DETAIL: User does not have CONNECT privilege.

● The network connection fails.

Solution● The number of system connections exceeds the upper limit.

Contact Huawei technical support.You can check the number of connections as described in Table 1-1.

Data Warehouse ServiceTroubleshooting 1 Database Connection

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 1

Page 6: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

Table 1-1 Viewing the numbers of connections

Description Command

View the upper limitof a user'sconnections.

Run the following command to view the upperlimit of user user1's connections. -1 indicates thatno connection upper limit is set for user user1.SELECT ROLNAME,ROLCONNLIMIT FROM PG_ROLES WHERE ROLNAME='user1'; rolname | rolconnlimit---------+-------------- user1 | -1(1 row)

View the number ofconnections that havebeen used by aspecified user.

Run the following command to view the number ofconnections that have been used by user user1. 1indicates the number of connections that havebeen used by user user1.SELECT COUNT(*) FROM V$SESSION WHERE USERNAME='user1';

count------- 1(1 row)

View the upper limitof connections todatabase.

Run the following command to view the upperlimit of connections used by postgres. -1 indicatesthat no upper limit is set for the number ofconnections that have been used by postgres.SELECT DATNAME,DATCONNLIMIT FROM PG_DATABASE WHERE DATNAME='postgres';

datname | datconnlimit----------+-------------- postgres | -1(1 row)

View the number ofconnections that havebeen used by adatabase.

Run the following command to view the number ofconnections that have been used by postgres. 1indicates the number of connections that havebeen used by postgres.SELECT COUNT(*) FROM PG_STAT_ACTIVITY WHERE DATNAME='postgres'; count ------- 1(1 row)

View the totalnumber ofconnections that havebeen used by allusers.

Run the following command to view the number ofconnections that have been used by all users:SELECT COUNT(*) FROM V$SESSION; count------- 10(1 row)

● Users do not have the access permission to the database.

a. Connect to the database as user dbadmin.gsql -d human_resource -U dbadmin -p 8000

b. Grant the users with the access permission to the database.

Data Warehouse ServiceTroubleshooting 1 Database Connection

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 2

Page 7: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

GRANT CONNECT ON DATABASE human_resource TO user1;

NO TE

Common misoperations may also cause a database connection failure, forexample, entering an incorrect database name, user name, or password. In thiscase, the client tool will display the corresponding error messages.gsql -d human_resource -p 8000gsql: FATAL: database "human_resource" does not exist

gsql -d human_resource -U user1 -W gauss@789 -p 8000gsql: FATAL: Invalid username/password,login denied.

● The network connection fails.Check the network connection between the client and the database server. Ifyou cannot ping from the client to the database server, the networkconnection is abnormal. Contact Huawei technical support.ping -c 4 10.10.10.1PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data.From 10.10.10.1: icmp_seq=2 Destination Host UnreachableFrom 10.10.10.1 icmp_seq=2 Destination Host UnreachableFrom 10.10.10.1 icmp_seq=3 Destination Host UnreachableFrom 10.10.10.1 icmp_seq=4 Destination Host Unreachable--- 10.10.10.1 ping statistics ---4 packets transmitted, 0 received, +4 errors, 100% packet loss, time 2999ms

1.2 Failed to Ping the Access Address of a Cluster

Symptom

The client host cannot ping the access address of a data warehouse cluster.

Possible Causes● The network is disconnected.

If the client host connects to a data warehouse cluster using the cluster'sprivate IP address, check whether the client host and the data warehousecluster are in the same VPC and subnet. If they are not in the same VPC orsubnet, the network is disconnected.

● The ping command is disabled in the security group rule.The cluster's access address can be pinged only when the ICMP port isenabled in the inbound rule of the cluster's security group. By default, onlythe database port is enabled in the security group automatically createdduring cluster creation. The default database port is 8000.If the ICMP port is enabled in the inbound rule of the security group, checkwhether the source address in the inbound rule covers the IP address of theclient host. If not, the client host cannot ping the cluster.

Handling Procedure● The network is disconnected.

If the client host connects to the data warehouse cluster using the cluster'sprivate IP address, apply for another ECS as the client host. The ECS must bein the same VPC and subnet as the data warehouse cluster.

Data Warehouse ServiceTroubleshooting 1 Database Connection

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 3

Page 8: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

● The ping command is disabled in the security group rule.

View the cluster's security group rule to check whether it enables the ICMPport for the client host's IP address. Detailed operations are as follows:

a. Log in to the GaussDB(DWS) management console.

b. On the Cluster Management page, find the target cluster and click itsname. The Basic Information page is displayed.

c. Locate the Security Group parameter and click the security group nameto switch to the Security Groups page on the VPC console.

d. Click the Inbound Rules tab and check whether an inbound rule thatenables the ICMP port exists. If such an inbound rule does not exist, clickAdd Rule to add one.

▪ Protocol & Port: Select ICMP and All.

▪ Source: Select IP address, and enter the IP address and subnet maskof the client host. 0.0.0.0/0 indicates any IP address.

Figure 1-1 Inbound rule

e. Click OK.

1.3 An Error Indicating Too Many Client Connections IsReported When a User Connects to a GaussDB(DWS)Database

Symptom

An error indicating too many client connections is reported when a user connectsto a GaussDB(DWS) database.

● When a user uses an SQL client tool, such as gsql, to connect to a database,the following error information is displayed:FATAL: Already too many clients, active/non-active/reserved: 5/508/3.

● When the user uses multiple clients to concurrently connect to the database,the following error information is displayed:[2019/12/25 08:30:35] [ERROR] ERROR: pooler: failed to create connections in parallel mode for thread 140530192938752, Error Message: FATAL: dn_6001_6002: Too many clients already, active/non-active: 468/63.FATAL: dn_6001_6002: Too many clients already, active/non-active: 468/63.

Data Warehouse ServiceTroubleshooting 1 Database Connection

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 4

Page 9: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

Possible Causes● The number of database connections exceeds the upper limit.

In the error information, the value of non-active indicates the number of idleconnections. For example, if the value of non-active is 508, there are 508 idleconnections.

● The maximum number of connections for a user has been set during usercreation.

Query the number of database connections. If the number of connectionsdoes not reach the upper limit, the possible cause is that the maximumnumber of connections has been set when the user is created.

Handling Procedure

To resolve this problem, perform the following steps:

1. Release all non-active connections temporarily.SELECT PG_TERMINATE_BACKEND(pid) from pg_stat_activity WHERE state='idle';

2. Check whether the application does not actively release the connections. Inthis case, optimize the code to release the connections properly.

3. On the GaussDB(DWS) management console, set parametersession_timeout, which controls the timeout period of idle sessions. After anidle session's timeout period exceeds the specified value, the serverautomatically closes the connection.

The default value of parameter session_timeout is 600 seconds. The value 0indicates that the timeout limit is disabled. You are not advised to setsession_timeout to 0.

The procedure for setting parameter session_timeout is as follows:

a. Log in to the GaussDB(DWS) management console.

b. In the navigation tree on the left, click Cluster Management.

c. In the cluster list, find the target cluster and click its name. The BasicInformation page is displayed.

d. Click the Parameter Modifications tab and modify the value ofparameter session_timeout. Then click Save.

e. In the Modification Preview dialog box, confirm the modification andclick Save.

4. If the maximum number of connections cannot meet service requirements,you can submit a service ticket to technical support to adjust the maximumnumber.

1.4 How to Unlock an Account

Symptom

An account is locked and an error stating "The account has been locked" isreported when the account attempts to access a cluster.

Data Warehouse ServiceTroubleshooting 1 Database Connection

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 5

Page 10: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

Possible CausesWhen a user uses an account to access the database in a cluster, if the number ofconsecutive incorrect password attempts reaches the upper limit (10 by default),the account will be locked.

Method for Unlocking the Administrator (dbadmin by Default)You can log in to the GaussDB(DWS) management console to reset theadministrator password. After the password is reset, the account is automaticallyunlocked. On the GaussDB(DWS) management console, go to the ClusterManagement page, locate the required cluster, and choose More > ResetPassword.

Method for Unlocking Common Database UsersConnect to the database as the administrator (dbadmin by default) and run thefollowing command to unlock a database user (replace user_name with the nameof the locked user):

ALTER USER user_name ACCOUNT UNLOCK;

Setting the Number of Login FailuresYou can set the maximum number of incorrect password attempts by configuringthe failed_login_attempts parameter on the Parameter Modifications tab of thecluster. When failed_login_attempts is set to 0, the number of incorrect passwordattempts is unlimited. You are not advised to set failed_login_attempts to 0.

Perform the following steps:

1. Log in to the GaussDB(DWS) management console.2. In the navigation tree on the left, click Cluster Management.3. In the cluster list, find the target cluster and click the cluster name. The Basic

Information page is displayed.4. Enter the Parameter Modifications tab page, locate the

failed_login_attempts parameter, change its value, and click Save. Afterconfirming the modification click Save.

Data Warehouse ServiceTroubleshooting 1 Database Connection

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 6

Page 11: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

2 Data Import and Export

2.1 Data Import and Export Faults with GDSWhen GDS is used to import or export data, character set problems may occur,especially when data is migrated across databases of different types or differentencoding types. As a result, data import fails, severely blocking data migration andother onsite operations. A character set is in fact a module of an entire platform.However, GDS import and export are interfaces of data operations, whereproblems are often first exposed, incurring criticism easily. Therefore, a lot of work(such as error tables) has been done with GDS to make the character set morecompatible, to ensure that the import process is not interrupted. However, thelocalization work (including work on the character set) is not carried out in aunified manner, thus incompatibility problems still occur on site frequently.

This topic explains basics about character sets, and summarizes common faultsand solutions for your reference.

Locale Support

Locale support refers to cultural preference compliance of applications, includingalphabetic, sorting, and number formats. A locale is automatically initialized whena database is created using initdb. By default, initdb initializes the databasebased on the locale of its execution environment. The locale is preset in thesystem. You can use initdb –locale=xx to specify another locale.

If you need to use the rules of multiple locales, you can use the following localecategories to control the localization rules. These categories are converted toinitdb options, indicating locale selections of a particular category.

Table 2-1 Locale support

Category Description

LC_COLLATE Defines character-collation or string-collation information.

Data Warehouse ServiceTroubleshooting 2 Data Import and Export

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 7

Page 12: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

Category Description

LC_CTYPE Defines character classification, forexample, what counts as a character,case conversion, and others.

LC_MESSAGES Defines the language used bymessages.

LC_MONETARY Defines formatting for monetarynumeric information.

LC_NUMERIC Defines formatting for non-monetarynumeric information.

LC_TIME Defines formatting for time and dateinformation.

If you want the system to behave like there is no locale support, you can use the Clocale or its equivalent the POSIX locale. Using non-C or non-POSIX locales mayaffect the performance, because it slows character processing and prevents theuse of normal indexes in the LIKE clause. Therefore, use non-C or non-POSIXlocales only when they are required.

Some locale category values must be fixed upon the creation of a database.Different databases can use different value settings. However, once a database iscreated, these locale category values cannot be changed in the database. Forexample, LC_COLLATE and LC_CTYPE require fixed values upon the creation of adatabase. These two locale categories determine the collation of indexes, so theymust be fixed. Otherwise indexes in the text column will break down. Defaultvalues of these two locale categories are set when initdb is running, and will beused to create new databases, unless they are otherwise specified by the CREATEDATABASE command. Other locale category values can be changed at any time.To change a locale category value, set it to the configuration parameters of theserver named the same as the locale category. The values chosen by initdb arewritten to the postgresql.conf file as the default values for the server startup. Ifyou delete these values from the postgresql.conf file, the server will inherit thesettings from its execution environment.

In particular, the locale setting affects the following SQL features:

● Data collation in the process of queries that use ORDER BY or a standardcomparison operator on text data

● UPPER, LOWER, and INITCAP functions● Pattern matching operators (such as LIKE, SIMILAR TO, and POSIX style

regular expressions), case-insensitive matching, and character classificationusing character regular expressions

● TO_CHAR functions

Therefore, inconsistent query result sets in these scenarios are probably caused bythe character set. A typical case occurred at the Shanghai Stock Exchange site,where uncommon Chinese characters are imported to the database in the GBK

Data Warehouse ServiceTroubleshooting 2 Data Import and Export

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 8

Page 13: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

encoding format. As a result, the LIKE query result set is inconsistent with resultsets of equivalent queries.

Collation SupportThis feature allows you to specify the data collation and character classificationbehavior for each column or even each operation, which relaxes the restrictionthat the LC_COLLATE and LC_CTYPE settings cannot be changed since thedatabase is created.

The collation of an expression can be a default rule that matches the locale of thedatabase. The collation rule can also be uncertain. In this case, the collationoperation and other operations that depend on the collation rule will fail.

When the database system must perform collation or character classification, ituses the collation rule of the input expression. This happens when you use theORDER BY clause and functions, or when you call an operator (such as <). Thecollation rule used by the ORDER BY clause is the collation rule of the sort key.The collation rule used by a function or an operator call is derived from theirparameters. In addition to comparison operators, functions (such as LOWER,UPPER, and INITCAP) that convert between uppercase and lowercase letters willrefer to the collation rule. Pattern matching operators and TO_CHAR relatedfunctions also need to refer to the collation rule.

For a function or an operator call, it checks the collation parameter when thespecified operation is performed, to obtain the collation rule. If the result of thefunction or operator call is a sortable data set, the collation rule is also used bythe function or operator expression in case a peripheral expression requires thecollation rule of the function or operator expression.

The collation derivation of an expression can be implicit or explicit. This distinctiondetermines how collations are organized when multiple different collations appearin an expression. An explicit collation derivation occurs when a COLLATE clause isused. All other collation derivations are implicit. When multiple collations need tobe organized, for example in a function call, the following rules are used:

1. If any input expression has an explicit collation derivation, all explicitly derivedcollations among the input expressions must be the same, otherwise an erroris raised. If any explicitly derived collation exists, it is the result of the collationcombination.

2. Otherwise, all input expressions must have the same implicit collationderivation or the default collation. If any non-default collation exists, that isthe result of the collation combination. Otherwise, the result is the defaultcollation.

3. If there are conflicting non-default implicit collations among the inputexpressions, the combination is deemed to have indeterminate collation. Thisis not an error unless the particular function called requires knowledge of thecollation it should apply. If it does, an error will be raised at runtime.

Character Set SupportThe character set support in PostgreSQL enables you to store text in variouscharacter sets (also called encodings), including single-byte character sets such asthe ISO 8859 series and multiple-byte character sets such as EUC (Extended Unix

Data Warehouse ServiceTroubleshooting 2 Data Import and Export

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 9

Page 14: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

Code), UTF-8, and Mule internal code. MPPDB mainly uses the GBK, UTF-8, andLATIN1 character sets. All supported character sets can be used transparently byclients, but a few are not supported for use within the server (that is, as a server-side encoding. GBK encoding in PostgreSQL database is only client-side encoding,not server-side encoding. MPPDB introduces GBK to server-side encoding, which isthe root cause of many problems). The default character set is selected whileinitializing your PostgreSQL database using initdb. It can be overridden when youcreate a database, so you can have multiple databases each with a differentcharacter set. An important restriction is that each database's character set mustbe compatible with the database's LC_CTYPE (character classification) andLC_COLLATE (string sort order) locale settings. For the C or POSIX locale, anycharacter set is allowed, but for other locales there is only one character set thatcan work correctly. On Windows, however, UTF-8 encoding can be used with anylocale.

The SQL_ASCII setting behaves considerably differently from the other settings.When the server character set is SQL_ASCII, the server interprets byte values 0-127according to the ASCII standard. Byte values 128-255 are deemed as uninterpretedcharacters. No encoding conversion will be done if the setting is SQL_ASCII.Therefore, this setting is not a declaration that a specific encoding is in use, as adeclaration of ignorance about the encoding. In most cases, if you are workingwith non-ASCII data, it is unwise to use the SQL_ASCII setting because PostgreSQLis unable to help you convert or validate non-ASCII characters.

Which encoding is supported by a database system is determined by three aspects:database server support, database access interface support, and client support.

● Database server supportDatabase server support means a server can receive character set in a certainencoding format and store the character set, and it can also provide thecharacter set (including identifiers and character field values) to the client. Inaddition, it can convert the characters to other encoding formats, for example,from UTF-8 to GBK.You can specify the database server encoding when creating a database:CREATE DATABASE ... ENCODING ... // ASCII, UTF-8, EUC_CN, and more aresupported.You can check database encoding: SHOW server_encoding

● Database access interface supportDatabase access interface support means that the API must be able tocorrectly read and write the characters of a certain encoding format, withoutany data loss or distortion. The following uses the JDBC interface as anexample:The JDBC interface sets client_encoding based on the file.encoding of JVM: setclient_encoding to file_encodingThen converts a string to a byte stream encoded in the client_encodingformat, and send the byte stream to the server. Prototype:String.getBytes(client_encoding).After receiving the byte stream from the server, the client uses client_encodingto construct a string object as the return value of getString and send theobject to the application. Prototype: String(byte[], ..., client_encoding).

● Client support

Data Warehouse ServiceTroubleshooting 2 Data Import and Export

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 10

Page 15: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

Client support means that the client can display the characters that are readfrom the database and can submit the characters to the server.You can specify the client encoding of a session: SET CLIENT_ENCODINGTO'value'You can check database encoding: Show client_encoding

Solutions to Character Set Problems During GDS Import and Export(Constantly Updated)

Problem 1: 0x00 characters cannot be saved to the database. ERROR: invalidbyte sequence for encoding "UTF8": 0x00

Cause: The PostgreSQL database does not allow 0x00 characters in text data. Thisis a baseline problem. Other databases do not have this problem.

Solution:

1. Replace 0x00 characters.2. The COPY command and GDS both have the compatible_illegal_chars

option. If this option is enabled (the COPY command and GDS foreign tablecan be altered), single-byte or multi-byte invalid characters will be replacedwith spaces or question marks (?). In this way, the data can be importedsuccessfully, but the original data is changed.

3. Create a database whose encoding is SQL_ASCII and set client_encoding toSQL_ASCII (you can set it using the COPY command or in the GDS foreigntable). In this case, special processing and conversion of the character set canbe avoided, all sorting, comparison, and processing related to the library areprocessed as single bytes.

Problem 2: GBK characters cannot be imported to the UTF-8 library.

Cause: The function for converting GBK to UTF-8 is missing.

Solution: Currently, the missing conversion function is added to the R8C10 version,which contains 106 characters. The function will be synchronized to the R7C10delivery version as soon as possible. The following figure lists the characters:

Data Warehouse ServiceTroubleshooting 2 Data Import and Export

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 11

Page 16: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

Problem 3: GBK escape character \ (0x5C) problem

Cause: The server-side GBK encoding has many problems, which violates thePostgreSQL design principles. The ASCII code cannot be used as a part of a multi-byte character (the first bit of each byte of a multi-byte character must be 1). Ifthis principle is not followed, errors may occur. In the following example, the GBKmulti-byte character may use \ as the second character.

/* Else, it's the traditional escaped style */for (bc = 0, tp = inputText; *tp != '\0'; bc++){if (tp[0] != '\\')tp++;

This problem is caused by the code implementation of the PostgreSQL baseline. Ofcourse, you can solve the problem by enumerating all possible invalid scenarios.However, it is difficult to implement. More importantly, the judgment logic isadded to reduce the processing efficiency. This is the reason why the communitydoes not allow the introduction of character sets such as GBK and SJIS (Japanese).

Solution: Do not use GBK as the character encoding on the server. You can useUTF-8 instead. In addition, do not use SQL_ASCII as the server encoding.SQL_ASCII saves characters as single-byte characters regardless of the characterset. The internal logic will also be processed as single-byte characters, which maycause the problem. The GBK contains two-byte characters (0x5C), as shown in thefollowing figure.

Data Warehouse ServiceTroubleshooting 2 Data Import and Export

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 12

Page 17: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

2.2 When a Common User Executes or Deletes theStatement for Creating a GDS/OBS Foreign Table, anError Is Reported, Indicating That the User Does NotHave the Permission or Has Insufficient Permission

Symptom

A super user can successfully execute the statement for creating a GDS/OBSforeign table, but an error "ERROR: permission denied to create foreign table insecurity mode" is reported when a common user executes the statement.

Possible Causes

The error information indicates that the common user does not have thepermission to create a foreign table.

Handling Procedure

Use the database administrator to assign the permissions for operating foreigntables to common users or roles. The permissions include creating, deleting,modifying, and reading and writing foreign tables. For details about theauthorization commands, see ALTER USER or ALTER ROLE in the Data WarehouseService Database Developer Guide. The following is an example:ALTER USER user_name USEFT;

2.3 During Execution of the SQL Statement forCreating an OBS Foreign Table, OBS Access Is Denied

Symptom

When a user executes the SQL statement for creating an OBS foreign table, anOBS error "Access Denied" is reported.

Possible Causes● If the AK and SK in the statement for creating an OBS foreign table are

incorrect, the following error information is displayed:ERROR: Fail to connect OBS in node:cn_5001 with error code: AccessDenied

● If an account does not have the read and write permissions on correspondingOBS buckets, the following error information is displayed:dn_6001_6002: Datanode 'dn_6001_6002' fail to read OBS object bucket:'obs-bucket-name' key:'xxx/xxx/xxx.csv' with OBS error code:AccessDenied message: Access Denied

By default, an account does not have the permission to access OBS data ofother accounts. In addition, an IAM user (similar to a sub-user) does not havethe permission to access OBS data of the account to which it belongs.

Data Warehouse ServiceTroubleshooting 2 Data Import and Export

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 13

Page 18: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

Handling Procedure● The AK and SK in the statement for creating an OBS foreign table are

incorrect.Obtain the correct AK and SK and write them into the SQL statement. Toobtain the AK and SK, perform the following steps:

a. Log in to the GaussDB(DWS) management console.b. Move the cursor to the username in the upper right corner and choose

My Credentials.c. In the navigation pane, click Access Keys.

On the Access Keys page, you can view the existing access key ID (AK).d. If you want to obtain both the AK and SK, click Create Access Key to

create and download the access key file.● The account does not have the read and write permissions on OBS

buckets.You must grant the required OBS access permissions to specified users.– When importing data to GaussDB(DWS) using an OBS foreign table, the

user who performs the operation must have the read permission on theOBS bucket and object where the source data files are located.

– When exporting data using an OBS foreign table, the user who performsthe operation must have the read and write permissions on the OBSbucket and object where the data export path is located.

For details about configuring OBS permissions, see Configuring a Bucket ACLand Configuring a Bucket ACL in the Object Storage Service ConsoleOperation Guide.

2.4 Failed to Create a GDS Foreign Table and An ErrorWas Reported Indicating That ROUNDROBIN Is NotSupported

Symptom

A GDS foreign table failed to be created and an error was reported indicating thatROUNDROBIN is not supported. The message is as follows:

ERROR: For foreign table ROUNDROBIN distribution type is built-in support.

Possible Causes

By default, a GDS foreign table is created in ROUNDROBIN distribution mode.ROUNDROBIN distribution information cannot be explicitly added during tablecreation.

Handling Procedure

When creating a GDS foreign table, delete the specified distribution information,that is, delete the specified DISTRIBUTE BY ROUNDROBIN in the statement.

Data Warehouse ServiceTroubleshooting 2 Data Import and Export

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 14

Page 19: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

2.5 Disk Usage Increases After Data Fails to BeImported Using GDS

SymptomA user uses GDS to import data but fails, triggering data import again. After datais imported, the user checks the disk space and finds that newly occupied diskspace is much greater than the imported data volume.

Cause AnalysisAfter data fails to be imported, the occupied disk space is not released.

Solution

Step 1 Check the logs of GDS import jobs to see whether any execution failure occurs.

Step 2 Clear the related table or partition.vacuum [full] table_name;

----End

2.6 Data to Be Imported Contains Chinese When theDLF Service Is Used to Create a GaussDB(DWS) ForeignTable

SymptomWhen a user uses the Data Lake Factory (DLF) service to create a GaussDB(DWS)foreign table and specify UTF-8 as the OBS file encoding format in the statementfor creating the foreign table. However, an error occurs when the user importsdata.

Possible CausesThe source file stored on OBS contains non-UTF-8 data.

Handling ProcedureCheck whether the source file contains non-UTF-8 data, for example, Chinesecharacters. If the source file contains non-UTF-8 data, convert the source file intothe UTF-8 format, upload the converted file to OBS again, and import the data.

Data Warehouse ServiceTroubleshooting 2 Data Import and Export

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 15

Page 20: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

2.7 "ERROR: invalid byte sequence for encoding 'UTF8':0x00" Is Reported When Data Is Imported toGaussDB(DWS) Using COPY FROM

Symptom

"ERROR: invalid byte sequence for encoding 'UTF8': 0x00" is reported when data isimported to GaussDB(DWS) using COPY FROM.

Possible Causes

The data file is imported from an Oracle database, and the file is UTF-8 encoded.The error message also contains the number of lines. Because the file is too largeto be opened by running the vim command, run the sed command to extract thelines, and then run the vim command to open the file. No exception is found. Partof the file can be imported after running the split command to split the file by thenumber of lines.

According to the GaussDB(DWS) document, the direct cause of this error is thatthe fields or variables in VARCHAR type do not support character stringscontaining '\0' (that is, the value 0x00 and the UTF code '\u0000'). The solution isto delete '\0' from the character string in advance.

Handling Procedure

Run the sed command to replace 0x00.

sed -i 's/\x00//g;' file

NO TE

Parameter description: -i indicates direct replacement in the original file. s/ indicatesreplacement. /g indicates global replacement.

2.8 Failed to Import an MRS Data Source Through aForeign Table

Symptom

When an MRS data source is imported through a foreign table, a message isdisplayed indicating that the import fails.

Possible Causes

The MRS cluster and the DWS cluster are not in the same VPC and subnet, andthe network is disconnected.

Data Warehouse ServiceTroubleshooting 2 Data Import and Export

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 16

Page 21: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

Handling ProcedureEnsure that the MRS cluster and the DWS cluster are in the same region, VPC, andsubnet, and the DWS cluster can communicate with the MRS cluster. For details,see Managing MRS Data Sources.

Data Warehouse ServiceTroubleshooting 2 Data Import and Export

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 17

Page 22: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

3 Database Use

3.1 After the Permission for Querying Tables in aSchema Is Granted to a User, the User Still CannotQuery the Tables

SymptomAfter an authorized user runs the grant select on all tables in schemaschema_name to B command to grant the permission for querying tables in aschema to user B, user B still cannot access the tables.

Possible CausesTo authorize a user to access table or view objects in a schema, you also need togrant the USAGE permission of the schema to the user. Without this permission,the user can only view the names of the objects but cannot access them.

If you want to grant user B the permission on tables to be created in the schema,run the ALTER DEFAULT PRIVILEGES command to change the default permission.

Handling ProcedureLog in to the database as a user with the schema permission and run thefollowing command to grant the table permission in the schema to a specifieduser:

GRANT USAGE ON SCHEMA schema_name TO B;GRANT SELECT ON ALL TABLES IN SCHEMA schema_name TO B;

Run the following command to grant the permission on the tables to be created inthe schema to a specified user:

ALTER DEFAULT PRIVILEGES IN SCHEMA schema_name GRANT SELECT ON TABLES TO B;

In the preceding SQL statements, GRANT SELECT indicates that the table querypermission is assigned. If you want to assign other permissions to other users, seethe GRANT syntax description.

Data Warehouse ServiceTroubleshooting 3 Database Use

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 18

Page 23: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

3.2 "Connection reset by peer" Is Displayed When aUser Executes an SQL Statement

Symptom"Connection reset by peer" is displayed when a user executes an SQL statement.

ERROR: Failed to read response from Datanodes Detail: Connection reset by peer

Cause AnalysisNetwork is disconnected due to socket communication errors under heavynetwork traffic.

Solution● Set the following GUC parameters to control the peak value of the network

traffic:comm_quota_size = 400comm_usable_memory = 100

● After detecting such errors, the database automatically retries the SQLstatements. The number of retries is controlled by max_query_retry_times.

NO TE

Only one SQL statement can be retried excluding error SQL statements in a transactionblock.

3.3 "failed to find conversion function from unknownto text" Is Displayed When a User Executes the SELECTStatement

SymptomAn error message is displayed when the SELECT statement is executed.

failed to find conversion function from unknown to text

ERROR: failed to find conversion function from unknown to text

Cause AnalysisThe type of a constant in a subquery of the SELECT statement is not specified.

SolutionConvert the constant type of the subquery to a fixed type.

For example:

create table t1(col1 int, col2 int);

Data Warehouse ServiceTroubleshooting 3 Database Use

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 19

Page 24: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

SELECT distinct Q.* FROM (SELECT col1, '2015-03-01' AS start_time, '2015-03-01' AS last_time FROM t1)Q;

Change it as follows:

SELECT distinct Q.* FROM (SELECT col1, cast('2015-03-01' as text) AS start_time, cast('2015-03-01' as text) AS last_time FROM t1)Q;

3.4 Is a Field Name Enclosed with Double QuotationMarks in an SQL Statement Case-sensitive?

Symptom

Is a field name enclosed with double quotation marks in an SQL statement case-sensitive?

Assume that the table01 table contains a field named ColumnA. When you runthe select statement, an error message is displayed, indicating that the field doesnot exist. The error message is as follows: column "columna" does not exist.

select ColumnA from table01 limit 100;

However, the following select statement can be successfully executed:

select "ColumnA" from table01 limit 100;

Possible Causes

On GaussDB(DWS), table field names of SQL statements are case-sensitive if theyare enclosed with double quotation marks. Otherwise, they are case-insensitive(are regarded as lowercase letters).

Handling Procedure

In case insensitive scenarios, delete the double quotation marks from the fieldnames. In case sensitive scenarios, add the double quotation marks to the fieldnames.

3.5 VARCHAR(18) Cannot Store Eight ChineseCharacters

Symptom

How many bytes does a Chinese character occupy? The VARCHAR(18) fieldcannot store eight Chinese characters. The following error is reported:

org.postgresql.util.PSQLException: ERROR: value too long for type character varying(18)

Data Warehouse ServiceTroubleshooting 3 Database Use

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 20

Page 25: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

Possible CausesA Chinese character occupies three or four bytes, so 18 bytes cannot store eightChinese characters.

Handling ProcedureIncrease the field length.

3.6 The Byte Type Is Returned After a Table Field of theCharacter Type Is Read In Java

SymptomA field in a newly created database table is of the character type. However, afterthe field is read in Java, the returned type is byte.

For example, create a table using the following statement:

CREATE TABLE IF NOT EXISTS table01( msg_id character(36), msg character varying(50));

In Java, the code for reading the field of the character type is as follows:

ColumnMetaInfo(msg_id,1,Byte,true,false,1,true);

Possible CausesCHARACTER(n) is a fixed-length character string. When the actual string length isinsufficient, the database pads it with spaces. Then, Java uses the byte type toreceive the string. CHARACTER VARYING(n) is a variable-length character string.Java uses the string type to receive it.

3.7 When the ODBC Driver of GaussDB(DWS) Is Used,Content of Fields of the Character Type in the SQLQuery Result Is Truncated

SymptomWhen the ODBC driver of GaussDB(DWS) is used, the content of fields of thecharacter type in the SQL query result is truncated. To obtain the complete fieldinformation, use the SQL syntax CAST BYTEA to convert the field content intobinary. However, when the same program connects to the Oracle database andSQL server, this fault does not occur.

Possible CausesThe max varchar parameter is set to 255 on the ODBC client. As a result, fieldsthat have more than 255 characters are truncated.

Data Warehouse ServiceTroubleshooting 3 Database Use

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 21

Page 26: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

Handling ProcedureOn the ODBC client, increase the value of max varchar.

3.8 Failed to Execute "merge into update" for MultipleTables

SymptomFailed to execute "merge into update" for multiple tables.

Possible CausesThe following error log is printed:

dn_6007_6008 YY003 79375943437085786 [BACKEND] DETAIL: blocked by hold lock thread 0, statement <pending twophase transaction>, hold lockmode (null).

This fault is caused by distributed locks. Two DNs lock their own data blocks andwait for the data block of the other. As a result, the locks time out.

This is a feature of two-phase locks, and this fault occurs in distributed situations.

Handling ProcedureRun the merge command to change the concurrent operations to serial operationson a single table.

3.9 "ERROR:start value of partition 'XX' NOT EQUALup-boundary of last partition." Is Displayed WhenOperations Related to Table Partitions Are Performed

SymptomWhen ALTER TABLE PARTITION is performed, the following error message isdisplayed:

ERROR:start value of partition "XX" NOT EQUAL up-boundary of last partition.

Cause AnalysisIf the ALTER TABLE PARTITION statement involves both the DROP PARTITIONoperation and the ADD PARTITION operation, GaussDB(DWS) always performs theDROP PARTITION operation before the ADD PARTITION operation regardless oftheir orders. However, performing DROP PARTITION before ADD PARTITIONcauses a partition gap. As a result, an error is reported.

SolutionTo prevent partition gaps, set END in DROP PARTITION to the value of START inADD PARTITION.

Data Warehouse ServiceTroubleshooting 3 Database Use

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 22

Page 27: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

Example: Create the partitioned table partitiontest.

CREATE TABLE partitiontest ( c_int integer, c_time TIMESTAMP WITHOUT TIME ZONE) PARTITION BY range (c_int) ( partition p1 start(100)end(108), partition p2 start(108)end(120) );

An error is reported when the following statements are used:

ALTER TABLE partitiontest ADD PARTITION p3 start(120)end(130), DROP PARTITION p2;ERROR: start value of partition "p3" NOT EQUAL up-boundary of last partition.ALTER TABLE partitiontest DROP PARTITION p2,ADD PARTITION p3 start(120)end(130) ;ERROR: start value of partition "p3" NOT EQUAL up-boundary of last partition.

Change them as follows:

ALTER TABLE partitiontest ADD PARTITION p3 start(108)end(130), DROP PARTITION p2;ALTER TABLE partitiontest DROP PARTITION p2,ADD PARTITION p3 start(108)end(130) ;

3.10 Different Data Is Displayed for the Same TableQueried By Multiple Users

SymptomTwo users log in to the same database human_resource and run the selectcount(*) from areas statement separately to query the areas table, but obtaindifferent results.

Cause AnalysisCheck whether the two users really query the same table. In a relational database,a table is identified by three elements: database, schema, and table. In this issue,database is human_resource and table is areas. Then, check schema. Log in asusers dbadmindbadmin and user01 separately. It is found that search_path ispublic for dbadmin and $user for user01. By default, a schema having the samename as user dbadmin, the cluster administrator, is not created. That is, all tableswill be created in public if no schema is specified. However, when a common user,such as user01, is created, the same-name schema (user01) is created by default.That is, all tables are created in user01 if the schema is not specified. Inconclusion, because both users performed operations on the table, there are nowtwo different tables with the same name.

SolutionUse schema.table to determine a table for query.

Data Warehouse ServiceTroubleshooting 3 Database Use

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 23

Page 28: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

3.11 When a User Specifies Only an Index Name toModify the Index, A Message Indicating That the IndexDoes Not Exist Is Displayed

Symptom

Create a partitioned table index HR_staffS_p1_index1, without specifying indexpartitions.

CREATE INDEX HR_staffS_p1_index1 ON HR.staffS_p1 (staff_ID) LOCAL;

Create a partitioned table index HR_staffS_p1_index2, with index partitionsspecified.

CREATE INDEX HR_staffS_p1_index2 ON HR.staffS_p1 (staff_ID) LOCAL( PARTITION staff_ID1_index, PARTITION staff_ID2_index TABLESPACE example3, PARTITION staff_ID3_index TABLESPACE example4) TABLESPACE example;

The user changes the tablespace of an index partition staff_ID1_index toexample1:

When the user executes ALTER INDEX HR_staffS_p1_index2 MOVE PARTITIONstaff_ID2_index TABLESPACE example1;, a message is displayed, indicating thatthe index does not exist.

Cause Analysis

Run the CREATE INDEX HR_staffS_p1_index2 MOVE PARTITION staff_ID2_indexTABLESPACE example1 command to recreate the index. An error messageindicating that the index already exists is displayed. Then, run the following SQLstatement or the \d+ HR.staffS_p1 meta command using gsql to query the index,a message is displayed, indicating that the index already exists.

SELECT * FROM DBA_INDEXES WHERE index_name = HR.staffS_p1 ;

The possible reason why the user fails to find the index is that the user is in thepublic schema instead of the hr schema.

To verify this guess, execute ALTER INDEX hr.HR_staffS_p1_index2 MOVEPARTITION staff_ID2_index TABLESPACE example1;. The execution succeeds,proving the guess to be correct.

Execute ALTER SESSION SET CURRENT_SCHEMA TO hr; and then ALTER INDEXHR_staffS_p1_index2 MOVE PARTITION staff_ID2_index TABLESPACEexample1;. The setting succeeds.

Solution

Use schema.table to determine a table, index, or view for query.

Data Warehouse ServiceTroubleshooting 3 Database Use

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 24

Page 29: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

3.12 Reindexing Fails

Symptom

When an index of the Desc table is damaged, a series of operations cannot beperformed. The error information may be as follows:

index \"%s\" contains corrupted page at block %u" ,RelationGetRelationName(rel),BufferGetBlockNumber(buf),please reindex it.

Cause Analysis

In actual operations, indexes may break down due to software or hardware faults.For example, if disk space is insufficient or pages are damaged after indexes aresplit, the indexes may be damaged.

Solution

If the table is named , the index table of the Desc table has been damaged. Usethe name of the Desc index table to find the OID and table of the correspondingprimary table, and run the REINDEX INTERNAL TABLE name statement toreindex the cudesc table.

3.13 An Error Occurs During the Integer Conversion

Symptom

The following error is reported during the integer conversion:

Invalid input syntax for integer: "13."

Cause Analysis

Some data types cannot be converted to the target data type.

Solution

Gradually narrow down the range of SQL statements to locate the fault.

3.14 A View Failed to Be Queried

Symptom

When a user connects to a cluster database and then queries a view, the followingerror information is displayed:

[GAUSS-01850] : object with oid 16420 is not a partition object

Data Warehouse ServiceTroubleshooting 3 Database Use

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 25

Page 30: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

Cause AnalysisThe queried view is created on a partition of a partitioned table, therefore,querying this view requires access to the target partition. If this partition has beendeleted, the view fails to be queried.

Solution

Step 1 Ensure that you are running an SQL statement on the view object and obtain theview name.

Check whether the object specified for FROM in the SQL statement is the view. Ifit is, record the view name.

Step 2 Delete the view using the obtained user name and schema.

Step 3 Run the SQL statement again. The target partition has been deleted, therefore,querying the view is unnecessary.

----End

3.15 An Error Is Reported When Data is Inserted orUpdated, Indicating That the Distribution Key CannotBe Updated

SymptomAn error is reported when data is inserted or updated, indicating that thedistribution key cannot be updated. The following is the error message:

ERROR: Distributed key column can't be updated in current version

Possible CausesThe GaussDB(DWS) distribution key cannot be updated.

3.16 DROP TABLE Fails to Be Executed

SymptomDROP TABLE fails to be executed in the following scenarios:

● A user runs the SELECT * FROM DBA_TABLES statement (or runs the \dt+command using gsql) and finds that the table_name table does not exist inthe database. When the user runs the CREATE TABLE table_name statement,an error message indicating that the table_name table already exists. Whenthe user runs the DROP TABLE table_name statement, an error messageindicating that the table_name table does not exist. In this case, thetable_name table cannot be recreated.

● A user runs the SELECT * FROM DBA_TABLES statement (or runs the \dt+command using gsql) and finds that the table_name table exists in the

Data Warehouse ServiceTroubleshooting 3 Database Use

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 26

Page 31: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

database. When the user runs the DROP TABLE table_name statement, anerror message indicating that the table_name table does not exist. In thiscase, the table_name table cannot be recreated.

Cause Analysis

The table_name table exists on some nodes only.

Solution

In the preceding scenarios, if DROP TABLE table_name fails to be executed, runDROP TABLE IF EXISTS table_name to successfully drop table_name.

3.17 Failed to Delete a Database and an Error WasReported Indicating That a Session Is Connected to theDatabase

Symptom

A database failed to be deleted and an error was reported indicating that asession is connected to the database.

Possible Causes

A session is still connected to the database, or a session keeps connecting to thedatabase. Therefore, the database fails to be deleted. Check the database to findout whether there is a connected session. If such a session exists, find the machinethat connects to the database, disconnect the connection, and delete thedatabase.

Handling Procedure

Step 1 Using the SQL client tool to connect to the database.

Step 2 Run the following command to view the current sessions:select * from pg_stat_activity;

Key fields in the query result are described as follows:

● datname: name of the database to which the user session connects● usename: name of the user who connects to the database● client_addr: IP address of the client host that connects to the database

In the query result, find the name of the database to be deleted and the IPaddress of the corresponding client host.

Step 3 Check the host and applications that connect to the database based on the IPaddress of the client host, and stop the connections.CLEAN CONNECTION TO ALL FOR DATABASE xxx;

Step 4 Run the following command to delete the database again:

Data Warehouse ServiceTroubleshooting 3 Database Use

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 27

Page 32: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

DROP DATABASE [ IF EXISTS ] database_name;

----End

3.18 Failed to Run the "create extension" Commandand An Error Indicating No Permission Was Reported

Symptom

The create extension command failed to be run and the following error messagewas displayed:

ERROR: permission denied to create extension "uuid-ossp" Hint: Must be superuser to create this extension.

Possible Causes

GaussDB(DWS) does not support the extension feature of the postgrescommunity.

3.19 Checking Lock Waits1. Create a test table and insert data.

2. Create database connection 1, start transaction 1, and delete the test table.

3. Create database connection 2, start transaction 2, and query data in the testtable. The following error information is displayed:

4. Query the pg_locks view, and run the select * from pg_locks wherepid=140162688874240; command to check the process that holds the lock.

Data Warehouse ServiceTroubleshooting 3 Database Use

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 28

Page 33: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

5. Check the pg_stat_activity view, and run the select * from pg_stat_activitywhere pid=140162688874240; command to query the process that holds thelock.

6. Terminate transaction 1.

7. Query the table data. The query results show that the data is normal.

3.20 Global SQL QueryThe pgxc_stat_activity function and view are used to implement global SQLquery.

1. Log in as the OS user omm to the host where a CN is deployed. Run source ${BIGDATA_HOME}/mppdb/.mppdbgs_profile to start environment variables.

2. Run the following command to connect to the database:gsql -d postgres -p 8000

3. Run the following commands to create the pgxc_stat_activity function:DROP FUNCTION PUBLIC.pgxc_stat_activity() cascade;CREATE OR REPLACE FUNCTION PUBLIC.pgxc_stat_activity(

Data Warehouse ServiceTroubleshooting 3 Database Use

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 29

Page 34: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

OUT coorname text,OUT datname text,OUT usename text,OUT pid bigint,OUT application_name text,OUT client_addr inet,OUT backend_start timestamptz,OUT xact_start timestamptz,OUT query_start timestamptz,OUT state_change timestamptz,OUT waiting boolean,OUT enqueue text,OUT state text,OUT query_id bigint,OUT query text)RETURNS setof RECORDAS $$DECLARErow_data pg_stat_activity%rowtype;coor_name record;fet_active text;fetch_coor text;BEGIN--Get all the node namesfetch_coor := 'SELECT node_name FROM pg_catalog.pgxc_node WHERE node_type=''C''';FOR coor_name IN EXECUTE(fetch_coor) LOOPcoorname := coor_name.node_name;fet_active := 'EXECUTE DIRECT ON (' || coorname || ') ''SELECT * FROM pg_catalog.pg_stat_activity WHERE pid != pg_catalog.pg_backend_pid() and application_name not in (SELECT node_name FROM pg_catalog.pgxc_node WHERE node_type=''''C''''); ''';FOR row_data IN EXECUTE(fet_active) LOOPdatname := row_data.datname;pid := row_data.pid;usename := row_data.usename;application_name := row_data.application_name;client_addr := row_data.client_addr;backend_start := row_data.backend_start;xact_start := row_data.xact_start;query_start := row_data.query_start;state_change := row_data.state_change;waiting := row_data.waiting;enqueue := row_data.enqueue;state := row_data.state;query_id := row_data.query_id;query := row_data.query;RETURN NEXT;END LOOP;END LOOP;return;END; $$LANGUAGE 'plpgsql';

4. Run the following command to create the pgxc_stat_activity view:CREATE VIEW PUBLIC.pgxc_stat_activity AS SELECT * FROM PUBLIC.pgxc_stat_activity();

5. Run the following SQL statement to query global session information:SELECT * FROM PUBLIC.pgxc_stat_activity order by coorname;

Data Warehouse ServiceTroubleshooting 3 Database Use

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 30

Page 35: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

3.21 What Should I Do If an Authentication orMechanisms Error Is Reported When Connecting toGaussDB(DWS)?

SymptomEither of the following error message is displayed when GaussDB(DWS) isconnected:

The authentication type 10 is not supported.

Invalid or unsupported by client SCRAM mechanisms

Possible CausesSuch error is reported when there is a failure in negotiating authenticationalgorithm between the client and server. The possible causes may be thatPostgreSQL ecosystem tools are used or the driver client is connected toGaussDB(DWS).

Handling ProcedureSolution 1:

Replace postgresql-*.jar in the ecosystem tool with gsjdbc4.jar, driver ofGaussDB(DWS) (the interface name is the same).

If PostgreSQL is used, replace it with the gsql client of GaussDB(DWS). (Use thesame method.)

Solution 2:

If the driver mentioned in solution 1 cannot be found or the tool does not supportdriver replacement, use solution 2.

Step 1 Set password_encryption_type to 1, indicating that SAH256 and MD5 aresupported. The GaussDB client uses SHA256 by default. The native PostgreSQLclient uses MD5 authentication.gs_guc reload -Z coordinator -Z datanode -N all -I all -c "password_encryption_type=1"

Step 2 After modifying the parameters, create another database user or change the olduser's password.

----End

Data Warehouse ServiceTroubleshooting 3 Database Use

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 31

Page 36: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

4 Database Performance and Resources

4.1 A Data Warehouse Cluster Becomes Read-Only andIs Locked, so Data Cannot be Written to It

Symptom● The cluster is in the read-only state.● When SQL statements are executed to write data to the cluster, an error

message stating "cannot execute INSERT in a read-only transaction" isrepeatedly reported.Reporting "read-only transaction" indicates that the data warehouse clusterhas entered the read-only state.

Possible CausesIf the data storage capacity of any disk on a node in the data warehouse cluster isgreater than 90%, the cluster automatically enters the read-only state, preventingexceptions caused by full disk usage. The cluster can still work in this state butsupports only query operations. To check the fault, do as follows:

1. Check whether the database's data volume reaches 90% of the total capacity.Log in to the GaussDB(DWS) management console. On the ClusterManagement page, find the target cluster and click its name. The BasicInformation page is displayed. Check the Used Storage Capacity parameter.

2. Check whether data skew occurs, which causes disk skew. On a cluster node,if the usage of a disk reaches 90% but the usage of other disks is low, thecluster still enters the read-only state.If the distribution columns are not properly selected for a Hash table, datawill be unevenly distributed on DNs, causing data skew.In this case, run the following SQL statement to check whether data skewoccurs in a table. Replace table_name with the actual table name.SELECT a.count,b.node_name FROM (SELECT count(*) AS count,xc_node_id FROM table_name GROUP BY xc_node_id) a, pgxc_node b WHERE a.xc_node_id=b.node_id ORDER BY a.count desc;

xc_node_id corresponds to a DN. Generally, if the data volume differencebetween two DNs is more than 5%, data skew occurs. If the difference is

Data Warehouse ServiceTroubleshooting 4 Database Performance and Resources

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 32

Page 37: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

more than 10%, you must adjust the distribution columns. Multipledistribution columns can be selected on GaussDB(DWS) to distribute dataevenly.

Handling Procedure1. Contact technical support engineers to cancel the read-only state.2. If the Used Storage Capacity of the cluster reaches 90%, perform the

following operations:

a. Run VACUUM FULL periodically to prevent data expansion.b. Analyze whether the current cluster flavor meets service requirements. If

not, scale out the cluster.c. If you do not want to scale out your cluster, you are advised to release

the disk space after the read-only state is canceled.3. If the disk usage of a DN is too high due to data skew, the distribution

columns are not properly selected. Select appropriate distribution columnsand recreate the table.

4.2 Slow Response to a Query Statement

Symptom

After a query statement has been executed, no response is returned for a longtime.

Cause Analysis● The query statement is complex and requires a long time for execution.● The query statement is blocked.

Solution

Step 1 Use an SQL client to connect to the database.

Step 2 Check for the query statements that are executed for a long time in the system.select current_timestamp - query_start as runtime, datname, usename, query from pg_stat_activity where state != 'idle' order by 1 desc;

Query statements are returned, sorted by execution time length in descendingorder. The first record is the query statement that takes the longest time forexecution.

Alternatively, you can set current_timestamp - query_start to be greater than athreshold to identify query statements that are executed for a duration longerthan this threshold.select query from pg_stat_activity where current_timestamp - query_start > 2;

Step 3 Analyze the status of the query statements that were run for a long time.

For details on how to query the statement status, see Analyzing the Status of aQuery Statement.

Data Warehouse ServiceTroubleshooting 4 Database Performance and Resources

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 33

Page 38: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

● If the query statement is normal, wait until the execution is complete.● If the query statement is blocked, see the handling method in Analyzing

Whether a Query Statement Is Blocked.

----End

4.3 Analyzing the Status of a Query StatementSome query statements are executed for an excessively long time in the system.You can analyze the status of these query statements to find which are runningand which are blocked.

Solution

Step 1 Use an SQL client to connect to the database.

Step 2 Set the parameter track_activities to on.SET track_activities = on;

The database collects the running information about active queries only if theparameter is set to on.

Step 3 Check the statement running status.

Viewing pg_stat_activity is used as an example here.

SELECT datname, usename, state FROM pg_stat_activity; datname | usename | state |----------+---------+--------+ postgres | dbadmin | idle | postgres | dbadmin | active |(2 rows)

If the state column is idle, the connection is idle and requires a user to enter acommand.

To identify only active query statements, run the following command:

SELECT datname, usename, state FROM pg_stat_activity WHERE state != 'idle';

Step 4 Analyze whether a query statement is in the active or blocked state.

Run the following command to view a query statement in the block state:

SELECT datname, usename, state, query FROM pg_stat_activity WHERE waiting = true;

The query statement is displayed. It is requesting a lock resource that may be heldby another session, and is waiting for the lock resource to be released by thesession. For details about how to release lock resources, see Analyzing Whether aQuery Statement Is Blocked.

NO TE

Only when the query is blocked by internal lock resources, the waiting field is true. In mostcases, block happens when query statements are waiting for lock resources to be released.However, query statements may be blocked because they are waiting to write in files or fortimers. Such blocked queries are not displayed in the pg_stat_activity view.

----End

Data Warehouse ServiceTroubleshooting 4 Database Performance and Resources

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 34

Page 39: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

4.4 Analyzing Whether a Query Statement Is Blocked

Symptom

During database system running, query statements are blocked in some servicescenarios. As a result, the query statements are executed for an excessively longtime.

Cause Analysis

A query statement uses a lock to protect the data objects that it wants to access,but if the data objects have been locked by another session, the query statementwill be blocked and wait for the session to complete operation and release thelock resource. The data objects requiring locks include tables and tuples.

Solution

Step 1 Use an SQL client to connect to the database.

Step 2 View blocked query statements and information about the tables and schemasthat block the query statements.SELECT w.query as waiting_query,w.pid as w_pid,w.usename as w_user,l.query as locking_query,l.pid as l_pid,l.usename as l_user,t.schemaname || '.' || t.relname as tablenamefrom pg_stat_activity w join pg_locks l1 on w.pid = l1.pidand not l1.granted join pg_locks l2 on l1.relation = l2.relationand l2.granted join pg_stat_activity l on l2.pid = l.pid join pg_stat_user_tables t on l1.relation = t.relidwhere w.waiting;

The command output includes a session ID, user information, query status, andtable or schema that caused the block.

Step 3 After finding the blocked table or schema information, end the faulty session.SELECT PG_TERMINATE_BACKEND(139834762094352);

If information similar to the following is displayed, the session is successfullyterminated:

PG_TERMINATE_BACKEND---------------------- t(1 row)

If information similar to the following is displayed, a user is attempting toterminate the session, and the session will be reconnected rather than beingterminated.

FATAL: terminating connection due to administrator commandFATAL: terminating connection due to administrator commandThe connection to the server was lost. Attempting reset: Succeeded.

Data Warehouse ServiceTroubleshooting 4 Database Performance and Resources

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 35

Page 40: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

NO TE

If the PG_TERMINATE_BACKEND function is used to terminate the background threads ofthe session, the gsql client will be reconnected rather than be logged out.

----End

4.5 The Database Does Not Respond and the SQLStatement Is Quickly Terminated

Symptom

The database enters the suspension mode and does not respond to any query.

Solution

Step 1 Use a SQL client to connect to the database.

Step 2 Run the following command to quickly locate the blocked SQL session through theactive session view:SELECT pid,datname, usename, state,waiting, query FROM pgxc_stat_activity WHERE state <> 'idle' and waiting=true;

Step 3 Run the following statement to end the blocked SQL session:SELECT PG_TERMINATE_BACKEND(pid);

If information similar to the following is displayed, the session is successfullyterminated:

PG_TERMINATE_BACKEND---------------------- t(1 row)

If information similar to the following is displayed, a user is attempting toterminate the session, and the session will be reconnected rather than beingterminated.

FATAL: terminating connection due to administrator commandFATAL: terminating connection due to administrator commandThe connection to the server was lost. Attempting reset: Succeeded.

NO TE

If the PG_TERMINATE_BACKEND function is used to terminate the background threads ofthe session, the gsql client will be reconnected rather than be logged out.

----End

4.6 Forcibly Terminating a SessionIn some cases, an administrator must forcibly terminate abnormal sessions to keepthe healthy system running normally.

Data Warehouse ServiceTroubleshooting 4 Database Performance and Resources

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 36

Page 41: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

Context

In GaussDB(DWS), one session corresponds to one thread. GaussDB(DWS)provides the PG_TERMINATE_BACKEND function to forcibly terminate a specifiedsession thread.

Solution

Step 1 Use an SQL client to connect to the database.

Step 2 Find the thread ID of the faulty session from the current active session view.select datid,pid,state from pg_stat_activity;

A command output similar to the following is displayed, where the pid valueindicates the thread ID of the session.

datid | pid | state -------+-----------------+-------- 13205 | 139834762094352 | active 13205 | 139834759993104 | idle(2 rows)

Step 3 Terminate the session using its thread ID.SELECT PG_TERMINATE_BACKEND(139834762094352);

If information similar to the following is displayed, the session is successfullyterminated:

PG_TERMINATE_BACKEND---------------------- t(1 row)

If information similar to the following is displayed, a user is attempting toterminate the session, and the session will be reconnected rather than beingterminated.

FATAL: terminating connection due to administrator commandFATAL: terminating connection due to administrator commandThe connection to the server was lost. Attempting reset: Succeeded.

NO TE

If the PG_TERMINATE_BACKEND function is used to terminate the background threads ofthe session, the gsql client will be reconnected rather than be logged out.

----End

4.7 Low Query EfficiencyA query task that used to take a few milliseconds to complete is now requiringseveral seconds, and that used to take several seconds is now requiring even halfan hour. This section describes how to analyze and rectify such low efficiencyissues.

Solution

Perform the following procedure to locate the cause of this fault.

Data Warehouse ServiceTroubleshooting 4 Database Performance and Resources

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 37

Page 42: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

Step 1 Run the analyze command to analyze the database.

The analyze command updates data statistics information, such as data sizes andattributes in all tables. This is a lightweight command and can be executedfrequently. If the query efficiency is improved or restored after the commandexecution, the autovacuum process does not function well and requires furtheranalysis.

Step 2 Check whether the query statement returns unnecessary information.

For example, if the query statement to query all records in a table, and use resultin only the first 10 records. If the ACS contains 50 record table. The query up isvery fast. However, when the table contains records reaches 50000 to queryefficiency will decrease.

If an application requires only a part of data information but the query statementreturns all information, add a LIMIT clause to the query statement to restrict thenumber of returned records. In this way, the database optimizer can optimizespace and improve query efficiency.

Step 3 Check whether the query statement still has a low response even when it is solelyexecuted.

Run the query statement when there are no or only a few other query requests inthe database, and observe the query efficiency. If the efficiency is high, theprevious issue is possibly caused by a heavily loaded host in the database systemor an inefficient execution plan.

Step 4 Check the same query statement repeatedly to check the query efficiency.

One major cause of low query efficiency is that the required information is notcached in the memory or is replaced by other query requests because ofinsufficient memory resources.

Run the same query statement repeatedly. If the query efficiency increasesgradually, the previous issue might be caused by this reason.

----End

4.8 SQL Execution Is Slow with Low Performance andSometimes Does Not End After a Long Period of Time

Symptom

The SQL execution is slow with low performance and sometimes does not endafter a long period of time.

Possible Causes

Analyze the causes of slow SQL execution from the following aspects:

1. Run the EXPLAIN command to view the SQL execution plan and determinewhether to optimize the SQL statements based on the plan.

Data Warehouse ServiceTroubleshooting 4 Database Performance and Resources

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 38

Page 43: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

2. Check whether the query is blocked. If the query is blocked, the statementexecution takes a long time. In this case, you can forcibly terminate theabnormal sessions.

3. Review and modify the table definitions. Select an appropriate distribution keyto avoid data skew.

4. Check whether the SQL statements use functions that do not supportpushdown. You are advised to use the syntax or function that supportspushdown.

5. Run the VACUUM FULL and ANALYZE commands periodically to reclaim thedisk space occupied by updated or deleted data.

6. Check whether the table has an index. You are advised to re-create the indexregularly.After multiple deletion operations are performed on the database, the indexkey on the index page will be deleted, causing index expansion. Re-creatingthe index regularly can improve the query efficiency.

7. Optimize services and analyze whether large tables can be divided.

Handling ProcedureGaussDB(DWS) provides methods for analyzing and optimizing queries, as well assome common cases and error handling methods. For details about how to tuneSQL performance, see Query Performance Optimization.

4.9 It Takes a Long Time to Execute SQL StatementsThat Could be Executed Quickly Before

SymptomIt takes a long time to execute SQL statements that could be executed quicklybefore.

Possible CausesThe VACUUM FULL and ANALYZE commands are not executed on the tablesbefore SQL execution, causing data expansion and inaccurate statistics anddeteriorating the SQL execution plan.

Handling ProcedureFor tables that are frequently added, deleted, or modified, periodically run theVACUUM FULL and ANALYZE commands to prevent performance deteriorationcaused by data expansion and inaccurate statistics.

Data Warehouse ServiceTroubleshooting 4 Database Performance and Resources

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 39

Page 44: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

4.10 During SQL Execution, a Table Deadlock Occursand An Error Stating LOCK_WAIT_TIMEOUT Is Reported

Symptom

During SQL execution, lock wait timeout (LOCK_WAIT_TIMEOUT) is reported.

Possible Causes

Lock wait timeout is generally caused by the fact that another SQL statement hasheld the lock. The current SQL statement can be executed only after the SQLstatement that holds the lock is successfully executed and releases the lock. If thelock wait time exceeds the specified value of the GUC parameterlockwait_timeout, the system reports the LOCK_WAIT_TIMEOUT error.

Handling Procedure1. Execute the following SQL statement to check whether any SQL statement is

blocked. If there is a blocked SQL statement, forcibly end it.SELECT w.query as waiting_query,w.pid as w_pid,w.usename as w_user,l.query as locking_query,l.pid as l_pid,l.usename as l_user,t.schemaname || '.' || t.relname as tablenamefrom pg_stat_activity w join pg_locks l1 on w.pid = l1.pidand not l1.granted join pg_locks l2 on l1.relation = l2.relationand l2.granted join pg_stat_activity l on l2.pid = l.pid join pg_stat_user_tables t on l1.relation= t.relidwhere w.waiting;

After the blocked table and the schema information are found, end thesession based on the session ID.SELECT PG_TERMINATE_BACKEND(PID);

2. This fault is generally caused by improper service scheduling. It isrecommended that the scheduling time of each service be properly arranged.

3. You can also set the GUC parameter lockwait_timeout to control themaximum wait time (wait timeout) of a single lock.The unit of lockwait_timeout is millisecond. The default value is 20 minutes.The lockwait_timeout parameter is of the SUSET type. Follow instructions inResetting Parameters to set the parameter.

4.11 An Error Indicating Insufficient Memory IsReported During SQL Execution

Symptom● During SQL execution, the following error information is displayed, indicating

that the memory cannot be allocated:

Data Warehouse ServiceTroubleshooting 4 Database Performance and Resources

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 40

Page 45: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

dn_6015_6016: failed to startup stream thread, NodeName: dn_6015_6016, key(79938893395877621, 3): Cannot allocate memory

● When multiple threads are used to enable multiple connections to run SQLstatements, an error is reported after a period of time, indicating that thememory is unavailable. The error information is as follows:Error: dn_6005_6006: dn_6001_6002: memory is temporarily unavailableDETAIL: Failed on request of size 1024 bytes under queryid 72620543994312268 in stringinfo.cpp:56.

Possible CausesThe error information indicates that insufficient memory is caused by high clusterloads.

Log in to the DWS management console. On the Cluster Management page,locate the required cluster and click View Metric to go to the Cloud Eyemanagement console. Then, view the monitoring information of each node in thecluster and find out the nodes with high memory usage.

● If only the memory of connected CNs is high, syntax or functions that cannotbe pushed down may have been used.

● If the memory usage of all nodes is high, the service concurrency may be toohigh.

Handling Procedure1. Check the services and find out syntax and functions that cannot be pushed

down. Obtain the execution plan of service SQL statements. If the executionplan contains the Data Node Scan node, it cannot be pushed down.For details about the execution plan, and the syntax and functions thatcannot be pushed down on DWS, see Optimizing Statement Pushdown inthe Data Warehouse Service Developer Guide.

2. Reduce the number of concurrent clients.

4.12 Writing Data to GaussDB(DWS) Is Slow and ClientData Is Stacked

SymptomWriting data to GaussDB(DWS) is slow and the client data is stacked.

Possible CausesIf a single INSERT INTO statement is used to write data to a database, the clientmay encounter a bottleneck. INSERT is the simplest data writing method and isapplicable to scenarios with small data volumes and low concurrency.

Handling ProcedureIf data writing is slow, use either of the following methods to rectify the fault:

● Select another more efficient data import mode, for example, COPY.For details about the import modes, see Import Modes.

Data Warehouse ServiceTroubleshooting 4 Database Performance and Resources

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 41

Page 46: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

● Increase the concurrent client requests.

4.13 Error LOCK_WAIT_TIMEOUT Is Reported WhenVACUUM FULL Is Executed

SymptomThe following error is reported when the VACUUM FULL command is executed:

[0]ERROR: dn_6009_6010: Lock wait timeout: thread 140158632457984 on node dn_6009_6010 waiting for AccessExclusiveLock on relation 2299036 of database 14522 after 1202001.968 msDetail: blocked by hold lock thread 140150147380992, statement <<backend information not available>>, hold lockmode AccessShareLock.Line Number: 1

Possible Causes"Lock wait timeout" in the log indicates that the lock wait times out. Lock waittimeout is generally caused by the fact that another SQL statement has held thelock. The current SQL statement can be executed only after the SQL statementthat holds the lock is successfully executed and releases the lock. If the lock waittime exceeds the specified value of the GUC parameter lockwait_timeout, thesystem reports the LOCK_WAIT_TIMEOUT error.

VACUUM FULL command execution may cause this error. For example, if you runthe command over the entire database, the execution time may be long and maytime out.

Handling ProcedureRun the VACUUM FULL command over a single table. The command format isVACUUM FULL table name. In addition, increase the frequency for running thecommand. Especially for tables that are frequently added, deleted, or modified,run the VACUUM FULL command periodically.

4.14 VACUUM Is Executed After Table Data Deletion,But the Space Is Not Released

SymptomAfter a user deletes the data in a table and executes VACUUM, the storage spaceis not released.

Possible CausesThe user may not have the permission to execute VACUUM on some tables or thedatabase does not have too much data expansion.

By default, data in tables of which the current user has the permission are deletedby executing VACUUM. Tables of which the user does not have the permission areskipped.

Data Warehouse ServiceTroubleshooting 4 Database Performance and Resources

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 42

Page 47: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

Handling Procedure

Run the VACUUM FULL command over a single table. The command format isVACUUM FULL table name.

If you do not have the permission on a table, contact the database administratoror the table owner.

4.15 Table Size Does not Change After VACUUM FULLIs Executed on the Table

Symptom

A user runs the VACUUM FULL command to clear a table, but the table size doesnot change.

Cause Analysis

Assume the table is name table_name. Possible causes are as follows:

● No data has been deleted from the table_name table. Therefore, VACUUMFULL table_name has nothing to delete, causing that the table size does notchange.

● Concurrent transactions exist during the execution of VACUUM FULLtable_name, causing that the recently deleted data is skipped for deletion,and thereby the table size does not change.

Solution

The following are solutions for the second possible cause:● Wait until all concurrent transactions are complete, and then run the

VACUUM FULL table_name command again.● If the table size still does not change, Contact Huawei technical support.

4.16 Memory Overflow Occurs in a Cluster

Symptom

The error log is as follows:

[ERROR] Mpp task queryDataAnalyseById or updateDataAnalyseHistoryEndTimesAndResult fail, dataAnalyseId:17615 org.postgresql.util.PSQLException: ERROR: memory is temporarily unavailablesql: vacuum full dws_customer_360.t_user_resource;

Possible Causes

An SQL statement is delivered too many times. As a result, the memory isexhausted.

Data Warehouse ServiceTroubleshooting 4 Database Performance and Resources

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 43

Page 48: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

Handling ProcedureQuery the number of active SQL statements on the two CNs and run the followingstatement to query the memory usage of the current cluster:

select * from pv_total_memory_detail;

Data Warehouse ServiceTroubleshooting 4 Database Performance and Resources

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 44

Page 49: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

5 Database Parameter Modification

5.1 How to Change a Database's Default Time ZoneWhen the Database Time Is Different from the SystemTime

SymptomThe database time is inconsistent with the operating system time. After a userqueries the default database time SYSDATE, it is found that the database time iseight hours later than the Beijing time. As a result, the updated data cannot beaccurately located.

Possible CausesThe UTC time zone is used to display and interpret GaussDB(DWS) databasetimestamps. If the operating system's time zone is not the UTC, time of theGaussDB(DWS) database will be inconsistent with the system time.

Handling ProcedureMethod 1: Change the default time zone of the database in a data warehousecluster.

Step 1 Log in to the GaussDB(DWS) management console.

Step 2 In the navigation tree on the left, click Cluster Management.

Step 3 In the cluster list, find the target cluster and click its name. The Basic Informationpage is displayed.

Step 4 Click the Parameter Modifications tab and change the value of parametertimezone to your time zone. Then click Save.

Step 5 In the Modification Preview dialog box, confirm the modification and click Save.

----End

Data Warehouse ServiceTroubleshooting 5 Database Parameter Modification

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 45

Page 50: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

Method 2: Change the default database time zone in a parameter templateand apply the template to multiple data warehouse clusters.

Step 1 Log in to the GaussDB(DWS) management console.

Step 2 In the navigation tree on the left, click Parameter Template Management.

Step 3 Click Create Parameter Template. In the displayed dialog box, configure thefollowing parameters and click OK.● Database Version: Select a version that matches the cluster version.● Name: Enter the custom name of the new parameter template.

Step 4 In the parameter template list, click the name of the new template and enter theparameter setting page. Set timezone to the time zone where you are located.Click Save.

Step 5 Return to the Parameter Template Management page, find the newly createdtemplate, and click Apply. In the dialog box that is displayed, select the clusters towhich the template is to be applied, and click OK.

You can apply a parameter template to multiple clusters, but note that the EngineVersion of the parameter template must match the cluster version.

----End

Data Warehouse ServiceTroubleshooting 5 Database Parameter Modification

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 46

Page 51: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

A Change History

Release Date Description

2020-11-16 This is the sixth official release.

2020-07-31 This is the fifth official release.The following topic is added:What Should I Do If an Authentication or MechanismsError Is Reported When Connecting to GaussDB(DWS)?

2020-07-15 This is the fourth official release.The following topic is added:"ERROR: invalid byte sequence for encoding 'UTF8': 0x00"Is Reported When Data Is Imported to GaussDB(DWS)Using COPY FROM

2020-05-15 This is the third official release.

Data Warehouse ServiceTroubleshooting A Change History

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 47

Page 52: Troubleshooting - support.huaweicloud.com · connection is abnormal. Contact Huawei technical support. ping -c 4 10.10.10.1 PING 10.10.10.1 (10.10.10.1) 56(84) bytes of data. From

Release Date Description

2020-01-14 This is the second official release.● The following topics are added:

– An Error Indicating Too Many Client Connections IsReported When a User Connects to a GaussDB(DWS)Database

– During Execution of the SQL Statement for Creatingan OBS Foreign Table, OBS Access Is Denied

– Writing Data to GaussDB(DWS) Is Slow and ClientData Is Stacked

– SQL Execution Is Slow with Low Performance andSometimes Does Not End After a Long Period of Time

– An Error Indicating Insufficient Memory Is ReportedDuring SQL Execution

– VARCHAR(18) Cannot Store Eight Chinese Characters– The Byte Type Is Returned After a Table Field of the

Character Type Is Read In Java– When the ODBC Driver of GaussDB(DWS) Is Used,

Content of Fields of the Character Type in the SQLQuery Result Is Truncated

– Failed to Run the "create extension" Command andAn Error Indicating No Permission Was Reported

– After the Permission for Querying Tables in a SchemaIs Granted to a User, the User Still Cannot Query theTables

– VACUUM Is Executed After Table Data Deletion, Butthe Space Is Not Released

● The following topics are modified:– During SQL Execution, a Table Deadlock Occurs and

An Error Stating LOCK_WAIT_TIMEOUT Is Reported– How to Unlock an Account– A Data Warehouse Cluster Becomes Read-Only and Is

Locked, so Data Cannot be Written to It

2019-08-20 This is the first official release.

Data Warehouse ServiceTroubleshooting A Change History

Issue 06 (2020-11-16) Copyright © Huawei Technologies Co., Ltd. 48