[MDEV-16096] system versioning by trx id doesn't seem to work properly Created: 2018-05-06  Updated: 2018-05-07  Resolved: 2018-05-07

Status: Closed
Project: MariaDB Server
Component/s: Versioned Tables
Affects Version/s: 10.3.6
Fix Version/s: N/A

Type: Bug Priority: Major
Reporter: Axel Schwenke Assignee: Sergei Golubchik
Resolution: Duplicate Votes: 0
Labels: None

Issue Links:
Duplicate
duplicates MDEV-15412 For any non-existing transaction ID, ... Closed

 Description   

Test case:

MariaDB [test]> CREATE TABLE `t3` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `start_trxid` bigint(20) unsigned GENERATED ALWAYS AS ROW START,
  `end_trxid` bigint(20) unsigned GENERATED ALWAYS AS ROW END,
  PRIMARY KEY (`id`),
  PERIOD FOR SYSTEM_TIME (`start_trxid`, `end_trxid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 WITH SYSTEM VERSIONING;
 
MariaDB [test]> insert into t3 (id) select NULL from seq_1_to_1000000;
Query OK, 1000000 rows affected (3.45 sec)
Records: 1000000  Duplicates: 0  Warnings: 0
 
MariaDB [test]> select now(); delete from t3;
+---------------------+
| now()               |
+---------------------+
| 2018-05-06 11:51:57 |
+---------------------+
1 row in set (0.00 sec)
 
Query OK, 1000000 rows affected (7.61 sec)
 
MariaDB [test]> select * from t3 where id=1000;
Empty set (0.01 sec)
 
MariaDB [test]> select * from t3 for system_time as of 
TIMESTAMP'2018-05-06 11:51:57' where id=1000;
+------+-------------+-----------+
| id   | start_trxid | end_trxid |
+------+-------------+-----------+
| 1000 |         115 |       126 |
+------+-------------+-----------+
1 row in set (0.00 sec)

Question 1: the KB does not mention that timestamps are stored along transaction ids. It's also not obvious where the timestamps are stored (not in the table, obviously) nor how InnoDB finds the correspondence between time and trx id.

No we know that row existed between trx 115 and 126. Lets query by trx id:

MariaDB [test]> select * from t3 for system_time as of transaction 120 
where id=1000;
Empty set (0.00 sec)
 
MariaDB [test]> select * from t3 for system_time as of transaction 115 
where id=1000;
+------+-------------+-----------+
| id   | start_trxid | end_trxid |
+------+-------------+-----------+
| 1000 |         115 |       126 |
+------+-------------+-----------+
1 row in set (0.00 sec)

Question 2: the start/end_trxid columns suggest that the row existed for transactions 115 to 126. But it is returned just for 115. How comes?

Conclusion: the feature is at least underdocumented and behaves in unexpected ways.



 Comments   
Comment by Elena Stepanova [ 2018-05-06 ]

Some notes:

1) about documentation for timestamps storage: mysql.transaction_registry was in fact documented recently, in scope of MDEV-15963, here: https://mariadb.com/kb/en/library/mysqltransaction_registry-table/ , and it's linked from the main system versioning page. However, I agree that linking them could be more obvious.

2) about non-existing trx ids: it is not this smart (for now, at least), it only works with existing transaction id, doesn't estimate what could have been for those that don't exist. It's an open issue in progress: MDEV-15412.

Comment by Axel Schwenke [ 2018-05-07 ]

Thanks elenst - I close this as duplicate of MDEV-15412

Generated at Thu Feb 08 08:26:21 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.