~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/lock/lock0lock.c

  • Committer: Andrew Hutchings
  • Date: 2010-12-09 13:44:51 UTC
  • mfrom: (1986 real-trunk)
  • mto: This revision was merged to the branch mainline in revision 2006.
  • Revision ID: andrew@linuxjedi.co.uk-20101209134451-hsu1l98ks2pwvucu
Merge trunk into branch

Show diffs side-by-side

added added

removed removed

Lines of Context:
466
466
        /* A sanity check: the trx_id in rec must be smaller than the global
467
467
        trx id counter */
468
468
 
469
 
        if (ut_dulint_cmp(trx_id, trx_sys->max_trx_id) >= 0) {
 
469
        if (UNIV_UNLIKELY(trx_id >= trx_sys->max_trx_id)) {
470
470
                ut_print_timestamp(stderr);
471
471
                fputs("  InnoDB: Error: transaction id associated"
472
472
                      " with record\n",
479
479
                        " global trx id counter " TRX_ID_FMT "!\n"
480
480
                        "InnoDB: The table is corrupt. You have to do"
481
481
                        " dump + drop + reimport.\n",
482
 
                        TRX_ID_PREP_PRINTF(trx_id),
483
 
                        TRX_ID_PREP_PRINTF(trx_sys->max_trx_id));
 
482
                        trx_id, trx_sys->max_trx_id);
484
483
 
485
484
                is_ok = FALSE;
486
485
        }
554
553
        }
555
554
 
556
555
        max_trx_id = page_get_max_trx_id(page_align(rec));
557
 
        ut_ad(!ut_dulint_is_zero(max_trx_id));
 
556
        ut_ad(max_trx_id);
558
557
 
559
 
        return(ut_dulint_cmp(max_trx_id, view->up_limit_id) < 0);
 
558
        return(max_trx_id < view->up_limit_id);
560
559
}
561
560
 
562
561
/*********************************************************************//**
1592
1591
        max trx id to the log, and therefore during recovery, this value
1593
1592
        for a page may be incorrect. */
1594
1593
 
1595
 
        if (!(ut_dulint_cmp(page_get_max_trx_id(page),
1596
 
                            trx_list_get_min_trx_id()) >= 0)
 
1594
        if (page_get_max_trx_id(page) < trx_list_get_min_trx_id()
1597
1595
            && !recv_recovery_is_on()) {
1598
1596
 
1599
1597
                return(NULL);
1818
1816
 
1819
1817
#ifdef UNIV_DEBUG
1820
1818
        if (lock_print_waits) {
1821
 
                fprintf(stderr, "Lock wait for trx %lu in index ",
1822
 
                        (ulong) ut_dulint_get_low(trx->id));
 
1819
                fprintf(stderr, "Lock wait for trx " TRX_ID_FMT " in index ",
 
1820
                        trx->id);
1823
1821
                ut_print_name(stderr, trx, FALSE, index->name);
1824
1822
        }
1825
1823
#endif /* UNIV_DEBUG */
2191
2189
 
2192
2190
#ifdef UNIV_DEBUG
2193
2191
        if (lock_print_waits) {
2194
 
                fprintf(stderr, "Lock wait for trx %lu ends\n",
2195
 
                        (ulong) ut_dulint_get_low(lock->trx->id));
 
2192
                fprintf(stderr, "Lock wait for trx " TRX_ID_FMT " ends\n",
 
2193
                        lock->trx->id);
2196
2194
        }
2197
2195
#endif /* UNIV_DEBUG */
2198
2196
 
3480
3478
                                }
3481
3479
#endif /* UNIV_DEBUG */
3482
3480
 
3483
 
                                if (trx_weight_cmp(wait_lock->trx,
3484
 
                                                   start) >= 0) {
 
3481
                                if (trx_weight_ge(wait_lock->trx, start)) {
3485
3482
                                        /* Our recursion starting point
3486
3483
                                        transaction is 'smaller', let us
3487
3484
                                        choose 'start' as the victim and roll
3741
3738
                /* Deadlock resolution chose another transaction as a victim,
3742
3739
                and we accidentally got our lock granted! */
3743
3740
 
3744
 
                return(DB_SUCCESS);
 
3741
                return(DB_SUCCESS_LOCKED_REC);
3745
3742
        }
3746
3743
 
3747
3744
        trx->que_state = TRX_QUE_LOCK_WAIT;
3810
3807
 
3811
3808
        if (flags & BTR_NO_LOCKING_FLAG) {
3812
3809
 
3813
 
                return(DB_SUCCESS);
 
3810
                return(DB_SUCCESS_LOCKED_REC);
3814
3811
        }
3815
3812
 
3816
3813
        ut_a(flags == 0);
4017
4014
                        ut_ad(lock_get_type_low(lock) & LOCK_TABLE);
4018
4015
 
4019
4016
                        if (lock_get_mode(lock) != LOCK_IS
4020
 
                            && !ut_dulint_is_zero(trx->undo_no)) {
 
4017
                            && trx->undo_no != 0) {
4021
4018
 
4022
4019
                                /* The trx may have modified the table. We
4023
4020
                                block the use of the MySQL query cache for
4216
4213
        fputs("TABLE LOCK table ", file);
4217
4214
        ut_print_name(file, lock->trx, TRUE,
4218
4215
                      lock->un_member.tab_lock.table->name);
4219
 
        fprintf(file, " trx id " TRX_ID_FMT,
4220
 
                TRX_ID_PREP_PRINTF(lock->trx->id));
 
4216
        fprintf(file, " trx id " TRX_ID_FMT, lock->trx->id);
4221
4217
 
4222
4218
        if (lock_get_mode(lock) == LOCK_S) {
4223
4219
                fputs(" lock mode S", file);
4270
4266
                (ulong) space, (ulong) page_no,
4271
4267
                (ulong) lock_rec_get_n_bits(lock));
4272
4268
        dict_index_name_print(file, lock->trx, lock->index);
4273
 
        fprintf(file, " trx id " TRX_ID_FMT,
4274
 
                TRX_ID_PREP_PRINTF(lock->trx->id));
 
4269
        fprintf(file, " trx id " TRX_ID_FMT, lock->trx->id);
4275
4270
 
4276
4271
        if (lock_get_mode(lock) == LOCK_S) {
4277
4272
                fputs(" lock mode S", file);
4406
4401
              "------------\n", file);
4407
4402
 
4408
4403
        fprintf(file, "Trx id counter " TRX_ID_FMT "\n",
4409
 
                TRX_ID_PREP_PRINTF(trx_sys->max_trx_id));
 
4404
                trx_sys->max_trx_id);
4410
4405
 
4411
4406
        fprintf(file,
4412
4407
                "Purge done for trx's n:o < " TRX_ID_FMT
4413
4408
                " undo n:o < " TRX_ID_FMT "\n",
4414
 
                TRX_ID_PREP_PRINTF(purge_sys->purge_trx_no),
4415
 
                TRX_ID_PREP_PRINTF(purge_sys->purge_undo_no));
 
4409
                purge_sys->purge_trx_no,
 
4410
                purge_sys->purge_undo_no);
4416
4411
 
4417
4412
        fprintf(file,
4418
4413
                "History list length %lu\n",
4489
4484
                                "Trx read view will not see trx with"
4490
4485
                                " id >= " TRX_ID_FMT
4491
4486
                                ", sees < " TRX_ID_FMT "\n",
4492
 
                                TRX_ID_PREP_PRINTF(
4493
 
                                        trx->read_view->low_limit_id),
4494
 
                                TRX_ID_PREP_PRINTF(
4495
 
                                        trx->read_view->up_limit_id));
 
4487
                                trx->read_view->low_limit_id,
 
4488
                                trx->read_view->up_limit_id);
4496
4489
                }
4497
4490
 
4498
4491
                if (trx->que_state == TRX_QUE_LOCK_WAIT) {
4906
4899
lock_validate(void)
4907
4900
/*===============*/
4908
4901
{
4909
 
        lock_t* lock;
4910
 
        trx_t*  trx;
4911
 
        dulint  limit;
4912
 
        ulint   space;
4913
 
        ulint   page_no;
4914
 
        ulint   i;
 
4902
        lock_t*         lock;
 
4903
        trx_t*          trx;
 
4904
        ib_uint64_t     limit;
 
4905
        ulint           space;
 
4906
        ulint           page_no;
 
4907
        ulint           i;
4915
4908
 
4916
4909
        lock_mutex_enter_kernel();
4917
4910
 
4935
4928
 
4936
4929
        for (i = 0; i < hash_get_n_cells(lock_sys->rec_hash); i++) {
4937
4930
 
4938
 
                limit = ut_dulint_zero;
 
4931
                limit = 0;
4939
4932
 
4940
4933
                for (;;) {
4941
4934
                        lock = HASH_GET_FIRST(lock_sys->rec_hash, i);
4942
4935
 
4943
4936
                        while (lock) {
 
4937
                                ib_uint64_t     space_page;
4944
4938
                                ut_a(trx_in_trx_list(lock->trx));
4945
4939
 
4946
4940
                                space = lock->un_member.rec_lock.space;
4947
4941
                                page_no = lock->un_member.rec_lock.page_no;
4948
4942
 
4949
 
                                if (ut_dulint_cmp(
4950
 
                                            ut_dulint_create(space, page_no),
4951
 
                                            limit) >= 0) {
 
4943
                                space_page = ut_ull_create(space, page_no);
 
4944
 
 
4945
                                if (space_page >= limit) {
4952
4946
                                        break;
4953
4947
                                }
4954
4948
 
4966
4960
 
4967
4961
                        lock_mutex_enter_kernel();
4968
4962
 
4969
 
                        limit = ut_dulint_create(space, page_no + 1);
 
4963
                        limit = ut_ull_create(space, page_no + 1);
4970
4964
                }
4971
4965
        }
4972
4966
 
5340
5334
        if the max trx id for the page >= min trx id for the trx list or a
5341
5335
        database recovery is running. */
5342
5336
 
5343
 
        if (((ut_dulint_cmp(page_get_max_trx_id(block->frame),
5344
 
                            trx_list_get_min_trx_id()) >= 0)
 
5337
        if ((page_get_max_trx_id(block->frame) >= trx_list_get_min_trx_id()
5345
5338
             || recv_recovery_is_on())
5346
5339
            && !page_rec_is_supremum(rec)) {
5347
5340
 
5355
5348
 
5356
5349
        ut_ad(lock_rec_queue_validate(block, rec, index, offsets));
5357
5350
 
 
5351
        if (UNIV_UNLIKELY(err == DB_SUCCESS_LOCKED_REC)) {
 
5352
                err = DB_SUCCESS;
 
5353
        }
 
5354
 
5358
5355
        return(err);
5359
5356
}
5360
5357
 
5564
5561
Gets the id of the transaction owning a lock.
5565
5562
@return transaction id */
5566
5563
UNIV_INTERN
5567
 
ullint
 
5564
trx_id_t
5568
5565
lock_get_trx_id(
5569
5566
/*============*/
5570
5567
        const lock_t*   lock)   /*!< in: lock */
5571
5568
{
5572
 
        return(trx_get_id(lock->trx));
 
5569
        return(lock->trx->id);
5573
5570
}
5574
5571
 
5575
5572
/*******************************************************************//**
5663
5660
Gets the id of the table on which the lock is.
5664
5661
@return id of the table */
5665
5662
UNIV_INTERN
5666
 
ullint
 
5663
table_id_t
5667
5664
lock_get_table_id(
5668
5665
/*==============*/
5669
5666
        const lock_t*   lock)   /*!< in: lock */
5672
5669
 
5673
5670
        table = lock_get_table(lock);
5674
5671
 
5675
 
        return((ullint)ut_conv_dulint_to_longlong(table->id));
 
5672
        return(table->id);
5676
5673
}
5677
5674
 
5678
5675
/*******************************************************************//**