MySQL 26.7.0
Source Code Documentation
fil0innodb_tablespace_node_handle.h
Go to the documentation of this file.
1/* Copyright (c) 2022, 2026, Oracle and/or its affiliates.
2
3This program is free software; you can redistribute it and/or modify it under
4the terms of the GNU General Public License, version 2.0, as published by the
5Free Software Foundation.
6
7This program is designed to work with certain software (including
8but not limited to OpenSSL) that is licensed under separate terms,
9as designated in a particular file or component or in included license
10documentation. The authors of MySQL hereby grant you an additional
11permission to link the program and your derivative works with the
12separately licensed software that they have either included with
13the program or referenced in the documentation.
14
15This program is distributed in the hope that it will be useful, but WITHOUT
16ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
18for more details.
19
20You should have received a copy of the GNU General Public License along with
21this program; if not, write to the Free Software Foundation, Inc.,
2251 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23*/
24
25#pragma once
26
27#include <span>
29namespace ib::fil {
30
32 public:
34 space_id_t space_id, size_t page_size,
35 size_t node_order);
36
37 ~Tablespace_node_handle() override;
38
39 [[nodiscard]] bool needs_flushes_for_durability() const override;
40
41 [[nodiscard]] Status flush() override;
42
43 [[nodiscard]] Status truncate(Page_number size) override;
44
45 [[nodiscard]] Status fill_range_with_zeros(Page_number first_page,
46 Page_number number_of_pages,
47 bool optimize_writes) override;
48
49 [[nodiscard]] Status_IO read_page(IORequest req, byte *buffer,
50 Page_number page_no) override;
51
52#ifndef UNIV_HOTBACKUP
53 [[nodiscard]] Status_IO read_page_async(IORequest req, byte *buffer,
54 Page_number page_no,
55 Callback callback) override;
56#endif /* !UNIV_HOTBACKUP */
57
58 [[nodiscard]] Status_IO write_page(IORequest req, byte *buffer,
59 size_t buffer_len,
60 Page_number page_no) override;
61
62#ifdef UNIV_LINUX
63 [[nodiscard]] Status_IO write_pages(std::span<const byte *> buffers,
64 Page_number first_page_number) override;
65#endif /* UNIV_LINUX */
66
67#ifndef UNIV_HOTBACKUP
68 [[nodiscard]] Status_IO write_page_async(IORequest req, byte *buffer,
69 size_t buffer_len,
70 Page_number page_no,
71 Callback callback) override;
72#endif /* !UNIV_HOTBACKUP */
73
74 private:
75#ifndef UNIV_HOTBACKUP
76 /** Checks if the page read by a successful asynchronous read contains the
77 space and page IDs that were meant to be read and in case they are not, try a
78 few times to read them synchronously from disk.
79 @param[in] req IO request.
80 @param[in] offset An offset in bytes in the tablespace the read was
81 requested for.
82 @param[out] buffer A buffer where to read the data in.
83 @param[in] page_no Offset from the first page in the node to read
84 from.
85 @param[in,out] io_result Reference to the error code of the IO operation, it
86 will be have the value changed to result of last
87 read IO operation executed. */
89 uint64_t offset,
90 byte *buffer,
91 page_no_t page_no,
92 dberr_t &io_result);
93#endif /* !UNIV_HOTBACKUP */
94 /** Maps DB error code to Status_IO error code. */
95 [[nodiscard]] static Status_IO map_db_err_to_status_io(dberr_t err);
96
97 /** Opened tablespace file handle. */
99
100 /** Tablespace file name. */
101 const std::string m_file_name;
102
103 /** Tablespace ID. */
105
106 /** Physical size of a page. Needed to calculate the file offset for I/O. */
108
109 /** Number of the node in the tablespace. */
110 const size_t m_node_order;
111};
112
113} /* namespace ib::fil */
uint32_t space_id_t
Tablespace identifier.
Definition: api0api.h:49
uint32_t page_no_t
Page number.
Definition: api0api.h:47
Class that stores callback function reference as well as the result of the callback function call (in...
Definition: keyring_service.cc:44
Types for AIO operations.
Definition: os0file.h:262
Definition: fil0tablespace_node_handle_interface.h:35
Status_IO
Definition: fil0tablespace_node_handle_interface.h:79
uint32_t Page_number
Type used for numbering the pages in the node.
Definition: fil0tablespace_node_handle_interface.h:42
Status
Definition: fil0tablespace_node_handle_interface.h:39
Definition: fil0innodb_tablespace_node_handle.h:31
Status truncate(Page_number size) override
Truncate the node storage to the given size.
Definition: fil0innodb_tablespace_node_handle.cc:65
Status fill_range_with_zeros(Page_number first_page, Page_number number_of_pages, bool optimize_writes) override
Makes the number_of_pages pages, starting with page number first_page contain all zeros.
Definition: fil0innodb_tablespace_node_handle.cc:76
const std::string m_file_name
Tablespace file name.
Definition: fil0innodb_tablespace_node_handle.h:101
static Status_IO map_db_err_to_status_io(dberr_t err)
Maps DB error code to Status_IO error code.
Definition: fil0innodb_tablespace_node_handle.cc:96
bool needs_flushes_for_durability() const override
Returns true if the node must be flushed in general to ensure data durability.
Definition: fil0innodb_tablespace_node_handle.cc:54
const pfs_os_file_t m_handle
Opened tablespace file handle.
Definition: fil0innodb_tablespace_node_handle.h:98
Tablespace_node_handle(pfs_os_file_t handle, const std::string &file_name, space_id_t space_id, size_t page_size, size_t node_order)
Definition: fil0innodb_tablespace_node_handle.cc:37
Status_IO read_page_async(IORequest req, byte *buffer, Page_number page_no, Callback callback) override
Reads a requested page asynchronously.
Definition: fil0innodb_tablespace_node_handle.cc:133
Status_IO write_page(IORequest req, byte *buffer, size_t buffer_len, Page_number page_no) override
Writes a requested page synchronously.
Definition: fil0innodb_tablespace_node_handle.cc:156
Status flush() override
Ensures any data written so far to this tablespace node before this call will be made durable and wil...
Definition: fil0innodb_tablespace_node_handle.cc:58
~Tablespace_node_handle() override
Definition: fil0innodb_tablespace_node_handle.cc:48
Status_IO read_page(IORequest req, byte *buffer, Page_number page_no) override
Reads a requested page synchronously.
Definition: fil0innodb_tablespace_node_handle.cc:121
const size_t m_node_order
Number of the node in the tablespace.
Definition: fil0innodb_tablespace_node_handle.h:110
Status_IO write_page_async(IORequest req, byte *buffer, size_t buffer_len, Page_number page_no, Callback callback) override
Writes a requested page asynchronously.
Definition: fil0innodb_tablespace_node_handle.cc:214
const space_id_t m_space_id
Tablespace ID.
Definition: fil0innodb_tablespace_node_handle.h:104
void retry_read_a_few_times_if_page_id_seems_wrong(IORequest req, uint64_t offset, byte *buffer, page_no_t page_no, dberr_t &io_result)
Checks if the page read by a successful asynchronous read contains the space and page IDs that were m...
Definition: fil0innodb_tablespace_node_handle.cc:229
const size_t m_physical_page_size
Physical size of a page.
Definition: fil0innodb_tablespace_node_handle.h:107
dberr_t
Definition: db0err.h:39
Definition: fil0fil.cc:1392
static Value err()
Create a Value object that represents an error condition.
Definition: json_binary.cc:943
std::string file_name(Log_file_id file_id)
Provides name of the log file with the given file id, e.g.
Definition: log0pre_8_0_30.cc:45
size_t size(const char *const c)
Definition: base64.h:46
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
static int handle(int sql_errno, const char *sqlstate, const char *message, void *state)
Bridge function between the C++ API offered by this module and the C API of the parser service.
Definition: services.cc:64
Common file descriptor for file IO instrumentation with PFS on windows and other platforms.
Definition: os0file.h:172