Hi, Nikita, On Jul 25, Nikita Malyavin wrote:
Regarding MDEV-31646 preserve DMLs in case of online binlog fault: It's changes are shown there as a part of ca64ddcc709, but it's important to point out that it's a separate thing: It is the commit that introduces error reporting to the ALTER thread, and its practically important only for a 32-bit build. I made it, but not sure if it's worth it. It complicates the architecture and brings many ad-hoc checks into the code.
What do you think?
let's drop this code then, please create a new MDEV about IO_CACHE on 32-bit.
On Thu, 20 Jul 2023 at 17:59, Sergei Golubchik <serg@mariadb.org> wrote:
On Jul 20, Nikita Malyavin wrote:
revision-id: ca64ddcc709 (mariadb-11.0.1-144-gca64ddcc709) parent(s): f34c7419cb8 author: Nikita Malyavin committer: Nikita Malyavin timestamp: 2023-07-19 02:31:32 +0400 message:
MDEV-31646 Online alter applies binlog cache limit to cache writes
diff --git a/sql/log.cc b/sql/log.cc index afd0643fe82..7466d63d325 100644 --- a/sql/log.cc +++ b/sql/log.cc @@ -2291,8 +2294,14 @@ int binlog_log_row_online_alter(TABLE* table, const uchar *before_record, before_record, after_record);
table->rpl_write_set= old_rpl_write_set; + thd->pop_internal_handler(); + + if (unlikely(error)) + push_warning_printf(thd, Sql_condition::WARN_LEVEL_NOTE, ER_DISK_FULL, + "Broken online alter log. " + "ALTER TABLE will finish with error.");
I don't think so. Why would a DML statement get a warning about the concurrently running ALTER TABLE? It didn't do anything wrong, I don't think there should be a warning here
Like, someone is running a series of DML statements, or the same statement many times. At some point another connection runs ALTER TABLE and suddenly those perfectly good DML statements start spewing out warnings. ALTER ends and all is clear again - looks wrong to me
Honestly I added this printf only to pass buildbot (unused `error`), and I don't want to leave the result unhandled.
The result should be handled, yes. One possible way to react on such a failure in the DML thread is to stop writing to table->online_alter_cache. May be even destroy it right away.
But you see, if for example server has binlog enabled, this perfect DML will simply fail! And this warning is about that some system limit is reached.
Yes. It's a warning that some other statement in a different thread, started by a different user or application, have failed. This user or application cannot do anything about it, likely they cannot even use this information in any sensible way. In this case I don't see a need to warn the user about what some other user is doing.
- return unlikely(error) ? HA_ERR_RBR_LOGGING_FAILED : 0; + return 0; }
static void @@ -3806,9 +3815,9 @@ bool MYSQL_BIN_LOG::open_index_file(const char *index_file_name_arg, }
-bool Event_log::open(enum cache_type io_cache_type_arg) +bool Event_log::open(enum cache_type io_cache_type_arg, size_t buffer_size) { - bool error= init_io_cache(&log_file, -1, LOG_BIN_IO_SIZE, io_cache_type_arg, + bool error= init_io_cache(&log_file, -1, buffer_size, io_cache_type_arg,
why? it's only used by online alter, where would you need a different buffer size? only in your DBUG_EXECUTE_IF?
Yes, only there.
in that case, it'd be cleaner not to add a new, rather unused, argument everywhere. if you need it for debugging, you can add DBUG_EXECUTE_IF() directly into Event_log::open().
0, 0, MYF(MY_WME | MY_NABP | MY_WAIT_IF_FULL));
log_state= LOG_OPENED;
@@ -7721,8 +7749,11 @@ static int binlog_online_alter_end_trans(THD *thd, bool all, bool commit) { DBUG_ASSERT(cache.cache_log.type != READ_CACHE); mysql_mutex_lock(binlog->get_log_lock()); - error= binlog->write_cache(thd, &cache.cache_log); + error= binlog->write_cache_raw(thd, &cache.cache_log); mysql_mutex_unlock(binlog->get_log_lock()); + + if (unlikely(error)) + binlog->set_write_error(my_errno);
shouldn't binlog->write_cache() call set_write_error() internally? why would the caller have to do it?
Wouldn't you bother if I'll move it to mf_iocache as smth like my_b_copy_cache?
Move what?
diff --git a/sql/log.h b/sql/log.h index 83e323cb6fb..39512b01991 100644 --- a/sql/log.h +++ b/sql/log.h @@ -444,17 +445,20 @@ class Event_log: public MYSQL_LOG std::atomic<uint> ref_count; + std::atomic<int> online_write_error; public:
Cache_flip_event_log() : Event_log(), alt_buf{}, - current(&log_file), alt(&alt_buf), ref_count(1) {} - bool open(enum cache_type io_cache_type_arg) + current(&log_file), alt(&alt_buf), ref_count(1), + online_write_error(0) {} + bool open(size_t buffer_size)
looks like Cache_flip_event_log::open() doesn't need any arguments at all
I don't want to put DBUG_EXECUTE_IF inside, because I'll have to either #include it in log.h, or move Cache_flip_event_log::open in some .cc.
Event_log::open() is already in some .cc, and that's the only place where you actually need this value, isn't it so? Regards, Sergei VP of MariaDB Server Engineering and security@mariadb.org