diff --git a/src/main/java/com/pinterest/secor/uploader/Uploader.java b/src/main/java/com/pinterest/secor/uploader/Uploader.java index 7a53b6d5d..d98294766 100644 --- a/src/main/java/com/pinterest/secor/uploader/Uploader.java +++ b/src/main/java/com/pinterest/secor/uploader/Uploader.java @@ -102,8 +102,6 @@ private void uploadFiles(TopicPartition topicPartition) throws Exception { topicPartition.getTopic(), topicPartition.getPartition()); - // Deleting writers closes their streams flushing all pending data to the disk. - mFileRegistry.deleteWriters(topicPartition); mZookeeperConnector.lock(lockPath); try { // Check if the committed offset has changed. @@ -111,6 +109,8 @@ private void uploadFiles(TopicPartition topicPartition) throws Exception { topicPartition); if (zookeeperComittedOffsetCount == committedOffsetCount) { LOG.info("uploading topic {} partition {}", topicPartition.getTopic(), topicPartition.getPartition()); + // Deleting writers closes their streams flushing all pending data to the disk. + mFileRegistry.deleteWriters(topicPartition); Collection paths = mFileRegistry.getPaths(topicPartition); List> uploadFutures = new ArrayList>(); for (LogFilePath path : paths) {