From 80d14e6b528fcf34f4bd39bfd5ea8dce0f303127 Mon Sep 17 00:00:00 2001 From: yejun Date: Thu, 2 Jul 2015 11:34:03 -0700 Subject: [PATCH] fix a rare race condition --- src/main/java/com/pinterest/secor/uploader/Uploader.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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) {