1919#include < Common/randomSeed.h>
2020#include < Common/DNSResolver.h>
2121#include < shared_mutex>
22+ #include < Core/ServerUUID.h>
2223
2324
2425namespace ProfileEvents
@@ -505,17 +506,22 @@ namespace
505506 {
506507 std::string hostname;
507508 std::string table_id;
509+ std::string server_uuid;
510+
511+ size_t version = 1 ;
508512
509513 bool operator ==(const Info & other) const
510514 {
511- return hostname == other.hostname && table_id == other.table_id ;
515+ return hostname == other.hostname && table_id == other.table_id
516+ && (version == 0 || other.version == 0 || server_uuid == other.server_uuid );
512517 }
513518
514519 static Info create (const StorageID & storage_id)
515520 {
516521 Info self;
517522 self.hostname = DNSResolver::instance ().getHostName ();
518523 self.table_id = storage_id.hasUUID () ? toString (storage_id.uuid ) : storage_id.getFullTableName ();
524+ self.server_uuid = toString (ServerUUID::get ());
519525 return self;
520526 }
521527
@@ -524,27 +530,30 @@ namespace
524530 SipHash hash;
525531 hash.update (hostname);
526532 hash.update (table_id);
533+ hash.update (server_uuid);
527534 return hash.get128 ();
528535 }
529536
530537 std::string serialize () const
531538 {
532539 WriteBufferFromOwnString buf;
533- size_t version = 0 ;
534540 buf << version << " \n " ;
535541 buf << hostname << " \n " ;
536542 buf << table_id << " \n " ;
543+ if (version >= 1 )
544+ buf << server_uuid << " \n " ;
537545 return buf.str ();
538546 }
539547
540548 static Info deserialize (const std::string & str)
541549 {
542550 ReadBufferFromString buf (str);
543551 Info info;
544- size_t version;
545- buf >> version >> " \n " ;
552+ buf >> info.version >> " \n " ;
546553 buf >> info.hostname >> " \n " ;
547554 buf >> info.table_id >> " \n " ;
555+ if (info.version >= 1 )
556+ buf >> info.server_uuid >> " \n " ;
548557 return info;
549558 }
550559 };
0 commit comments