diff --git a/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/log/checkpoint/CheckPointerConstraintCreationDeadlockIT.java b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/log/checkpoint/CheckPointerConstraintCreationDeadlockIT.java
new file mode 100644
index 000000000000..afc886a79e97
--- /dev/null
+++ b/community/kernel/src/test/java/org/neo4j/kernel/impl/transaction/log/checkpoint/CheckPointerConstraintCreationDeadlockIT.java
@@ -0,0 +1,192 @@
+/*
+ * Copyright (c) 2002-2017 "Neo Technology,"
+ * Network Engine for Objects in Lund AB [http://neotechnology.com]
+ *
+ * This file is part of Neo4j.
+ *
+ * Neo4j is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ */
+package org.neo4j.kernel.impl.transaction.log.checkpoint;
+
+import org.junit.Rule;
+import org.junit.Test;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Future;
+
+import org.neo4j.graphdb.Label;
+import org.neo4j.graphdb.Transaction;
+import org.neo4j.kernel.api.exceptions.TransactionFailureException;
+import org.neo4j.kernel.impl.api.TransactionCommitProcess;
+import org.neo4j.kernel.impl.api.TransactionToApply;
+import org.neo4j.kernel.impl.api.index.IndexingService;
+import org.neo4j.kernel.impl.locking.LockWrapper;
+import org.neo4j.kernel.impl.transaction.TransactionRepresentation;
+import org.neo4j.kernel.impl.transaction.log.LogicalTransactionStore;
+import org.neo4j.kernel.impl.transaction.log.TransactionCursor;
+import org.neo4j.kernel.impl.transaction.log.TransactionIdStore;
+import org.neo4j.kernel.internal.GraphDatabaseAPI;
+import org.neo4j.kernel.monitoring.Monitors;
+import org.neo4j.test.Barrier;
+import org.neo4j.test.EphemeralFileSystemRule;
+import org.neo4j.test.OtherThreadRule;
+import org.neo4j.test.TestGraphDatabaseFactory;
+import org.neo4j.test.TestLabels;
+
+import static java.util.concurrent.TimeUnit.SECONDS;
+
+import static org.neo4j.kernel.impl.transaction.tracing.CommitEvent.NULL;
+import static org.neo4j.storageengine.api.TransactionApplicationMode.EXTERNAL;
+
+/**
+ * The scenario, which takes place on database instance applying constraint
+ * creation as an external transaction, looks like this:
+ *
+ *
+ *
+ * Transaction T1 creates the constraint index and population P starts
+ *
+ *
+ * Transaction T2 which activates the constraint starts applying and now has a read lock on the counts store
+ *
+ *
+ * Check point triggers, wants to rotate counts store and so acquires its write lock.
+ * It will have to block, but doing so will also blocks further read lock requests
+ *
+ *
+ * T2 moves on to activate the constraint. Doing so means first waiting for the index to come online
+ *
+ *
+ * P moves on to flip after population, something which includes initializing some sample data in counts store
+ * for this index. Will block on the counts store read lock, completing the deadlock
+ *
+ *
+ */
+public class CheckPointerConstraintCreationDeadlockIT
+{
+ private static final Label LABEL = TestLabels.LABEL_ONE;
+ private static final String KEY = "key";
+
+ @Rule
+ public final EphemeralFileSystemRule fs = new EphemeralFileSystemRule();
+ @Rule
+ public final OtherThreadRule t2 = new OtherThreadRule<>( "T2" );
+ @Rule
+ public final OtherThreadRule t3 = new OtherThreadRule<>( "T3" );
+
+ @Test
+ public void shouldNotDeadlock() throws Exception
+ {
+ List transactions = createConstraintCreatingTransactions();
+ Monitors monitors = new Monitors();
+ GraphDatabaseAPI db = (GraphDatabaseAPI) new TestGraphDatabaseFactory()
+ .setMonitors( monitors ).newImpermanentDatabase();
+ Barrier.Control controller = new Barrier.Control();
+ boolean success = false;
+ try
+ {
+ IndexingService.Monitor monitor = new IndexingService.MonitorAdapter()
+ {
+ @Override
+ public void indexPopulationScanComplete()
+ {
+ controller.reached();
+ }
+ };
+ monitors.addMonitorListener( monitor );
+ Future