mirror of
https://github.com/MariaDB/server.git
synced 2025-08-01 03:47:19 +03:00
remove handler::open_read_view()
ht->start_consistent_snapshot() is also not a way, because some engines (e.g. rocksdb) only do it readonly. instead, downgrade the lock after reading the first row (which implicitly opens a read view).
This commit is contained in:
@ -3562,7 +3562,6 @@ public:
|
|||||||
/** to be actually called to get 'check()' functionality*/
|
/** to be actually called to get 'check()' functionality*/
|
||||||
int ha_check(THD *thd, HA_CHECK_OPT *check_opt);
|
int ha_check(THD *thd, HA_CHECK_OPT *check_opt);
|
||||||
int ha_repair(THD* thd, HA_CHECK_OPT* check_opt);
|
int ha_repair(THD* thd, HA_CHECK_OPT* check_opt);
|
||||||
virtual void open_read_view(){}
|
|
||||||
void ha_start_bulk_insert(ha_rows rows, uint flags= 0)
|
void ha_start_bulk_insert(ha_rows rows, uint flags= 0)
|
||||||
{
|
{
|
||||||
DBUG_ENTER("handler::ha_start_bulk_insert");
|
DBUG_ENTER("handler::ha_start_bulk_insert");
|
||||||
|
@ -11623,52 +11623,11 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
|
|||||||
*/
|
*/
|
||||||
thd_progress_init(thd, MY_TEST(order) + 2 + 2 * MY_TEST(online));
|
thd_progress_init(thd, MY_TEST(order) + 2 + 2 * MY_TEST(online));
|
||||||
|
|
||||||
#ifdef HAVE_REPLICATION
|
|
||||||
if (online)
|
|
||||||
{
|
|
||||||
from->s->online_alter_binlog= new (thd->mem_root) Cache_flip_event_log();
|
|
||||||
if (!from->s->online_alter_binlog)
|
|
||||||
DBUG_RETURN(1);
|
|
||||||
|
|
||||||
from->s->online_alter_binlog->init_pthread_objects();
|
|
||||||
|
|
||||||
error= from->s->online_alter_binlog->open(WRITE_CACHE);
|
|
||||||
|
|
||||||
if (!error)
|
|
||||||
{
|
|
||||||
/*
|
|
||||||
Some engines (for example, InnoDB) might not create a read view
|
|
||||||
until the first row is read. We need to be sure that we won't see any
|
|
||||||
table changes after we enable replication and downgrade the MDL.
|
|
||||||
So, we force the consistent snapshot to be created now.
|
|
||||||
*/
|
|
||||||
handlerton *ht= from->s->db_type();
|
|
||||||
if (ht->start_consistent_snapshot)
|
|
||||||
{
|
|
||||||
thd->tx_isolation= ISO_REPEATABLE_READ;
|
|
||||||
from->file->open_read_view();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (error)
|
|
||||||
{
|
|
||||||
online_alter_cleanup_binlog(thd, from->s);
|
|
||||||
DBUG_RETURN(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
from->mdl_ticket->downgrade_lock(MDL_SHARED_UPGRADABLE);
|
|
||||||
DEBUG_SYNC(thd, "alter_table_online_downgraded");
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
DBUG_ASSERT(!online);
|
|
||||||
#endif // HAVE_REPLICATION
|
|
||||||
|
|
||||||
if (!(copy= new (thd->mem_root) Copy_field[to->s->fields]))
|
if (!(copy= new (thd->mem_root) Copy_field[to->s->fields]))
|
||||||
DBUG_RETURN(-1);
|
DBUG_RETURN(-1);
|
||||||
|
|
||||||
if (mysql_trans_prepare_alter_copy_data(thd))
|
if (mysql_trans_prepare_alter_copy_data(thd))
|
||||||
{
|
{
|
||||||
online_alter_cleanup_binlog(thd, from->s);
|
|
||||||
delete [] copy;
|
delete [] copy;
|
||||||
DBUG_RETURN(-1);
|
DBUG_RETURN(-1);
|
||||||
}
|
}
|
||||||
@ -11676,7 +11635,6 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
|
|||||||
/* We need external lock before we can disable/enable keys */
|
/* We need external lock before we can disable/enable keys */
|
||||||
if (to->file->ha_external_lock(thd, F_WRLCK))
|
if (to->file->ha_external_lock(thd, F_WRLCK))
|
||||||
{
|
{
|
||||||
online_alter_cleanup_binlog(thd, from->s);
|
|
||||||
/* Undo call to mysql_trans_prepare_alter_copy_data() */
|
/* Undo call to mysql_trans_prepare_alter_copy_data() */
|
||||||
ha_enable_transaction(thd, TRUE);
|
ha_enable_transaction(thd, TRUE);
|
||||||
delete [] copy;
|
delete [] copy;
|
||||||
@ -11822,9 +11780,31 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
|
|||||||
if (!ignore) /* for now, InnoDB needs the undo log for ALTER IGNORE */
|
if (!ignore) /* for now, InnoDB needs the undo log for ALTER IGNORE */
|
||||||
to->file->extra(HA_EXTRA_BEGIN_ALTER_COPY);
|
to->file->extra(HA_EXTRA_BEGIN_ALTER_COPY);
|
||||||
|
|
||||||
DEBUG_SYNC(thd, "alter_table_copy_start");
|
if (!(error= info.read_record()))
|
||||||
|
{
|
||||||
|
#ifdef HAVE_REPLICATION
|
||||||
|
if (online)
|
||||||
|
{
|
||||||
|
from->s->online_alter_binlog= new (thd->mem_root) Cache_flip_event_log();
|
||||||
|
if (!from->s->online_alter_binlog)
|
||||||
|
DBUG_RETURN(1);
|
||||||
|
from->s->online_alter_binlog->init_pthread_objects();
|
||||||
|
error= from->s->online_alter_binlog->open(WRITE_CACHE);
|
||||||
|
|
||||||
while (likely(!(error= info.read_record())))
|
if (error)
|
||||||
|
{
|
||||||
|
online_alter_cleanup_binlog(thd, from->s);
|
||||||
|
goto err;
|
||||||
|
}
|
||||||
|
|
||||||
|
from->mdl_ticket->downgrade_lock(MDL_SHARED_UPGRADABLE);
|
||||||
|
DEBUG_SYNC(thd, "alter_table_online_downgraded");
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
DBUG_ASSERT(!online);
|
||||||
|
#endif // HAVE_REPLICATION
|
||||||
|
|
||||||
|
do
|
||||||
{
|
{
|
||||||
if (unlikely(thd->killed))
|
if (unlikely(thd->killed))
|
||||||
{
|
{
|
||||||
@ -11956,7 +11936,10 @@ copy_data_between_tables(THD *thd, TABLE *from, TABLE *to,
|
|||||||
mysql_stage_set_work_completed(thd->m_stage_progress_psi, found_count);
|
mysql_stage_set_work_completed(thd->m_stage_progress_psi, found_count);
|
||||||
}
|
}
|
||||||
thd->get_stmt_da()->inc_current_row_for_warning();
|
thd->get_stmt_da()->inc_current_row_for_warning();
|
||||||
|
} while (!(error= info.read_record()));
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
online= false;
|
||||||
|
|
||||||
DEBUG_SYNC(thd, "alter_table_copy_end");
|
DEBUG_SYNC(thd, "alter_table_copy_end");
|
||||||
|
|
||||||
|
@ -21165,17 +21165,3 @@ buf_pool_size_align(
|
|||||||
return (size / m + 1) * m;
|
return (size / m + 1) * m;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ha_innobase::open_read_view()
|
|
||||||
{
|
|
||||||
trx_t *trx= m_prebuilt->trx;
|
|
||||||
auto thd_iso= thd_get_trx_isolation(m_user_thd);
|
|
||||||
|
|
||||||
trx->isolation_level= innobase_map_isolation_level(thd_iso);
|
|
||||||
ut_ad(trx->isolation_level == TRX_ISO_REPEATABLE_READ);
|
|
||||||
ut_ad(!trx_is_started(trx));
|
|
||||||
|
|
||||||
trx_start_if_not_started_xa(trx, false);
|
|
||||||
|
|
||||||
trx->read_view.open(m_prebuilt->trx);
|
|
||||||
}
|
|
||||||
|
@ -438,7 +438,6 @@ public:
|
|||||||
const KEY_PART_INFO& old_part,
|
const KEY_PART_INFO& old_part,
|
||||||
const KEY_PART_INFO& new_part) const override;
|
const KEY_PART_INFO& new_part) const override;
|
||||||
|
|
||||||
void open_read_view() override;
|
|
||||||
protected:
|
protected:
|
||||||
bool
|
bool
|
||||||
can_convert_string(const Field_string* field,
|
can_convert_string(const Field_string* field,
|
||||||
|
Reference in New Issue
Block a user