Bug #74471 most rollback segments may always be created in first undo tablespace
Submitted: 21 Oct 2014 5:18 Modified: 23 Apr 2015 0:38
Reporter: zhai weixiang (OCA) Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Documentation Severity:S3 (Non-critical)
Version:5.7.5 OS:Any
Assigned to: Daniel Price CPU Architecture:Any

[21 Oct 2014 5:18] zhai weixiang
Description:
While  reading  the new code of MySQL5.7.5 . I found that innodb always try to create new rollback segment starting from the first undo tablespace:

quoted code from function:
trx_sys_create_rsegs:

 876
 877                 for (i = 0; i < new_rsegs; ++i) {
 878                         ulint   space;
 879
 880                         /* Tablespace 0 is the system tablespace. All UNDO
 881                         log tablespaces start from 1. */
 882
 883                         if (n_spaces > 0) {
 884                                 space = (i % n_spaces) + 1;
 885                         } else {
 886                                 space = 0; /* System tablespace */
 887                         }
 888
 889                         if (trx_rseg_create(space, 0) != NULL) {
 890                                 ++n_used;

Suppose we increase innodb_undo_logs one by one, then here  new_rsegs= 1, and obviously  all increased rollback segments will be inside the first undo tablespace.

How to repeat:
read the code or add some debug information in trx_sys_create_rsegs

Suggested fix:
I don't know
[4 Nov 2014 3:36] zhai weixiang
Can anyone take a look of this bug ? I think this may lead to online undo truncate unusable
[10 Feb 2015 16:28] MySQL Verification Team
Actually, this is not a bug in the code.

InnoDB can use several undo log files, but it will move to the next one only if all previous ones have been filled.

In the future, it will be possible to tie one or more log files to a specific tablespace, containing one or more tables. But, it is not yet possible.

I find that manual is not too clear on this subject, so I can verify this as a documentation bug. I hope you agree with this decision.
[15 Feb 2015 5:48] zhai weixiang
Agreed this behavior should be clarified in the document :)
[16 Feb 2015 13:41] MySQL Verification Team
Documentation on InnoDB usage of undo tablespaces has to be improved and extended.
[23 Apr 2015 0:38] Daniel Price
The innodb_undo_tablespaces option must be configured when the MySQL instance
is created. Otherwise, there is only the undo space in the system tablespace,
and that is where any additional rollback segments (i.e. undo logs) will be
allocated (space 0).

Also note that in MySQL 5.7.2, 32 rollback segments were allocated to the
temporary table tablespace (ibtmp1). Consequently, you must set
innodb_undo_logs=34 or more to allocate a rollback segment to an undo tablespace.

Please refer to this documentation for information about undo tablespace
setup and configuration. Revisions to this content should appear within
24-hours.

http://dev.mysql.com/doc/refman/5.7/en/innodb-undo-tablespace.html

Specific requirements regarding truncating undo logs that reside in undo
tablespaces are documented here:
http://dev.mysql.com/doc/refman/5.7/en/truncate-undo-tablespace.html