-
Notifications
You must be signed in to change notification settings - Fork 188
relay: don't purge relay logs when connected to last source #1400
Conversation
PTAL @3pointer @lichunzhu |
Done. But if stop source when worker is offline, need to manually purge now we should check if a source is deleted, changed some information like 'relay-binlog-gtid' and restarted, DM should handle it properly. maybe |
…O MASTER_AUTO_POSITION = 1, but the master has purged binary logs containing GTIDs that the slave requires.
seems this pr will always start pull the binlog files from relay.meta? |
yes, I want to ensure relay log is complete. if upstream has purged the binlog at the position of relay.meta, I am expecting DM auto switch to remote binlog. |
dm/worker/relay.go
Outdated
// purge relay dir when delete source | ||
if err := h.relay.PurgeRelayDir(); err != nil { | ||
return err | ||
} | ||
|
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 it's a bit aggressive.
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.
how to change 🤔
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 suggest moving relay dir to another name (relay_dir
-> relay_dir_deprecated
) instead of deleting it directly. We have purge-relay
command and I think the purge action should only happen in this command.
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.
relay_dir_deprecated
is out of relay_dir
thus can't be deleted using purge-relay
. And disk space is not freed
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 don't think it's a good idea. stop source
is a normal operation. shouldn't purge data or move to another directory.
Haven't implemented now? I'm afraid that it can't meet user expectations and hard to locate the error since behavior has changed. Moreover, sync should wait relay for a long time if it start from the meta pos but not checkpoint. |
the yes, sync will wait a longer time. My prefer for a complete relay log is to handle this case: if an upstream/worker handles multiple tasks, later added tasks may access the hole of relay log thus lost events |
That happens when sync meet errors, not relay. If relay meet an error, like binlog has been purged, sync will block now.
I prefer to check the checkpoint and relay meta. When worker bound to a source, compare the min checkpoint of the source and the relay meta location. If checkpoint is larger, purge relay dir and start from checkpoint(This is same as we specify relay-binlog-pos/gtid for a new source), if checkpoint is smaller, pull binlog from relay meta location. If user add a new task for that source which older than relay, we just report an error. That's same as user specify relay-binlog-pos/gtid, but start from a older location in syncer, or sync start from a location which has been purged in relay. |
I think we should also switch to remote binlog when relay meets error? |
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
/run-all-tests |
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
Signed-off-by: ti-srebot <[email protected]>
cherry pick to release-2.0 in PR #1428 |
What problem does this PR solve?
close #1398
What is changed and how it works?
Purge relay log directory when switch to different upstream.
If reconnected to same upstream, relay will look at position saved in relay meta and needed position which specified by user or saved in syncer checkpoint. If relay.meta is left behind, purge the relay folder
Check List
Tests
Code changes
Side effects
Related changes