~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Brian Aker
  • Date: 2010-11-30 00:29:39 UTC
  • mto: (1965.2.2 build)
  • mto: This revision was merged to the branch mainline in revision 1966.
  • Revision ID: brian@tangent.org-20101130002939-8bzz3xpa0aapbq2w
Fix sleep() so that a kill command will kill it.

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