Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change the order of dumping checkpoint to avoid checkpoint overwritten caused by inode multiplexing #596

Merged
merged 2 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion core/controller/EventDispatcherBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1105,7 +1105,10 @@ void EventDispatcherBase::DumpAllHandlersMeta(bool remove) {
MapType<int, DirInfo*>::Type::iterator it;
vector<int> timeout;
for (it = mWdDirInfoMap.begin(); it != mWdDirInfoMap.end(); ++it) {
((it->second)->mHandler)->DumpReaderMeta(remove);
((it->second)->mHandler)->DumpReaderMeta(true, remove);
}
for (it = mWdDirInfoMap.begin(); it != mWdDirInfoMap.end(); ++it) {
((it->second)->mHandler)->DumpReaderMeta(false, remove);
timeout.push_back(it->first);
if (remove)
ConfigManager::GetInstance()->AddHandlerToDelete((it->second)->mHandler);
Expand Down
20 changes: 11 additions & 9 deletions core/event_handler/EventHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,9 +190,9 @@ void TimeoutHandler::HandleTimeOut() {
// do nothing
}

bool CreateModifyHandler::DumpReaderMeta(bool checkConfigFlag) {
bool CreateModifyHandler::DumpReaderMeta(bool isRotatorReader, bool checkConfigFlag) {
for (ModifyHandlerMap::iterator iter = mModifyHandlerPtrMap.begin(); iter != mModifyHandlerPtrMap.end(); ++iter) {
iter->second->DumpReaderMeta(checkConfigFlag);
iter->second->DumpReaderMeta(isRotatorReader, checkConfigFlag);
}
return true;
}
Expand Down Expand Up @@ -839,13 +839,15 @@ void ModifyHandler::HandleTimeOut() {
}
}

bool ModifyHandler::DumpReaderMeta(bool checkConfigFlag) {
DevInodeLogFileReaderMap::iterator it = mDevInodeReaderMap.begin();
for (; it != mDevInodeReaderMap.end(); ++it) {
it->second->DumpMetaToMem(checkConfigFlag);
}
for (it = mRotatorReaderMap.begin(); it != mRotatorReaderMap.end(); ++it) {
it->second->DumpMetaToMem(checkConfigFlag);
bool ModifyHandler::DumpReaderMeta(bool isRotatorReader, bool checkConfigFlag) {
if (!isRotatorReader) {
for (DevInodeLogFileReaderMap::iterator it = mDevInodeReaderMap.begin(); it != mDevInodeReaderMap.end(); ++it) {
it->second->DumpMetaToMem(checkConfigFlag);
}
} else {
for (DevInodeLogFileReaderMap::iterator it = mRotatorReaderMap.begin(); it != mRotatorReaderMap.end(); ++it) {
it->second->DumpMetaToMem(checkConfigFlag);
}
}
return true;
}
Expand Down
12 changes: 6 additions & 6 deletions core/event_handler/EventHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class EventHandler {
public:
virtual void Handle(const Event& event) = 0;
virtual void HandleTimeOut() = 0;
virtual bool DumpReaderMeta(bool checkConfigFlag = false) = 0;
virtual bool DumpReaderMeta(bool isRotatorReader, bool checkConfigFlag = false) = 0;
virtual ~EventHandler() {}
};

Expand All @@ -47,7 +47,7 @@ class TimeoutHandler : public EventHandler {

virtual void Handle(const Event& event);
virtual void HandleTimeOut();
virtual bool DumpReaderMeta(bool checkConfigFlag = false) { return true; }
virtual bool DumpReaderMeta(bool isRotatorReader, bool checkConfigFlag = false) { return true; }
yyuuttaaoo marked this conversation as resolved.
Show resolved Hide resolved
};

class ModifyHandler : public EventHandler {
Expand Down Expand Up @@ -88,7 +88,7 @@ class ModifyHandler : public EventHandler {
virtual ~ModifyHandler();
virtual void Handle(const Event& event);
virtual void HandleTimeOut();
virtual bool DumpReaderMeta(bool checkConfigFlag = false);
virtual bool DumpReaderMeta(bool isRotatorReader, bool checkConfigFlag = false);

#ifdef APSARA_UNIT_TEST_MAIN
friend class ConfigUpdatorUnittest;
Expand All @@ -105,7 +105,7 @@ class CreateHandler : public EventHandler {
virtual void Handle(const Event& event);
virtual void HandleTimeOut();

virtual bool DumpReaderMeta(bool checkConfigFlag = false) { return true; }
virtual bool DumpReaderMeta(bool isRotatorReader, bool checkConfigFlag = false) { return true; }
};

class NormalEventHandler : public EventHandler {
Expand All @@ -122,7 +122,7 @@ class NormalEventHandler : public EventHandler {

virtual void Handle(const Event& event);
virtual void HandleTimeOut();
virtual bool DumpReaderMeta(bool checkConfigFlag = false) { return true; }
virtual bool DumpReaderMeta(bool isRotatorReader, bool checkConfigFlag = false) { return true; }
};

class CreateModifyHandler : public EventHandler {
Expand All @@ -141,7 +141,7 @@ class CreateModifyHandler : public EventHandler {
virtual ~CreateModifyHandler();
virtual void Handle(const Event& event);
virtual void HandleTimeOut();
virtual bool DumpReaderMeta(bool checkConfigFlag = false);
virtual bool DumpReaderMeta(bool isRotatorReader, bool checkConfigFlag = false);

ModifyHandler* GetOrCreateModifyHandler(const std::string& configName, Config* pConfig = NULL);

Expand Down