@@ -183,23 +183,27 @@ void VBucket::fireAllOps(EventuallyPersistentEngine &engine) {
183183
184184void VBucket::setState (vbucket_state_t to, SERVER_HANDLE_V1 *sapi) {
185185 cb_assert (sapi);
186- WriterLockHolder wlh (stateLock);
187- vbucket_state_t oldstate (state);
188186
189- if (to == vbucket_state_active &&
190- checkpointManager.getOpenCheckpointId () < 2 ) {
191- checkpointManager.setOpenCheckpointId (2 );
187+ vbucket_state_t oldstate;
188+ {
189+ WriterLockHolder wlh (stateLock);
190+ oldstate = state;
191+
192+ if (to == vbucket_state_active &&
193+ checkpointManager.getOpenCheckpointId () < 2 ) {
194+ checkpointManager.setOpenCheckpointId (2 );
195+ }
196+
197+ LOG (EXTENSION_LOG_DEBUG, " transitioning vbucket %d from %s to %s" ,
198+ id, VBucket::toString (oldstate), VBucket::toString (to));
199+
200+ state = to;
192201 }
193202
194203 if (oldstate == vbucket_state_active) {
195204 uint64_t highSeqno = (uint64_t )checkpointManager.getHighSeqno ();
196205 setCurrentSnapshot (highSeqno, highSeqno);
197206 }
198-
199- LOG (EXTENSION_LOG_DEBUG, " transitioning vbucket %d from %s to %s" ,
200- id, VBucket::toString (oldstate), VBucket::toString (to));
201-
202- state = to;
203207}
204208
205209void VBucket::doStatsForQueueing (Item& qi, size_t itemBytes)
0 commit comments