#At file:///C:/Work/bzr/Merge/mysql-6.0-falcon-team/ based on revid:kevin.lewis@stripped
2716 Kevin Lewis 2009-06-03
Bug#43344 Code review fix. The previous patch lost the negative on isALock().
This bug would limit the effectiveness of pruning old versions.
In addition, this patch limits the use of Record::state even further by asserting that it is always recNormal before setting it to something, and setting it back to recNormal when that state is completed. It assures that these temporary states do not overlap. And since recChilled overlaps with recInserting, recChilled is not used anymore. Instead recInserting and a new state, recUpdating, are checked to prevent the current record from being chilled.
modified:
storage/falcon/Record.cpp
storage/falcon/Record.h
storage/falcon/RecordScavenge.cpp
storage/falcon/RecordVersion.cpp
storage/falcon/SRLUpdateRecords.cpp
storage/falcon/Table.cpp
storage/falcon/Transaction.cpp
=== modified file 'storage/falcon/Record.cpp'
--- a/storage/falcon/Record.cpp 2009-06-03 01:36:57 +0000
+++ b/storage/falcon/Record.cpp 2009-06-03 18:15:32 +0000
@@ -1235,6 +1235,7 @@ void Record::ShowHistory(void)
void Record::queueForDelete(void)
{
ASSERT(state != recQueuedForDelete);
+ ASSERT(state == recNormal);
state = recQueuedForDelete;
format->table->queueForDelete(this);
}
=== modified file 'storage/falcon/Record.h'
--- a/storage/falcon/Record.h 2009-06-03 01:36:57 +0000
+++ b/storage/falcon/Record.h 2009-06-03 18:15:32 +0000
@@ -42,18 +42,19 @@ enum RecordEncoding {
// Record states
static const int recNormal = 0; // normal record
-//static const int recDeleted = 1; // obsolete - record has been deleted
-//static const int recChilled = 2; // obsolete - record data is temporarily stored in serial log
-//static const int recOnDisk = 3; // obsolete - record is on disk and must be read
-//static const int recLock = 4; // obsolete - this is a "record lock" and not a record
-static const int recNoChill = 5; // record is in use and should not be chilled
-//static const int recRollback = 6; // obsolete - record is being rolled back
-//static const int recUnlocked = 7; // obsolete - record is being unlocked
-static const int recInserting = 8; // record is being physically inserted
-//static const int recDeleting = 9; // obsolete - record is being physically deleted
-//static const int recPruning = 10; // obsolete - record is being pruned
-static const int recEndChain = 11; // end of chain for garbage collection
+//static const int recDeleted = 1; // obsolete - record has been deleted
+//static const int recChilled = 2; // obsolete - record data is temporarily stored in serial log
+//static const int recOnDisk = 3; // obsolete - record is on disk and must be read
+//static const int recLock = 4; // obsolete - this is a "record lock" and not a record
+//static const int recNoChill = 5; // record is in use and should not be chilled
+//static const int recRollback = 6; // obsolete - record is being rolled back
+//static const int recUnlocked = 7; // obsolete - record is being unlocked
+static const int recInserting = 8; // record is being inserted, , do not chill or use in fetchNext().
+//static const int recDeleting = 9; // obsolete - record is being physically deleted
+//static const int recPruning = 10; // obsolete - record is being pruned
+static const int recEndChain = 11; // end of chain for garbage collection
static const int recQueuedForDelete = 12; // Record is in purgatory.
+static const int recUpdating = 13; // record is being updated, do not chill
// Special value for data.record
static const char* recordIsChilled = (const char*) -1;
=== modified file 'storage/falcon/RecordScavenge.cpp'
--- a/storage/falcon/RecordScavenge.cpp 2009-06-03 01:36:57 +0000
+++ b/storage/falcon/RecordScavenge.cpp 2009-06-03 18:15:32 +0000
@@ -187,7 +187,7 @@ Record* RecordScavenge::inventoryRecord(
}
else if (committedBeforeAnyActiveTrans)
{
- if (rec->isALock())
+ if (!rec->isALock())
oldestVisibleRec = rec;
}
}
=== modified file 'storage/falcon/RecordVersion.cpp'
--- a/storage/falcon/RecordVersion.cpp 2009-06-03 01:36:57 +0000
+++ b/storage/falcon/RecordVersion.cpp 2009-06-03 18:15:32 +0000
@@ -187,6 +187,9 @@ Record* RecordVersion::fetchVersion(Tran
{
if (IS_READ_COMMITTED(trans->isolationLevel))
{
+ // Return the record if it is currently committed or
+ // it belongs to this open transaction.
+
if (recTransState->state == Committed || recTransState == trans->transactionState)
return (hasRecord() ? this : NULL);
}
@@ -298,10 +301,10 @@ void RecordVersion::scavengeSavepoint(Tr
// Set this record's priorVersion to point past the leaving record(s)
setPriorVersion(prior, rec);
- UCHAR prevState = ptr->state;
+ ASSERT(ptr->state == recNormal);
ptr->state = recEndChain;
format->table->garbageCollect(prior, this, targetTransaction, false);
- ptr->state = prevState;
+ ptr->state = recNormal;
prior->queueForDelete();
}
=== modified file 'storage/falcon/SRLUpdateRecords.cpp'
--- a/storage/falcon/SRLUpdateRecords.cpp 2009-06-03 01:36:57 +0000
+++ b/storage/falcon/SRLUpdateRecords.cpp 2009-06-03 18:15:32 +0000
@@ -171,9 +171,9 @@ void SRLUpdateRecords::append(Transactio
continue;
}
- // Skip record that is currently being used, but don't advance chillpoint
+ // Skip any record that is currently being used, but don't advance chillpoint
- if (record->state == recNoChill)
+ if ((record->state == recInserting) || (record->state == recUpdating))
continue;
// If this is a different savepoint, break out of the inner loop
=== modified file 'storage/falcon/Table.cpp'
--- a/storage/falcon/Table.cpp 2009-06-03 01:36:57 +0000
+++ b/storage/falcon/Table.cpp 2009-06-03 18:15:32 +0000
@@ -348,6 +348,7 @@ void Table::insert(Transaction *transact
Format *format = getFormat(formatVersion);
record = allocRecordVersion(format, transaction, NULL);
+ ASSERT(record->state == recNormal);
record->state = recInserting;
// Handle any default values
@@ -428,6 +429,7 @@ void Table::insert(Transaction *transact
if (record)
{
SET_RECORD_ACTIVE(record, false);
+ record->state = recNormal;
record->queueForDelete();
}
@@ -1057,9 +1059,6 @@ void Table::rollbackRecord(RecordVersion
{
SET_RECORD_ACTIVE(recordToRollback, false);
- int priorState = recordToRollback->state;
-// recordToRollback->state = recRollback;
-
// Find the record that will become the current version.
Record *priorRecord = recordToRollback->getPriorVersion();
@@ -1075,7 +1074,8 @@ void Table::rollbackRecord(RecordVersion
if (!insertIntoTree(priorRecord, recordToRollback, recordToRollback->recordNumber))
{
// If a transaction inserts a record and then deletes it,
- // the deleted record version will have no priorRecord.
+ // the deleted record version will have no priorRecord.
+
if (priorRecord == NULL && recordToRollback->isDeleted())
{
ASSERT(!(priorRecord == NULL && recordToRollback->isDeleted()));
@@ -1086,7 +1086,7 @@ void Table::rollbackRecord(RecordVersion
// While the base record is uncommitted, only that transaction can change it.
recordToRollback->printRecord("Table::rollbackRecord failed");
- FATAL("Table::rollbackRecord-insertIntoTree failed, priorState =%d", priorState );
+ FATAL("Table::rollbackRecord-insertIntoTree failed, state =%d", recordToRollback->state);
}
if (!priorRecord && recordToRollback->recordNumber >= 0)
@@ -1347,6 +1347,8 @@ void Table::update(Transaction * transac
Format *format = getFormat(formatVersion);
record = allocRecordVersion(format, transaction, oldRecord);
+ ASSERT(record->state == recNormal);
+ record->state = recUpdating;
// Copy field values from old record version
@@ -1405,6 +1407,7 @@ void Table::update(Transaction * transac
// carefully remove the prior version.
record->scavengeSavepoint(transaction, transaction->curSavePointId);
+ record->state = recNormal;
record->release(REC_HISTORY);
}
catch (...)
@@ -1428,6 +1431,7 @@ void Table::update(Transaction * transac
record->deleteData();
SET_RECORD_ACTIVE(record, false);
+ record->state = recNormal;
record->queueForDelete();
}
@@ -3063,6 +3067,7 @@ uint Table::insert(Transaction *transact
fmt = format = getFormat(formatVersion);
record = allocRecordVersion(fmt, transaction, NULL);
+ ASSERT(record->state == recNormal);
record->state = recInserting;
record->setEncodedRecord(stream, false);
recordNumber = record->recordNumber = dbb->insertStub(dataSection, transaction->transactionState);
@@ -3103,6 +3108,7 @@ uint Table::insert(Transaction *transact
if (record)
{
SET_RECORD_ACTIVE(record, false);
+ record->state = recNormal;
record->queueForDelete();
}
@@ -3171,6 +3177,8 @@ void Table::update(Transaction * transac
else
record = allocRecordVersion(format, transaction, oldRecord);
+ ASSERT(record->state == recNormal);
+ record->state = recUpdating; // Keep it from being chilled
record->setEncodedRecord(stream, false);
// Fire pre-operation triggers
@@ -3191,8 +3199,6 @@ void Table::update(Transaction * transac
//updateInversion(record, transaction);
- ASSERT(record->state == recNormal);
-
if (!wasLock)
{
validateAndInsert(transaction, record);
@@ -3211,6 +3217,7 @@ void Table::update(Transaction * transac
// carefully remove the prior version.
record->scavengeSavepoint(transaction, transaction->curSavePointId);
+ record->state = recNormal;
record->release(REC_HISTORY);
oldRecord->release(REC_HISTORY); // This reference originated in this function.
@@ -3238,6 +3245,7 @@ void Table::update(Transaction * transac
SET_RECORD_ACTIVE(record, false);
oldRecord->release(REC_HISTORY);
+ record->state = recNormal;
record->queueForDelete();
}
=== modified file 'storage/falcon/Transaction.cpp'
--- a/storage/falcon/Transaction.cpp 2009-06-03 01:36:57 +0000
+++ b/storage/falcon/Transaction.cpp 2009-06-03 18:15:32 +0000
@@ -618,17 +618,10 @@ void Transaction::addRecord(RecordVersio
if (totalRecordData > database->configuration->recordChillThreshold
&& !systemTransaction)
{
- // Chill all records except the current record,
- // which may be part of an update or insert
-
- UCHAR saveState = record->state;
- if (!record->isALock())
- record->state = recNoChill;
+ // Chill all records except the current record or
+ // any record that may be part of an update or insert
chillRecords();
-
- if (record->state == recNoChill)
- record->state = saveState;
}
if (database->lowMemory && !systemTransaction
Attachment: [text/bzr-bundle] bzr/kevin.lewis@sun.com-20090603181532-a0y8lf338antt30e.bundle
| Thread |
|---|
| • bzr commit into mysql-6.0-falcon-team branch (kevin.lewis:2716)Bug#43344 | Kevin Lewis | 3 Jun |