Bug 1582 - rsync dry run cannot find missing folders, contradicts actual run.
rsync dry run cannot find missing folders, contradicts actual run.
Status: CLOSED FIXED
Product: rsync
Classification: Unclassified
Component: core
2.6.2
All IRIX
: P3 normal
: ---
Assigned To: Wayne Davison
Rsync QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2004-08-02 10:38 UTC by Erik Weyers
Modified: 2005-03-16 16:48 UTC (History)
0 users

See Also:


Attachments
Fix problem with --dry-run (-n) (1.05 KB, patch)
2004-08-05 11:21 UTC, Wayne Davison
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Erik Weyers 2004-08-02 10:38:38 UTC
If you are telling rsync to sync to a folder which does not exist, it would
normally create the folder and then continue to run normally.  But if you were
to use the -n dry run option, it can not create the folder and errors out.  This
leaves a user confused as to what happened.

Here is an example, in this example, junkdir does not exist on elk but does
exist on the host.  Normally rsync would then create the directory then copy the
junkdir4 directory as it should.  But with the dry run option (and the -vvv
debugging option to show what is happening) I get this:

/sw/pd/bin/rsync262 -azvvvn --delete --rsync-path=/sw/pd/bin/rsync262
/export/sw/irix/testirix6/junkdir/junkdir4
elk:/export/sw/irix6/sw01/testirix6/junkdir/
opening connection using rsh elk /sw/pd/bin/rsync262 --server -vvvnlogDtprz
--delete . /export/sw/irix6/sw01/testirix6/junkdir/

building file list ...
[sender] make_file(junkdir4,*,2)
[sender] expand file_list to 131072 bytes, did move
[sender] make_file(junkdir4/gar1,*,2)
[sender] make_file(junkdir4/gar2,*,2)
[sender] make_file(junkdir4/gar3,*,2)
[sender] make_file(junkdir4/gardir1,*,2)
[sender] make_file(junkdir4/gardir1/blah2,*,2)
[sender] make_file(junkdir4/gardir1/blah3,*,2)
[sender] make_file(junkdir4/gardir1/blah1,*,2)
[sender] clearing per-dir .cvsignore exclude list
[sender] clearing per-dir .cvsignore exclude list
done
send_file_list done
send_files starting
server_recv(2) starting pid=433406
recv_file_name(junkdir4)
recv_file_name(junkdir4/gar1)
recv_file_name(junkdir4/gar2)
recv_file_name(junkdir4/gar3)
recv_file_name(junkdir4/gardir1)
recv_file_name(junkdir4/gardir1/blah2)
recv_file_name(junkdir4/gardir1/blah3)
recv_file_name(junkdir4/gardir1/blah1)
received 8 names
recv_file_list done
get_local_name count=8 /export/sw/irix6/sw01/testirix6/junkdir/
created directory /export/sw/irix6/sw01/testirix6/junkdir/
push_dir "/export/sw/irix6/sw01/testirix6/junkdir/" failed: No such file or
directory (2)
rsync error: errors selecting input/output files, dirs (code 3) at main.c(355)
_exit_cleanup(code=3, file=main.c, line=355): about to call exit(3)
rsync: connection unexpectedly closed (8 bytes read so far)
rsync error: error in rsync protocol data stream (code 12) at io.c(342)
_exit_cleanup(code=12, file=io.c, line=342): about to call exit(12)

Now if I were to run this without the -n option, it would run normally, which
contradicts what -n option tells us.

/sw/pd/bin/rsync262 -azvvv --delete --rsync-path=/sw/pd/bin/rsync262
/export/sw/irix/testirix6/junkdir/junkdir4
elk:/export/sw/irix6/sw01/testirix6/junkdir/
opening connection using rsh elk /sw/pd/bin/rsync262 --server -vvvlogDtprz
--delete . /export/sw/irix6/sw01/testirix6/junkdir/
building file list ...
[sender] make_file(junkdir4,*,2)
[sender] expand file_list to 131072 bytes, did move
[sender] make_file(junkdir4/gar1,*,2)
[sender] make_file(junkdir4/gar2,*,2)
[sender] make_file(junkdir4/gar3,*,2)
[sender] make_file(junkdir4/gardir1,*,2)
[sender] make_file(junkdir4/gardir1/blah2,*,2)
[sender] make_file(junkdir4/gardir1/blah3,*,2)
[sender] make_file(junkdir4/gardir1/blah1,*,2)
[sender] clearing per-dir .cvsignore exclude list
[sender] clearing per-dir .cvsignore exclude list
done
send_file_list done
send_files starting
server_recv(2) starting pid=432780
recv_file_name(junkdir4)
recv_file_name(junkdir4/gar1)
recv_file_name(junkdir4/gar2)
recv_file_name(junkdir4/gar3)
recv_file_name(junkdir4/gardir1)
recv_file_name(junkdir4/gardir1/blah2)
recv_file_name(junkdir4/gardir1/blah3)
recv_file_name(junkdir4/gardir1/blah1)
received 8 names
recv_file_list done
get_local_name count=8 /export/sw/irix6/sw01/testirix6/junkdir/
created directory /export/sw/irix6/sw01/testirix6/junkdir
send_file_list done
deleting in junkdir4
recv_files(8) starting
generator starting pid=432780 count=8
delta transmission enabled
recv_generator(junkdir4,0)
set modtime of junkdir4 to (1091220597) Fri Jul 30 15:49:57 2004
junkdir4/
recv_generator(junkdir4/gar1,1)
send_files(1, /export/sw/irix/testirix6/junkdir/junkdir4/gar1)
send_files mapped /export/sw/irix/testirix6/junkdir/junkdir4/gar1 of size 0
calling match_sums /export/sw/irix/testirix6/junkdir/junkdir4/gar1
junkdir4/gar1
sending file_sum
false_alarms=0 tag_hits=0 matches=0
sender finished /export/sw/irix/testirix6/junkdir/junkdir4/gar1
recv_generator(junkdir4/gar2,2)
send_files(2, /export/sw/irix/testirix6/junkdir/junkdir4/gar2)
send_files mapped /export/sw/irix/testirix6/junkdir/junkdir4/gar2 of size 0
calling match_sums /export/sw/irix/testirix6/junkdir/junkdir4/gar2
junkdir4/gar2
sending file_sum
false_alarms=0 tag_hits=0 matches=0
sender finished /export/sw/irix/testirix6/junkdir/junkdir4/gar2
recv_generator(junkdir4/gar3,3)
send_files(3, /export/sw/irix/testirix6/junkdir/junkdir4/gar3)
send_files mapped /export/sw/irix/testirix6/junkdir/junkdir4/gar3 of size 0
calling match_sums /export/sw/irix/testirix6/junkdir/junkdir4/gar3
junkdir4/gar3
sending file_sum
false_alarms=0 tag_hits=0 matches=0
sender finished /export/sw/irix/testirix6/junkdir/junkdir4/gar3
recv_generator(junkdir4/gardir1,4)
set modtime of junkdir4/gardir1 to (1091218088) Fri Jul 30 15:08:08 2004
junkdir4/gardir1/
recv_generator(junkdir4/gardir1/blah1,5)
send_files(5, /export/sw/irix/testirix6/junkdir/junkdir4/gardir1/blah1)
send_files mapped /export/sw/irix/testirix6/junkdir/junkdir4/gardir1/blah1 of size 0
calling match_sums /export/sw/irix/testirix6/junkdir/junkdir4/gardir1/blah1
junkdir4/gardir1/blah1
sending file_sum
false_alarms=0 tag_hits=0 matches=0
sender finished /export/sw/irix/testirix6/junkdir/junkdir4/gardir1/blah1
recv_generator(junkdir4/gardir1/blah2,6)
send_files(6, /export/sw/irix/testirix6/junkdir/junkdir4/gardir1/blah2)
send_files mapped /export/sw/irix/testirix6/junkdir/junkdir4/gardir1/blah2 of size 0
calling match_sums /export/sw/irix/testirix6/junkdir/junkdir4/gardir1/blah2
junkdir4/gardir1/blah2
sending file_sum
false_alarms=0 tag_hits=0 matches=0
sender finished /export/sw/irix/testirix6/junkdir/junkdir4/gardir1/blah2
recv_generator(junkdir4/gardir1/blah3,7)
send_files(7, /export/sw/irix/testirix6/junkdir/junkdir4/gardir1/blah3)
send_files mapped /export/sw/irix/testirix6/junkdir/junkdir4/gardir1/blah3 of size 0
calling match_sums /export/sw/irix/testirix6/junkdir/junkdir4/gardir1/blah3
junkdir4/gardir1/blah3
sending file_sum
false_alarms=0 tag_hits=0 matches=0
sender finished /export/sw/irix/testirix6/junkdir/junkdir4/gardir1/blah3
generate_files phase=1
send_files phase=1
recv_files(junkdir4/gar1)
got file_sum
renaming junkdir4/.gar1.433730 to junkdir4/gar1
set modtime of junkdir4/gar1 to (1091205050) Fri Jul 30 11:30:50 2004
recv_files(junkdir4/gar2)
got file_sum
renaming junkdir4/.gar2.433730 to junkdir4/gar2
set modtime of junkdir4/gar2 to (1091205050) Fri Jul 30 11:30:50 2004
recv_files(junkdir4/gar3)
got file_sum
renaming junkdir4/.gar3.433730 to junkdir4/gar3
set modtime of junkdir4/gar3 to (1091205050) Fri Jul 30 11:30:50 2004
recv_files(junkdir4/gardir1/blah1)
got file_sum
renaming junkdir4/gardir1/.blah1.433730 to junkdir4/gardir1/blah1
set modtime of junkdir4/gardir1/blah1 to (1091218088) Fri Jul 30 15:08:08 2004
recv_files(junkdir4/gardir1/blah2)
got file_sum
renaming junkdir4/gardir1/.blah2.433730 to junkdir4/gardir1/blah2
set modtime of junkdir4/gardir1/blah2 to (1091218088) Fri Jul 30 15:08:08 2004
recv_files(junkdir4/gardir1/blah3)
got file_sum
renaming junkdir4/gardir1/.blah3.433730 to junkdir4/gardir1/blah3
set modtime of junkdir4/gardir1/blah3 to (1091218088) Fri Jul 30 15:08:08 2004
recv_files phase=1
generate_files phase=2
send files finished
total: matches=0  tag_hits=0  false_alarms=0 data=0
recv_generator(junkdir4,0)
set modtime of junkdir4 to (1091220597) Fri Jul 30 15:49:57 2004
recv_generator(junkdir4/gardir1,4)
set modtime of junkdir4/gardir1 to (1091218088) Fri Jul 30 15:08:08 2004
generate_files finished
recv_files finished
 
wrote 361 bytes  read 140 bytes  1002.00 bytes/sec
total size is 0  speedup is 0.00
_exit_cleanup(code=0, file=main.c, line=633): about to call exit(0)


This becomes a problem because we need the dry run to work exactly as a normal
run would, only without actually running.  Therefore a user can find out what
will happen in rsyncing the directories without it actually happening.  If they
find they have this error then running the normal command would be questionable. 

I hope this report has been satisfactory.
Comment 1 Wayne Davison 2004-08-05 11:21:34 UTC
Created attachment 594 [details]
Fix problem with --dry-run (-n)

This patch avoids a fatal error when using --dry-run and the destination
directory does not exist on the receiver.
Comment 2 Wayne Davison 2004-08-05 11:23:05 UTC
The fix was checked into CVS.

> I hope this report has been satisfactory.

The report was very well done.  Thanks!
Comment 3 Erik Weyers 2004-08-05 13:27:35 UTC
There appears to be a problem in that my generator.c differs from your
generator.c enough that the patch can not find and patch the correct area.  The
area the patch looks like it's trying to correct on my version looks like this:

	if (list_only)
		return;

	if (verbose > 2)
		rprintf(FINFO,"recv_generator(%s,%d)\n",fname,i);

	statret = link_stat(fname,&st);

	if (only_existing && statret == -1 && errno == ENOENT) {
		/* we only want to update existing files */

This is different from what I have.  Otherwise the pach worked well on main.c so
there is no need to worry about that.  Are there other patches you have used on
generator.c in the past that I need to be aware of?  

Otherwise thank you for looking into this bug.
Comment 4 Wayne Davison 2004-08-05 14:31:26 UTC
(In reply to comment #3)
> Are there other patches you have used on generator.c in the past
> that I need to be aware of?

All the patches I post to bugzilla are relative to the CVS version, so it's not
surprising that you ran into a problem if you tried to patch an earlier release.
You can either snag the CVS version (for instance, the latest nightly tar file
from the rsync website has the fix already applied).  Or you can adapt the fix
for your version.

From the code you cited, here's how I would adapt the fix:

	if (verbose > 2)
		rprintf(FINFO,"recv_generator(%s,%d)\n",fname,i);

	if (dry_run > 1) {
		statret = -1;
		errno = ENOENT;
	} else
		statret = link_stat(fname,&st);

	if (only_existing && statret == -1 && errno == ENOENT) {
		/* we only want to update existing files */
Comment 5 Erik Weyers 2004-08-06 07:34:02 UTC
Thank you very much for your help.