-
Notifications
You must be signed in to change notification settings - Fork 188
Conversation
Co-Authored-By: csuzhangxc <[email protected]>
/run-all-tests |
/run-all-tests |
1 similar comment
/run-all-tests |
Codecov Report
@@ Coverage Diff @@
## master #117 +/- ##
================================================
+ Coverage 32.4824% 34.2082% +1.7257%
================================================
Files 117 121 +4
Lines 13124 13602 +478
================================================
+ Hits 4263 4653 +390
- Misses 8378 8420 +42
- Partials 483 529 +46 |
// handleDuplicateEventsExist tries to handle a potential duplicate event in the binlog file. | ||
func (w *FileWriter) handleDuplicateEventsExist(ev *replication.BinlogEvent) (*Result, error) { | ||
filename := filepath.Join(w.cfg.RelayDir, w.filename.Get()) | ||
duplicate, err := checkIsDuplicateEvent(filename, ev) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is it inefficient that call it for every event?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in most cases, checkIsDuplicateEvent
only checks start/end pos with the file size (has a comment in checkIsDuplicateEvent
), so I think it is not inefficient. and if we want to make it work correctly, we must do this check.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm worrid that os.Stat
is an inefficient function
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so, pass file size into the function as an arg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for os.Stat
, it will call syscall.Stat
; for File.Stat
, it will call syscall.Fstat
.
from http://man7.org/linux/man-pages/man2/stat.2.html.
fstat() is identical to stat(), except that the file about which
information is to be retrieved is specified by the file descriptor
fd.
if we changed to pass File.Stat()
into the function, the difference of efficiency is small? or should we need to pass an in-memory offset into the function? @GregoryIan what's your opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can choose one
- check duplicate event only if we need to check, like
holeSize < 0
- or parse a
fd
orstat information
as arg?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I choose the first one.
/run-all-tests |
1 similar comment
/run-all-tests |
# Conflicts: # pkg/binlog/reader/tcp.go
/run-all-tests |
relay/writer/file_util.go
Outdated
|
||
// only parse single event | ||
eof, err := replication.NewBinlogParser().ParseSingleEvent(f, onEventFunc) | ||
if err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if some events after format description event
are damaged, but found == true
, should we return true?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I changed to return true
even err != nil
in 6d54140, because this function only checks if FormatDescriptionEvent
exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
make sense
Rest LGTM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
What problem does this PR solve?
this PR is a part of #91.
What is changed and how it works?
FileWriter
to support to write binlog events into filesRotateEvent
FileWriter
support to recover any binlog file with uncompleted events/transactionsCheck List
Tests
Code changes
Side effects