Update user-provided service instance failed with CF-DatabaseError
search cancel

Update user-provided service instance failed with CF-DatabaseError

book

Article ID: 298360

calendar_today

Updated On:

Products

VMware Tanzu Application Service for VMs

Issue/Introduction

A user-provided service instance has many keys already. When updating this service instance to add more keys, it fails with CF-DatabaseError.
update-cpus.png

And the following messages are found in cloud_controller logs.
{"timestamp":1669010956.3045118,"message":"Request failed: 500: {\"description\"=>\"Database error\", \"error_code\"=>\"CF-DatabaseError\", \"code\"=>10011, \"test_mode_info\"=>{\"descr
iption\"=>\"Database error\", \"error_code\"=>\"CF-DatabaseError\", ......

{"timestamp":1669010956.3013282,"message":"exception not translated: Sequel::DatabaseError - Mysql2::Error: Data too long for column 'credentials' at row 1:\\n/var/vcap/data/packages/cl
oud_controller_ng/0f1c9a33a39a999c95bb313d3396932df2d7968a/gem_home/ruby/2.7.0/gems/mysql2-0.5.3/lib/mysql2/client.rb:131:in `_query' ......


Environment

Product Version: 2.11

Resolution

Since the service instance is updated with adding more keys, Mysql2::Error: Data too long for column 'credentials' should indicate column 'credentials' in database table has no space to store more keys. 

By reviewing database table schema it's shown that 'credentials' column is defined as 'text' type, which can store up to 64KB (65536) chars
mysql> desc service_instances;
+-----------------------+----------------+------+-----+---------------------+----------------+
| Field                 | Type           | Null | Key | Default             | Extra          |
+-----------------------+----------------+------+-----+---------------------+----------------+
| id                    | int(11)        | NO   | PRI | NULL                | auto_increment |
......
| credentials           | text           | YES  |     | NULL                |                |
......
You might see the size of input data is less than 64 KB. However the content of input data will be encrypted and stored into 'credentials' column, which means the encrypted data size will be bigger than its original size. You can check the current length of 'credentials' column for problematic service instance. For example,
$ bosh -d cf-xxxx ssh mysql/0
$ sudo mysql --defaults-file=/var/vcap/jobs/pxc-mysql/config/mylogin.cnf ccdb

mysql> select id from service_instances where name='test';
+----+
| id |
+----+
| 45 |
+----+

mysql> select length(credentials) from service_instances where id=45;
+---------------------+
| length(credentials) |
+---------------------+
|               65516 |
+---------------------+

mysql> exit
Bye
Note: Do NOT run any other SQL statement to update data in database

As you can see the current length of is 'credentials' column in this example is 65516 bytes, which is very close to its capacity 65536 bytes. So adding even a few more data might reach to the 64KB capacity. 

Since 64KB is a hard limit of 'credentials' column with current design, it can't be changed through configuration parameter. So the solution for the issue is either creating a new user-provided service instance or deleting some unused keys from existing service instance.