[ 
https://issues.apache.org/jira/browse/FLUME-3349?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

chenhongcai updated FLUME-3349:
-------------------------------
    Labels: TailDir dataloss  (was: )
    Status: Patch Available  (was: Open)

> TailDir source Data loss
> ------------------------
>
>                 Key: FLUME-3349
>                 URL: https://issues.apache.org/jira/browse/FLUME-3349
>             Project: Flume
>          Issue Type: Bug
>          Components: Sinks+Sources
>    Affects Versions: 1.9.0, 1.8.0
>         Environment: apache-flume-bin-1.8.0
> java-1.8.92
>            Reporter: chenhongcai
>            Priority: Critical
>              Labels: TailDir, dataloss
>
> 如果skipToEnd为{color:red}true{color},file A 处理正在读取处理中时{color:red}生成file 
> B{color},等fileA处理完{color:red}下次{color}处理时file B 
> 从{color:red}末尾开始读取{color},而不是从头读取{color:red}导致数据丢失{color}
> {code:java}
> public List<Long> updateTailFiles(boolean skipToEnd) throws IOException {
>     updateTime = System.currentTimeMillis();
>     List<Long> updatedInodes = Lists.newArrayList();
>     for (TaildirMatcher taildir : taildirCache) {
>       Map<String, String> headers = headerTable.row(taildir.getFileGroup());
>       for (File f : taildir.getMatchingFiles()) {
>         long inode;
>         try {
>           inode = getInode(f);
>         } catch (NoSuchFileException e) {
>           logger.info("File has been deleted in the meantime: " + 
> e.getMessage());
>           continue;
>         }
>         TailFile tf = tailFiles.get(inode);
>         if (tf == null || !tf.getPath().equals(f.getAbsolutePath())) {
>           long startPos = skipToEnd ? f.length() : 0;
>           tf = openFile(f, headers, inode, startPos);
>         } else {
>           boolean updated = tf.getLastUpdated() < f.lastModified() || 
> tf.getPos() != f.length();
>           if (updated) {
>             if (tf.getRaf() == null) {
>               tf = openFile(f, headers, inode, tf.getPos());
>             }
>             if (f.length() < tf.getPos()) {
>               logger.info("Pos " + tf.getPos() + " is larger than file size! "
>                   + "Restarting from pos 0, file: " + tf.getPath() + ", 
> inode: " + inode);
>               tf.updatePos(tf.getPath(), inode, 0);
>             }
>           }
>           tf.setNeedTail(updated);
>         }
>         tailFiles.put(inode, tf);
>         updatedInodes.add(inode);
>       }
>     }
>     return updatedInodes;
>   }
> {code}



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to