Hello Sergei!

On Sun, 19 Jan 2025 at 14:39, Sergei Golubchik <serg@mariadb.org> wrote:
Hi, Nikita,

On Jan 19, Nikita Malyavin wrote:
> revision-id: 0b403e03939 (mariadb-11.7.1-16-g0b403e03939)
> parent(s): 40e502eca4c
> author: Nikita Malyavin
> committer: Nikita Malyavin
> timestamp: 2025-01-03 00:54:52 +0100
> message:
>
> MDEV-35661 Assertion `!cache_list ||...' fails in
> online_alter_close_connection
>
> After MDEV-35182 (88adcbf3) fix, online_alter still wasn't fully ready
> for `XA PREPARE` to be skipped.
>
> In fact, according to XA standard, even xa_commit() call may happen
> without preceding xa_prepare(), so this stage is completely optional.
>
> This commit removes any relying on xa_prepare() call. The only thing
> that will be done there is an equivalent of "statement-level commit",
> which basically just flushes a pending rows event to an online alter
> cache.
>
> This is done by always storing an online alter cache in the XA_data
> object whenever XA is active, rather than in THD::ha_data.

Why? I thought it'd be simpler to keep the cache in the THD and take it
off it in commit or rollback. That is, almost as now, but
commit/rollback won't rely on prepare being called before.

Basically because the XA can be orphaned. Then there'll be no connection to THD, when it'll be committed, or rolled back. Having xa_prepare optional (there's also XA COMMIT ONE PHASE) complicates the correct search deduction rule, so I think it's just better to always store it in the XA object.


--
Yours truly,
Nikita Malyavin