mirror of
https://github.com/xcat2/confluent.git
synced 2024-11-26 19:40:12 +00:00
Fix deleted logs breaking partial buffer rebuild
When the read_recent_text ran off a cliff looking for buffer data, it left the current textfile handle in a bad state. This caused the buffer rebuild to fail completely in a scenario where all the current logs put together don't have enough data to satisfy the buffer. Fix this by making the handle more obviously broken, and repairing while seeking out data.
This commit is contained in:
parent
6504acecad
commit
2dd6c31513
@ -625,6 +625,8 @@ class Logger(object):
|
||||
binfile = open(binpath, mode='r')
|
||||
textfile = open(textpath, mode='r')
|
||||
except IOError:
|
||||
binfile = None
|
||||
textfile = None
|
||||
break
|
||||
flock(binfile, LOCK_SH)
|
||||
flock(textfile, LOCK_SH)
|
||||
@ -649,11 +651,15 @@ class Logger(object):
|
||||
textdata = ''
|
||||
while offsets:
|
||||
(offset, length, textpath) = offsets.pop()
|
||||
if textfile is None:
|
||||
textfile = open(textpath, mode='r')
|
||||
flock(textfile, LOCK_SH)
|
||||
if textfile.name != textpath:
|
||||
try:
|
||||
flock(textfile, LOCK_UN)
|
||||
textfile.close()
|
||||
textfile = open(textpath, mode='r')
|
||||
flock(textfile, LOCK_SH)
|
||||
except (ValueError, IOError) as e:
|
||||
break
|
||||
try:
|
||||
|
Loading…
Reference in New Issue
Block a user