@@ -73,7 +73,7 @@ namespace
7373
7474 inline constexpr unsigned COPY_BLOCK_SIZE = 64 * 1024 ; // 64 KB
7575
76- inline constexpr const char * FILENAME_PATTERN = " %s.journal-%09" UQUADFORMAT;
76+ inline constexpr const char * FILENAME_PATTERN = " %s_% s.journal-%09" UQUADFORMAT;
7777
7878 inline constexpr const char * FILENAME_WILDCARD = " $(filename)" ;
7979 inline constexpr const char * PATHNAME_WILDCARD = " $(pathname)" ;
@@ -885,6 +885,26 @@ void ChangeLog::bgArchiver()
885885 }
886886}
887887
888+ void ChangeLog::cleanup ()
889+ {
890+ LockGuard guard (this );
891+
892+ while (m_segments.hasData ())
893+ {
894+ const auto segment = m_segments.pop ();
895+
896+ if (segment->getState () == SEGMENT_STATE_USED && segment->hasData ())
897+ segment->setState (SEGMENT_STATE_FULL);
898+
899+ if (segment->getState () == SEGMENT_STATE_FULL)
900+ archiveSegment (segment);
901+
902+ const PathName filename = segment->getPathName ();
903+ segment->release ();
904+ unlink (filename.c_str ());
905+ }
906+ }
907+
888908void ChangeLog::initSegments ()
889909{
890910 clearSegments ();
@@ -939,7 +959,7 @@ ChangeLog::Segment* ChangeLog::createSegment()
939959 const auto sequence = state->sequence + 1 ;
940960
941961 PathName filename;
942- filename.printf (FILENAME_PATTERN, m_config->filePrefix .c_str (), sequence);
962+ filename.printf (FILENAME_PATTERN, m_config->filePrefix .c_str (), m_guid. toString ( false ). c_str (), sequence);
943963 filename = m_config->journalDirectory + filename;
944964
945965 const auto fd = os_utils::openCreateSharedFile (filename.c_str (), O_EXCL | O_BINARY);
@@ -989,7 +1009,7 @@ ChangeLog::Segment* ChangeLog::reuseSegment(ChangeLog::Segment* segment)
9891009 // Attempt to rename the backing file
9901010
9911011 PathName newname;
992- newname.printf (FILENAME_PATTERN, m_config->filePrefix .c_str (), sequence);
1012+ newname.printf (FILENAME_PATTERN, m_config->filePrefix .c_str (), m_guid. toString ( false ). c_str (), sequence);
9931013 newname = m_config->journalDirectory + newname;
9941014
9951015 // If renaming fails, then we just create a new file.
0 commit comments