@@ -111,6 +111,7 @@ bool launch_agent(void)
111111 int outfd [2 ];
112112 int infd [2 ];
113113 int errfd [2 ];
114+ int agent_version ;
114115
115116 ssh_argc = 0 ;
116117#ifdef WIN32
@@ -163,24 +164,24 @@ bool launch_agent(void)
163164 }
164165 }
165166 if (needs_quotes (instance_config .remote .path ) || needs_quotes (PROGRAM_NAME_FULL ))
166- snprintf (cmd , sizeof (cmd ), "\"%s\\%s\" agent %s " ,
167- instance_config .remote .path , probackup , PROGRAM_VERSION );
167+ snprintf (cmd , sizeof (cmd ), "\"%s\\%s\" agent" ,
168+ instance_config .remote .path , probackup );
168169 else
169- snprintf (cmd , sizeof (cmd ), "%s\\%s agent %s " ,
170- instance_config .remote .path , probackup , PROGRAM_VERSION );
170+ snprintf (cmd , sizeof (cmd ), "%s\\%s agent" ,
171+ instance_config .remote .path , probackup );
171172#else
172173 if (needs_quotes (instance_config .remote .path ) || needs_quotes (PROGRAM_NAME_FULL ))
173- snprintf (cmd , sizeof (cmd ), "\"%s/%s\" agent %s " ,
174- instance_config .remote .path , probackup , PROGRAM_VERSION );
174+ snprintf (cmd , sizeof (cmd ), "\"%s/%s\" agent" ,
175+ instance_config .remote .path , probackup );
175176 else
176- snprintf (cmd , sizeof (cmd ), "%s/%s agent %s " ,
177- instance_config .remote .path , probackup , PROGRAM_VERSION );
177+ snprintf (cmd , sizeof (cmd ), "%s/%s agent" ,
178+ instance_config .remote .path , probackup );
178179#endif
179180 } else {
180181 if (needs_quotes (PROGRAM_NAME_FULL ))
181- snprintf (cmd , sizeof (cmd ), "\"%s\" agent %s " , PROGRAM_NAME_FULL , PROGRAM_VERSION );
182+ snprintf (cmd , sizeof (cmd ), "\"%s\" agent" , PROGRAM_NAME_FULL );
182183 else
183- snprintf (cmd , sizeof (cmd ), "%s agent %s " , PROGRAM_NAME_FULL , PROGRAM_VERSION );
184+ snprintf (cmd , sizeof (cmd ), "%s agent" , PROGRAM_NAME_FULL );
184185 }
185186
186187#ifdef WIN32
@@ -228,5 +229,22 @@ bool launch_agent(void)
228229
229230 fio_redirect (infd [0 ], outfd [1 ], errfd [0 ]); /* write to stdout */
230231 }
232+
233+ /* Make sure that remote agent has the same version
234+ * TODO: we must also check PG version and fork edition
235+ */
236+ agent_version = fio_get_agent_version ();
237+ if (agent_version != AGENT_PROTOCOL_VERSION )
238+ {
239+ char agent_version_str [1024 ];
240+ sprintf (agent_version_str , "%d.%d.%d" ,
241+ agent_version / 10000 ,
242+ (agent_version / 100 ) % 100 ,
243+ agent_version % 100 );
244+
245+ elog (ERROR , "Remote agent version %s does not match local program version %s" ,
246+ agent_version_str , PROGRAM_VERSION );
247+ }
248+
231249 return true;
232250}
0 commit comments