Repository navigation
fix(decomposedfs): [OCISDEV-943] return WriteResult with SpaceOwner f… - #615
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
b7cd836 to
77d16f2
Compare
I think you got it wrong. The user will eventually be sent through the channel, and I'd expect the receiver to block until it receives the user (because it's a blocking channel). With the PR, the sender won't block, and it's possible that it won't send the user if the channel is full. This seems riskier than the previous solution. I have no idea why it's implemented this way, but I feel there is something wrong and there should be a better solution. |
@jvillafanez |
@jvillafanez If I understand it correctly, this is a non-blocking read, because of the default case. So it tries to read the value from the channel, but if nothing was written yet, it just continues. This mean 1) it's a race condition, because if the goroutine with the writer has not been started yet, nothing will be read. I did see this behavior in practices while debugging, the spaceOwnerId was not reliably set. I'm confident that the old channel implementation did not work correctly & did test that the current implementation fixes it. However, we can still discuss alternatives, e.g. having a slot instead of a channel |
Yes, you're right. I didn't see that code piece.
It should be possible to set a pointer in the context. The callee could modify the pointed value without changing the reference in the context, so the caller would see the change. You can check https://github.com/owncloud/reva/pull/619/changes#diff-3704079fb17387ef8fb9459d686e0de5c11acdf6260aef4f93b92207ce080d95 as an example. I think that's more or less what you want to do. It needs to be easy and very transparent to use, basically a "Get" and a "Set" (with a big warning). From an usability point of view, I just want to know that setting the user might change the user in parent contexts (because we're using a pointer). |
@jvillafanez |
|
Some additional things:
The problem I see there is that it set up a dangerous precedent: if I need to get the space owner somewhere else, I'll be more inclined to copy this existing code, which could break things because I'll overwrite any existing space owner in the context. Using a |
|
Nothing more to add from me 👍 |
d58bd41 to
6e5a8cd
Compare
…rom write operations test(decomposedfs): [OCISDEV-943] verify WriteResult SpaceOwner in integration tests remove licence header review comments review comment review comments review comments review comments review comments review comments revert setting owner in Lock events & var rename make event usage consistent Make move event usage consistent to other events add cephfs error handling
270fa40 to
11d67f7
Compare
CreateDir, TouchFile, RestoreRevision, RestoreRecycleItem, SetLock and Unlock now return a typed result with the space owner instead of pushing it through a channel registered in the context. The events middleware registers a slot, the storageprovider writes the owner from the result into it, and the middleware reads it after the handler returned. That replaces the goroutine + channel dance, which could drop the owner when the select ran before the goroutine sent it. The move result slot follows the same pattern now and the middleware no longer builds an ItemMoved event without a move result. Our trashbin interface differs from upstream (it is space id based and returns the restored node), so Decomposedfs.RestoreRecycleItem builds the result from the restored node instead of the trashbin returning it. The cephfs, s3 and cbox eoswrapper drivers do not exist here. backport of owncloud#615 Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Jörn Friedrich Dreyer <[email protected]>
The goal is to move
storagespace.ContextSendSpaceOwnerID(ctx, rn.SpaceOwnerOrManager(ctx))out of drivers, to make events driver independent & drivers don't implement event specific logic. Instead, this channel is populated in the storageprovider now.2 additional changes:
The channel had a race condition, so it's not guarenteed the ownerId got set. With refactoring, this race condition is happening more often. Race condition got fixed by using a buffered channel instead & making the sending blocking:
sendOwnerChan := make(chan *user.UserId, 1)Additionally, conversion.go had a bug, that
FileLocked&FileUnlockedevent conversion did not pass the ownerId.