While investigating an issue, I came across this error:
30503 [ERROR] InnoDB: Attempted to open a previously opened tablespace. Previous tablespace mysql/innodb_index_stats uses space ID: 2 at filepath: ./mysql/innodb_index_stats.ibd. Cannot open tablespace Mydb/be_command_log which uses space ID: 2 at filepath: ./Mydb/be_command_log.ibd
After reading a bit about this issue, I came to know that this is a known issue of MySQL.
But my problem is that I don't know much about how tablespaces really work. How are they useful? I read this definition, but it does not give all the information.
Can someone share some detailed information about what are tablespaces and how do they work?
Each tablespace in an Oracle database is comprised of one or more operating system files called datafiles. A tablespace's datafiles physically store the associated database data on disk. A database's data is collectively stored in the datafiles that constitute each tablespace of the database.
What is an Oracle Tablespace. Oracle divides a database into one or more logical storage units called tablespaces. Each tablespace consists of one or more files called datafiles. A datafile physically stores the data objects of the database such as tables and indexes on disk.
The tablespace is where tables gets stored. It links the physical storage layer (files on disks) and the logical storage layer (tables, indexes).
There are three types of tablespaces: Permanent. You use permanent tablespaces to store your user and application data. Oracle Database uses permanent tablespaces to store permanent data, such as system data. Each user is assigned a default permanent tablespace.
A data file that can hold data for one or more InnoDB tables and associated indexes.
There are many types of tablespaces based on the configuration w.r.t the information clubbing per table. These are,
a. System tablespace b. File per tablespace c. General tablespace
System tablespace contains,
Apart from this it also contains,
Associated file is .idbdata1
The innodb_file_per_table option, which is enabled by default in MySQL 5.6 and higher, allows tables to be created in file-per-table tablespaces, with a separate data file for each table. Enabling the innodb_file_per_table option makes available other MySQL features such as table compression and transportable tablespaces.
Associated file is .idbd
InnoDB introduced general tablespaces in MySQL 5.7.6. General tablespaces are shared tablespaces created using CREATE TABLESPACE syntax. They can be created outside of the MySQL data directory, are capable of holding multiple tables, and support tables of all row formats.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With