Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

client crash on copying non empty directory #105

Open
evgmik opened this issue Mar 9, 2021 · 4 comments
Open

client crash on copying non empty directory #105

evgmik opened this issue Mar 9, 2021 · 4 comments
Labels
bug Anything that derives from the defined functionality major Major issue

Comments

@evgmik
Copy link
Collaborator

evgmik commented Mar 9, 2021

Steps to reproduce: start fresh and do

$ ali touch /test/dir1/t1
$ ali touch /test/dir1/t2
$ ali touch /test/dir1/t3
$ ali cp /test/dir1 /test/copydir1
08.03.2021/23:47:49 ⚡ cmd/parser.go:598:  panic rollback: runtime error: slice bounds out of range [14:13]; stack: goroutine 219 [running]:
runtime/debug.Stack(0xc0001767b0, 0xc0003f0140, 0xc000a780a0)
        /usr/lib/go-1.14/src/runtime/debug/stack.go:24 +0x9d

I just show first line of the crash report. Depending on what inside of the parent dir (I think it subdirs), the repo database could be left in a broken state.

While we at it, it would be nice to be able to copy to non-existing path. For example, in above to do ali cp /test/dir1 /to/new/non/existing/dir

@evgmik evgmik added bug Anything that derives from the defined functionality major Major issue labels Mar 9, 2021
@sahib
Copy link
Owner

sahib commented Mar 10, 2021

Will check next.

[...] the repo database could be left in a broken state.

It should not, there is some defence against crashes in the linker. If the state got broken that is a separate bug.

While we at it, it would be nice to be able to copy to non-existing path. For example, in above to do ali cp /test/dir1 /to/new/non/existing/dir

I guess we can do a mkdir in the client to make this work.

@evgmik
Copy link
Collaborator Author

evgmik commented Mar 11, 2021

While we at it, it would be nice to be able to copy to non-existing path. For example, in above to do ali cp /test/dir1 /to/new/non/existing/dir

I guess we can do a mkdir in the client to make this work.

Note that staging to non existing dir works, i.e.

$ ali tree
•

1 directory, 0 files
$ ali touch /to/new/non/existing/dir/testfile
$ ali tree
• ✔
└── to/ ✔
   └── new/ ✔
      └── non/ ✔
         └── existing/ ✔
            └── dir/ ✔
               └── testfile ✔

6 directories, 1 file

Which deviates from standard shell touch. So the question, shall we preserve shell cp style and the current brig, where the destination dir must exist, or shall we allow such copy to succeed?

@evgmik
Copy link
Collaborator Author

evgmik commented Apr 11, 2021

Still digging the top most bug description with recursive copy, apparently we have a problem when a directory copied inside of another directory. Looks like Walk get into recursion of some type or maybe adding a child to a parent triggers consequent Walk over itself.

Quick questions: how content of the directory is calculated? Is it based on names of the children or their content?

Also, am I right that Tree hash is calculated based on the full path to the node? If I am right, than what is the point? We can just use full path for the DB key.

Also, order field in the directory node, seems to be unneeded. It can be calculated on a fly, from the children names.

@sahib
Copy link
Owner

sahib commented Apr 11, 2021

Looks like Walk get into recursion of some type or maybe adding a child to a parent triggers consequent Walk over itself.

IIRC the logic for NotifyMove was not made for the Copy() case. It gets confused about the paths. I had a quick look and decided that it's probably wise to first do the staging-related re-design in linker.

Quick questions: how content of the directory is calculated? Is it based on names of the children or their content?

It's only based on the directory path, no content involved.

Also, am I right that Tree hash is calculated based on the full path to the node? If I am right, than what is the point? We can just use full path for the DB key.

That would only serve as key for one version of that file.

Also, order field in the directory node, seems to be unneeded. It can be calculated on a fly, from the children names.

Partly yes, It trades storage against CPU. On Add() for example we can do a log(n) binary search for the insert, while on the fly we have to do n * log(n). Do you suspect a problem with the storage space?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Anything that derives from the defined functionality major Major issue
Projects
None yet
Development

No branches or pull requests

2 participants