Typical Technical Questions
1. If the table structure of TcaplusDB changes, how does the background control versions?
TcaplusDB solves the compatibility problem between versions according to the version number of the table. That is, the TcaplusDB storage layer will store the data of the same table with different version numbers; Therefore, when the gameserver or client reads or writes data, the version number of the table needs to be specified.
When different clients write the same table alternately using different versions of table definitions, the pb table and the tdr table process different fields differently.
Assume gamesvr1: the table has an abc field
Assume gamesvr2: the table has an ab field
Assume tcaplusDb: the table has an abc field
For the PB table:
- Assuming that abc is a field in the pb table, the two svrs write this field alternately, and the c field will be cleared.
For the TDR table:
Assuming that abc is the first-level field of the tdr table, the two svrs write this field alternately, and the c field will not be cleared.
Assuming that abc is the secondary field of the tdr table, the two svrs write this field alternately, and the c field will be cleared.
2. How does TcaplusDB handle the request delay?
If the request does not respond within 3 s, TcaplusDB will print the error log containing the keyword timeout; It is recommended to add timeout logic or retry times in the client request code.
3. How does TcaplusDB ensure the stability of read and write requests?
TcaplusDB adopts the Master-Slave mode by default. The master is responsible for reading and writing user requests, and the slave functions as the hot standby node. When the QPS suddenly increases, the read/write split will be automatically enabled, which means that the master will be responsible for writing and the slave will be responsible for reading until the background expansion is complete.
4. Does TcaplusDB support retention policy?
Yes, TcaplusDB will retain all data by default. Users can set the time to live (TTL). When data expires, it will be automatically eliminated. Currently, it is supported by work orders.
5. Does TcaplusDB support cross-region migration?
Yes, TcaplusDB supports both hot migration (using cross-zone hot standby) and cold migration, supports data export as Json files, and supports MySQL data import into TcaplusDB. Currently, these are supported by work orders.
6. How does TcaplusDB ensure hot data?
TcaplusDB uses LRU cache algorithm to ensure data fever.
7. How does TcaplusDB store player data?
A TcaplusDB record is the data of a single player, which is operated according to the primary key field or index.
8. Can indexes be added or primary keys changed after the TcaplusDB table is created?
No, please rebuild the table if necessary.
9. Can TcaplusDB support transactions?
Not yet. It is recommended to define the relevant fields in the same table for operation to obtain the experience of similar transactions.
10. Does it guarantee that the asynchronous request-related responses in a thread will be processed in order? Is is necessary to use syncld for synchronization? (In the case of function-based without using synchronization api)
In the same thread, the read and write operations of the same key are processed in order, that is, the order is guaranteed. The order of read and write operations for different keys is not guaranteed. If the project team uses asyncid to mark the mapping relationship between request and response, it can be guaranteed. This is a transparent field, including asyncid, sequence, and userbuff.
11. How about the delete performance? Whether it requires the update command instead of delete?
Delete is a normal write operation. There is no problem in performance. The project team can delete at any time.
12. Threads and concurrency
The TcaplusDB API is single-threaded and does not support multi-threading. A tcaplus api object corresponds to a request and response. Since the TcaplusDB API is non-thread-safe, the same TcaplusDB API object cannot be used by multiple threads. If the concurrency scenario needs to be implemented, it is recommended that a single thread use a single TcaplusDB API object. From the perspective of online operation, it is sufficient to maintain 1 to 2 TcaplusDB API instances on a single machine. The qps of a TcaplusDB API instance can reach 70000 to 100000.
13. How about SDK memory usage?
A TcaplusDB API instance occupies about 200 MB of physical memory in static allocation mode. The memory is mainly consumed by the protocol, where the receiving and sending packets have separate structures, so some memory needs to be pre-allocated. Note: Due to the different size of a single record supported by different TcaplusDB API versions, the pre-allocated memory may be different.
14. Can the Tcaplus primary key be a structure? Or can it only be the base type?
It is not recommended to use the structure; because it is not convenient for the use of various tools or the positioning of the problem, rollback, or key provision.
15. Error 525 after requesting to read data
Generally, the backend has timed out. If the concurrency is large, it may be a communication problem between gameserver and tcaproxy, as follows:
- Whether tcaproxy is normal
- Whether the TcaplusDB API version number is greater than the access layer version number
- Whether the number of TCP connections of tcaproxy exceeds the limit
16. Is there a method that supports where when using distributed indexes to delete?
Distributed indexes can be used to read records out and then delete them one by one.
17. For the newly added table group, are the new global indexes of the corresponding table still in use after the data is rolled back? Is it necessary to add indexes again?
The distributed index can automatically maintain itself when inserting data. When we use the data import method, the data will be synchronized to the global index
18. If a table has more than one primary_key, is it possible to specify one of the primary_keys and delete its corresponding data?
Primary key: delete the corresponding data according to delete. Local index: delete the corresponding data according to deletebypartkey.
19. How to troubleshoot the problem that the telnet IP port can connect to the tcapdir address, but the connection to the database cluster fails?
- Telnet 9999 port
- Confirm whether it is Tencent cloud environment or ordinary cluster environment. Tencent cloud needs to connect to the client's own vip + 9999 port, and ordinary cluster needs to connect to the real dirip + 9999 port
- Because a cluster contains multiple dirs, it is preferable to obtain the api connection log in order to determine which dir failed to connect or to determine which dir failed to connect because the proxy version was higher than the api version.
20. Does Tcaplus support different protocols for different zones under a single app
Tcaplus supports different protocols for different zones under a single app, that is, the PB protocol for zone 1, and the TDR protocol for zone 2.
21. Does a table rebuild or deletion before adding a table affect the cache configuration?
The cache can be preserved for table rebuilds, but it cannot be preserved for table deletion before addition. This is because the cache will be deleted when the table is deleted.
22. Is it necessary to rebuild the table after adding columns?
You only need to execute online changes to add columns.
22. Is it necessary to rebuild the table after a count expansion in the table structure?
No, you can directly change it without adding the version number. The count can only be changed to be larger rather than smaller.
23. Is it necessary to change the version number of tables.xml after deleting a table or a certain row?
Yes. The existing table cannot delete fields but can only add them. If fields need to be deleted, the full table needs to be deleted and then rebuilt.
24. Is it possible for the app side's imperceptible dynamic adjustment to be supported by the blob's lengthening?
Yes, the count defines refer, and the count value can be modified to be large without increasing the version number.
25. Is it necessary to update the buffer after modifying the first-level fields?
If these fields do not need to be configured for buffering, do not change them. If they need to be configured, update the buffering configuration.
26. Redis replacement scenario
26.1 Is it possible for TcaplusDB to replace the pub/sub function of Redis?
Currently TcaplusDB does not have pub/sub function, but can use list table to simulate it. Process A writes data to the list table and Process B reads data from the list table, which will increase the cost of code transformation.
26.2 Is it possible for TcaplusDB to support the expired function of Redis (automatic expiration function)?
At present, TcaplusDB supports data expiration. For example, if the table is set to be expired within 30 days, the data without any write operation within 30 days will be expired, which is physical deletion. So, this function is supported.
26.3 TcaplusDB Client supports setttl. Does API also support it?
The TcaplusDB API supports setting setttl for single record. The project team's use scenario, on the other hand, can be set to full table data expiration, which means that hundreds of millions of records in a single table can be expired under a standard like no write operation within 30 days.
26.4 Is it possible to use the list table of tcaplus to replace the stored set function of Redis?
If it is TopN, use the list table to realize this function; that is, this function is supported.
26.5 Is there a pipeline like Redis that can process multiple queries with one request? For example, if there are 10 queries, one request can process 10 queries.
TcaplusDB provides batch operations to meet the requirements of similar scenarios. Please refer to the SDK for details: https://github.com/tencentyun/tcaplusdb-go-sdk/blob/v0.0.10/tdr/request/batchget_req.go
27. Index-increasing rules in the List table
- The idx starts from 0
- Each time the newly allocated idx increases automatically, until it reaches int32, and then loops back
- If the key is deleted, the idx starts from 0, or it can be kept from the last idx. It starts from 0 by default, or from the last idx by setting SetFlags
/*TCAPLUS_FLAG_LIST_RESERVE_INDEX_HAVING_NO_ELEMENTS
* After setting this flag, the index and version will be reserved when the last element in the List table is deleted.
* And the deletion operations involve ListDelete, ListDeleteBatch, and ListDeleteAll
* After setting this flag, when writing a new List record, the version number will increase in turn and will not be reset to 1.
*
* Application Scenario:
* The app needs to determine whether the index and version of a table need to be reserved when the last element is deleted
* Mostly involves List table usage experience
*
*/
int SetFlags(int32_t flag);
The index is discontinuous, but only increases. For example, 1 2 3 4 5 deletes 3 and becomes 1 2 4 5. If AddRecord (2), it becomes 1 2 6 4 5
- If all the list elements under the key are deleted, it is equivalent to that the key is also deleted
- Listaddafter supports the deletion of queue head and insertion of queue tail, or the insertion of queue head and deletion of queue tail
- listdelete deletes the idx
- TCAPLUS_API_LIST_PRE_FIRST_INDEX: The new element is inserted before the first element. TCAPLUS_API_LIST_LAST_INDEX: The new element is inserted after the last element
28. The upper limit of the increase-related interface. If the current value is 97 and the upper limit of increase5 is set to 100 at the same time, will it increase some of them successfully?
The update will not succeed, and the error code of SVR_ERR_FAIL_OUT_OF_USER_DEF_RANGE will be returned
29. In the process of tcaplus inserting a table, if the primary keys of the two insert operations are the same, will the second one overwrite the first one or will the second one fail?
The error code of -1293 SVR_ERR_FAIL_RECORD_EXIST will be reported during the second operation, that is, the record of insert already exists
30. Can tcaplus use all types that can be defined in the protoc file? Sush as the any type
Yes, but the conditional update does not support the any and union types
31. How to set the go sdk to traverse slave tables?
Call settings through SetOnlyReadFromSlave interface
32. ListGetAllRequest returns the error code of SVR_ERR_FAIL_INVALID_SUBSCRIPT
When pulling by offset and limit, the parameters may be incorrect. Please check the offset and limit parameter settings
33. How to create the local index and distributed index (global index)
The local index is defined in the table structure file. Once defined, it cannot be modified or deleted; The distributed index is created on the corresponding console page (OMS or Tencent Cloud console page) and can be modified and rebuilt
34. Does the distributed index (global index) support word segmentation fuzzy query of strings?
It supports like fuzzy query and does not support word segmentation query
35. Can the fields in the table definition be deleted?
Fields cannot be deleted from existing tables
36. For the add operation of the PB table, is there any way to return the existing data when the add data already exists?
Yes, set the option in the int SetMessageOption(const ::google::protobuf::Message &msg, int32_t item, const std::string &option) function to change the old data of all fields in the record. For details, refer to the function comments in the pb api of Chapter 9: TcaplusDB Download Center.
37. Does the TcaplusDB Go SDK support connecting to the directory server (Tcapdir) through a domain name?
Yes, the directory server (Tcapdir) can be connected through the domain name.
38. For the list structure of TcaplusDB, is there an interface to query only the number of elements in the list?
Currently, the size of a list cannot be queried