Skip to content

Commit

Permalink
fix a rare race condition
Browse files Browse the repository at this point in the history
  • Loading branch information
yejun committed Jul 9, 2015
1 parent bc0cafe commit 80d14e6
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/pinterest/secor/uploader/Uploader.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ 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.
long zookeeperComittedOffsetCount = mZookeeperConnector.getCommittedOffsetCount(
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<LogFilePath> paths = mFileRegistry.getPaths(topicPartition);
List<Future<?>> uploadFutures = new ArrayList<Future<?>>();
for (LogFilePath path : paths) {
Expand Down

0 comments on commit 80d14e6

Please sign in to comment.