@@ -1117,7 +1117,7 @@ class RdbSaver::Impl final : public SliceSnapshot::SnapshotDataConsumerInterface
11171117 // We pass K=sz to say how many producers are pushing data in order to maintain
11181118 // correct closing semantics - channel is closing when K producers marked it as closed.
11191119 Impl (bool align_writes, unsigned producers_len, CompressionMode compression_mode,
1120- SaveMode save_mode, io::Sink* sink);
1120+ SaveMode save_mode, io::Sink* sink, DflyVersion replica_dfly_version );
11211121
11221122 ~Impl ();
11231123
@@ -1182,12 +1182,13 @@ class RdbSaver::Impl final : public SliceSnapshot::SnapshotDataConsumerInterface
11821182 // make snapshot size smaller and opreation faster.
11831183 CompressionMode compression_mode_;
11841184 SaveMode save_mode_;
1185+ DflyVersion replica_dfly_version_ = DflyVersion::CURRENT_VER ;
11851186};
11861187
11871188// We pass K=sz to say how many producers are pushing data in order to maintain
11881189// correct closing semantics - channel is closing when K producers marked it as closed.
11891190RdbSaver::Impl::Impl (bool align_writes, unsigned producers_len, CompressionMode compression_mode,
1190- SaveMode sm, io::Sink* sink)
1191+ SaveMode sm, io::Sink* sink, DflyVersion replica_dfly_version )
11911192 : sink_(sink),
11921193 shard_snapshots_ (producers_len),
11931194 meta_serializer_(CompressionMode::NONE ), // Note: I think there is not need for compression
@@ -1201,6 +1202,7 @@ RdbSaver::Impl::Impl(bool align_writes, unsigned producers_len, CompressionMode
12011202 channel_.emplace (kChannelLen , producers_len);
12021203 }
12031204 save_mode_ = sm;
1205+ replica_dfly_version_ = replica_dfly_version;
12041206}
12051207
12061208void RdbSaver::Impl::CleanShardSnapshots () {
@@ -1302,8 +1304,9 @@ void RdbSaver::Impl::StartSnapshotting(bool stream_journal, ExecutionState* cntx
13021304
13031305SnapshotPtr RdbSaver::Impl::CreateSliceSnapshot (EngineShard* shard, DbSlice* db_slice,
13041306 ExecutionState* cntx) {
1305- return SnapshotPtr (new SliceSnapshot (compression_mode_, db_slice, this , cntx),
1306- OwnerThreadDeleter::FromShard (shard));
1307+ return SnapshotPtr (
1308+ new SliceSnapshot (compression_mode_, db_slice, this , cntx, replica_dfly_version_),
1309+ OwnerThreadDeleter::FromShard (shard));
13071310}
13081311
13091312// called on save flow
@@ -1532,8 +1535,9 @@ SnapshotPtr& RdbSaver::Impl::GetSnapshot(EngineShard* shard) {
15321535 return shard_snapshots_[sid];
15331536}
15341537
1535- RdbSaver::RdbSaver (::io::Sink* sink, SaveMode save_mode, bool align_writes, std::string snapshot_id)
1536- : snapshot_id_(std::move(snapshot_id)) {
1538+ RdbSaver::RdbSaver (::io::Sink* sink, SaveMode save_mode, bool align_writes, std::string snapshot_id,
1539+ DflyVersion replica_dfly_version)
1540+ : replica_dfly_version_(replica_dfly_version), snapshot_id_(std::move(snapshot_id)) {
15371541 CHECK_NOTNULL (sink);
15381542 CompressionMode compression_mode = GetDefaultCompressionMode ();
15391543 int producer_count = 0 ;
@@ -1561,7 +1565,8 @@ RdbSaver::RdbSaver(::io::Sink* sink, SaveMode save_mode, bool align_writes, std:
15611565 break ;
15621566 }
15631567 VLOG (1 ) << " Rdb save using compression mode:" << uint32_t (compression_mode_);
1564- impl_.reset (new Impl (align_writes, producer_count, compression_mode_, save_mode, sink));
1568+ impl_.reset (new Impl (align_writes, producer_count, compression_mode_, save_mode, sink,
1569+ replica_dfly_version_));
15651570 save_mode_ = save_mode;
15661571}
15671572
@@ -1649,13 +1654,20 @@ error_code RdbSaver::SaveAux(const GlobalData& glob_state) {
16491654 if (!glob_state.search_indices .empty ())
16501655 LOG (WARNING ) << " Dragonfly search index data is incompatible with the RDB format" ;
16511656 } else {
1652- // Search index definitions (simple "index_name cmd" restore commands)
1653- for (const string& s : glob_state.search_indices )
1654- RETURN_ON_ERR (impl_->SaveAuxFieldStrStr (" search-index" , s));
1657+ // Search index definitions - for non-summary shards only sent to replicas >= VER6,
1658+ // since older replicas only expect search-index from the summary shard.
1659+ bool send_search_index =
1660+ (save_mode_ != SaveMode::SINGLE_SHARD ) || (replica_dfly_version_ >= DflyVersion::VER6 );
1661+ if (send_search_index) {
1662+ for (const string& s : glob_state.search_indices )
1663+ RETURN_ON_ERR (impl_->SaveAuxFieldStrStr (" search-index" , s));
1664+ }
16551665
1656- // HNSW index metadata (JSON, summary only)
1657- for (const string& s : glob_state.hnsw_index_metadata )
1658- RETURN_ON_ERR (impl_->SaveAuxFieldStrStr (" hnsw-index-metadata" , s));
1666+ // HNSW index metadata (JSON, summary only) - only for replicas >= VER6
1667+ if (replica_dfly_version_ >= DflyVersion::VER6 ) {
1668+ for (const string& s : glob_state.hnsw_index_metadata )
1669+ RETURN_ON_ERR (impl_->SaveAuxFieldStrStr (" hnsw-index-metadata" , s));
1670+ }
16591671
16601672 // Save synonyms only in summary file
16611673 DCHECK (save_mode_ != SaveMode::SINGLE_SHARD || glob_state.search_synonyms .empty ());
0 commit comments