Skip to content

Commit

Permalink
Merge pull request pinterest#106 from yyejun/fix_writer_delete
Browse files Browse the repository at this point in the history
Fix a race condition when two upload happens at the same time
  • Loading branch information
pgarbacki committed Jul 9, 2015
2 parents bc0cafe + 80d14e6 commit 8d97a99
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 8d97a99

Please sign in to comment.