mirror of
https://github.com/mongodb/mongo.git
synced 2024-12-01 09:32:32 +01:00
fix hashtable so that deleted entries don't prevent finding later chained entries SERVER-553
This commit is contained in:
parent
14a0217520
commit
693b5980dc
@ -61,11 +61,16 @@ namespace mongo {
|
|||||||
int i = h % n;
|
int i = h % n;
|
||||||
int start = i;
|
int start = i;
|
||||||
int chain = 0;
|
int chain = 0;
|
||||||
|
int firstNonUsed = -1;
|
||||||
while ( 1 ) {
|
while ( 1 ) {
|
||||||
if ( !nodes[i].inUse() ) {
|
if ( !nodes[i].inUse() ) {
|
||||||
return i;
|
if ( firstNonUsed < 0 )
|
||||||
|
firstNonUsed = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( nodes[i].hash == h && nodes[i].k == k ) {
|
if ( nodes[i].hash == h && nodes[i].k == k ) {
|
||||||
|
if ( chain >= 200 )
|
||||||
|
out() << "warning: hashtable " << name << " long chain " << endl;
|
||||||
found = true;
|
found = true;
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
@ -77,11 +82,11 @@ namespace mongo {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if( chain >= maxChain ) {
|
if( chain >= maxChain ) {
|
||||||
|
if ( firstNonUsed >= 0 )
|
||||||
|
return firstNonUsed;
|
||||||
out() << "error: hashtable " << name << " max chain n:" << n << endl;
|
out() << "error: hashtable " << name << " max chain n:" << n << endl;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
if ( chain == 200 )
|
|
||||||
out() << "warning: hashtable " << name << " long chain " << endl;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -112,7 +117,7 @@ namespace mongo {
|
|||||||
bool found;
|
bool found;
|
||||||
int i = _find(k, found);
|
int i = _find(k, found);
|
||||||
if ( i >= 0 && found ) {
|
if ( i >= 0 && found ) {
|
||||||
//TEMP nodes[i].k.kill();
|
nodes[i].k.kill();
|
||||||
nodes[i].setUnused();
|
nodes[i].setUnused();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user