Пример #1
0
    PlanStage::StageState OplogStart::work(WorkingSetID* out) {
        // We do our (heavy) init in a work(), where work is expected.
        if (_needInit) {
            CollectionScanParams params;
            params.collection = _collection;
            params.direction = CollectionScanParams::BACKWARD;
            _cs.reset(new CollectionScan(_txn, params, _workingSet, NULL));
            _needInit = false;
            _backwardsScanning = true;
            _timer.reset();
        }

        // If we're still reading backwards, keep trying until timing out.
        if (_backwardsScanning) {
            verify(!_extentHopping);
            // Still have time to succeed with reading backwards.
            if (_timer.seconds() < _backwardsScanTime) {
                return workBackwardsScan(out);
            }
            switchToExtentHopping();
        }

        // Don't find it in time?  Swing from extent to extent like tarzan.com.
        verify(_extentHopping);
        return workExtentHopping(out);
    }
Пример #2
0
    PlanStage::StageState OplogStart::work(WorkingSetID* out) {
        // We do our (heavy) init in a work(), where work is expected.
        if (_needInit) {
            CollectionScanParams params;
            params.collection = _collection;
            params.direction = CollectionScanParams::BACKWARD;
            _cs.reset(new CollectionScan(params, _workingSet, NULL));
            _nsd = _collection->details();
            _needInit = false;
            _backwardsScanning = true;
            _timer.reset();
        }

        // If we don't have a _curloc yet, then we'll have
        // to backwards scan this time in order to initialize it.
        if (_curloc.isNull() && !_extentHopping) {
            return workBackwardsScan(out);
        }

        // If we're reading backwards, try again.
        if (_backwardsScanning) {
            // Still have time to succeed with reading backwards.
            if (_timer.seconds() < _backwardsScanTime) {
                return workBackwardsScan(out);
            }
            switchToExtentHopping();
        }

        // Don't find it in time?  Swing from extent to extent like tarzan.com.
        verify(_extentHopping);
        return workExtentHopping(out);
    }