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

lib/repo: Enable locking by default, make API non-experimental #1555

Closed

Conversation

cgwalters
Copy link
Member

The code has been sitting around for a while but since I disabled
it by default, I doubt anyone is really using it or relying on it.

This patch makes the existing APIs public, and turns on locking
by default. Conceptually these are two distinct things, and we
may actually want to split up the patches.

I don't think this will break anyone, but it's hard to say for sure.
It's also going to be hard to find out until we actually release
I suspect...

But anyone who is broken should be able to add locking=false into
their repo config.

On the APIs - I'm a bit concerned about the interactions over time
between libostree's use of the API and any apps that start using it.
For example, if an app specifies a SHARED lock in their code, then
later internally we decide to temporarily grab an EXCLUSIVE, but the
app had a second thread/process that was EXCLUSIVE already, and
that process was waiting on the first bit of code, then we could
deadlock. I can't think of a real world situation where this would happen
yet though.

@cgwalters
Copy link
Member Author

Previous discussion: #813

@jlebon
Copy link
Member

jlebon commented Apr 24, 2018

So, that seems sane to me. Though I'd like @dbnicholson to chime in if possible.

On the APIs - I'm a bit concerned about the interactions over time
between libostree's use of the API and any apps that start using it.

Hmm, I guess we could start annotating APIs that use the lock to try to help avoid this?

@cgwalters
Copy link
Member Author

AFAICS flatpak isn't today using the repo locking APIs. @dbnicholson Are you aware of any applications which are today?

Perhaps the maximally conservative thing to do here is to keep the APIs private, and gradually extend the set of things that are safe to do concurrently with internal locking.

For example today we didn't add locking to checkouts; we could do so later and document it as now safe.

@dbnicholson
Copy link
Member

AFAIK, it's all internal. Even our flatpak fork isn't using the locking directly, but I don't think we've received any more corrupted repo reports since we enabled the locking for transactions and prunes.

Sorry for not picking this up again. I'm definitely interested in completing this, but it's hard for me to find time to work on it.

I do believe that ultimately you'd want to have this be public so that clients can be in control. I envision a couple ways you'd want to control the locking externally:

  • Taking an exclusive lock before doing a series of maintenance operations. Sort of like taking an exclusive lock at the beginning of a fsck operation, but where the app is doing more than one operation. For example, I would definitely take an exclusive lock in https://raw.githubusercontent.com/endlessm/eos-meta/master/eos-tech-support/eos-fix-ostree-repo if that was available.

  • Taking a shared lock before doing a pull in anticipation of doing a subsequent checkout to ensure the ref/commit doesn't go away before doing the checkout.

The code has been sitting around for a while but since I disabled
it by default, I doubt anyone is really using it or relying on it.

This patch and turns on locking by default, and also drops the
API which was only public in the experimental API builds.
Conceptually these are two distinct things, and we
may actually want to split up the patches.

I don't think this will break anyone, but it's hard to say for sure.
It's also going to be hard to find out until we actually release
I suspect...

But anyone who is broken should be able to add `locking=false` into
their repo config.  On the flip side Endless has been shipping with
this enabled and it is reported to help.

The reason to drop the APIs: I'm a bit concerned about the interactions over time
between libostree's use of the API and any apps that start using it.
For example, if an app specifies a SHARED lock in their code, then
later internally we decide to temporarily grab an `EXCLUSIVE`, but the
app had a second thread/process that was `EXCLUSIVE` already, and
that process was waiting on the first bit of code, then we could
deadlock. I can't think of a real world situation where this would happen
yet though.

We are likely to in the future have say `fsck` take an external lock,
`checkout` grab a shared one, etc.
@cgwalters cgwalters force-pushed the repo-locking-not-experimental branch from 40aed10 to 77b0ef1 Compare April 24, 2018 16:23
@cgwalters
Copy link
Member Author

cgwalters commented Apr 24, 2018

I do believe that ultimately you'd want to have this be public so that clients can be in control. I envision a couple ways you'd want to control the locking externally:

I feel like concurrency cases divide into two: Those which mutate refs, and those that don't.

Taking a shared lock before doing a pull in anticipation of doing a subsequent checkout to ensure the ref/commit doesn't go away before doing the checkout.

But that just feels weird to me. Generally a set of refs is going to be "owned" by a particular piece of software, so it could do its own locking too. For flatpak for example I don't think we'd have some non-flatpak software going in and replacing flathub:runtime/org.gimp.GIMP.Locale/x86_64/stable or whatever right? Same for the host ref cases.

I'm not opposed to adding ostree locking for this, but would we really want flatpak/gnome-software or whatever simultaneously doing a checkout/deploy for a ref and updating it?

For example, I would definitely take an exclusive lock in https://raw.githubusercontent.com/endlessm/eos-meta/master/eos-tech-support/eos-fix-ostree-repo if that was available.

This one is interesting; we should drain some of this logic into libostree's fsck too.

@cgwalters
Copy link
Member Author

Anyways for now I reworked this patch again to make the APIs unconditionally private for now. We can always change that later.

@cgwalters
Copy link
Member Author

@rh-atomic-bot delegate=dbnicholson

@rh-atomic-bot
Copy link

✌️ @dbnicholson can now approve this pull request

@jlebon
Copy link
Member

jlebon commented Apr 30, 2018

I'm going to merge this. I haven't personally played much with locking=true, but seeing the testsuite happy and knowing Endless has been running with it on for a while, I think this is pretty safe at this point. And there's always a locking=false escape hatch if needed.

@rh-atomic-bot r+ 77b0ef1

@rh-atomic-bot
Copy link

⌛ Testing commit 77b0ef1 with merge 4f93ea6...

rh-atomic-bot pushed a commit that referenced this pull request Apr 30, 2018
The code has been sitting around for a while but since I disabled
it by default, I doubt anyone is really using it or relying on it.

This patch and turns on locking by default, and also drops the
API which was only public in the experimental API builds.
Conceptually these are two distinct things, and we
may actually want to split up the patches.

I don't think this will break anyone, but it's hard to say for sure.
It's also going to be hard to find out until we actually release
I suspect...

But anyone who is broken should be able to add `locking=false` into
their repo config.  On the flip side Endless has been shipping with
this enabled and it is reported to help.

The reason to drop the APIs: I'm a bit concerned about the interactions over time
between libostree's use of the API and any apps that start using it.
For example, if an app specifies a SHARED lock in their code, then
later internally we decide to temporarily grab an `EXCLUSIVE`, but the
app had a second thread/process that was `EXCLUSIVE` already, and
that process was waiting on the first bit of code, then we could
deadlock. I can't think of a real world situation where this would happen
yet though.

We are likely to in the future have say `fsck` take an external lock,
`checkout` grab a shared one, etc.

Closes: #1555
Approved by: jlebon
@rh-atomic-bot
Copy link

💔 Test failed - status-atomicjenkins

@jlebon
Copy link
Member

jlebon commented Apr 30, 2018

@rh-atomic-bot retry

@rh-atomic-bot
Copy link

⌛ Testing commit 77b0ef1 with merge de8cdfa...

rh-atomic-bot pushed a commit that referenced this pull request Apr 30, 2018
The code has been sitting around for a while but since I disabled
it by default, I doubt anyone is really using it or relying on it.

This patch and turns on locking by default, and also drops the
API which was only public in the experimental API builds.
Conceptually these are two distinct things, and we
may actually want to split up the patches.

I don't think this will break anyone, but it's hard to say for sure.
It's also going to be hard to find out until we actually release
I suspect...

But anyone who is broken should be able to add `locking=false` into
their repo config.  On the flip side Endless has been shipping with
this enabled and it is reported to help.

The reason to drop the APIs: I'm a bit concerned about the interactions over time
between libostree's use of the API and any apps that start using it.
For example, if an app specifies a SHARED lock in their code, then
later internally we decide to temporarily grab an `EXCLUSIVE`, but the
app had a second thread/process that was `EXCLUSIVE` already, and
that process was waiting on the first bit of code, then we could
deadlock. I can't think of a real world situation where this would happen
yet though.

We are likely to in the future have say `fsck` take an external lock,
`checkout` grab a shared one, etc.

Closes: #1555
Approved by: jlebon
@rh-atomic-bot
Copy link

💔 Test failed - status-atomicjenkins

@cgwalters
Copy link
Member Author

@rh-atomic-bot retry

@rh-atomic-bot
Copy link

⌛ Testing commit 77b0ef1 with merge 8c15421...

@rh-atomic-bot
Copy link

☀️ Test successful - status-atomicjenkins
Approved by: jlebon
Pushing 8c15421 to master...

giuseppe added a commit to giuseppe/image that referenced this pull request May 30, 2018
Since ostreedev/ostree#1555, locking is
enabled by default in OSTree.  Unfortunately it uses thread-private
data and it breaks the Golang bindings.  Force the same thread for the
write operations to the OSTree repository.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
giuseppe added a commit to giuseppe/skopeo that referenced this pull request May 30, 2018
Needed to pick up this change:

ostree: use the same thread for ostree operations

Since ostreedev/ostree#1555, locking is
enabled by default in OSTree.  Unfortunately it uses thread-private
data and it breaks the Golang bindings.  Force the same thread for the
write operations to the OSTree repository.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
giuseppe added a commit to giuseppe/skopeo that referenced this pull request May 30, 2018
Needed to pick up this change:

ostree: use the same thread for ostree operations

Since ostreedev/ostree#1555, locking is
enabled by default in OSTree.  Unfortunately it uses thread-private
data and it breaks the Golang bindings.  Force the same thread for the
write operations to the OSTree repository.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Jamesjaj2dc6j added a commit to Jamesjaj2dc6j/lucascalsilvaa that referenced this pull request Jun 6, 2022
Since ostreedev/ostree#1555, locking is
enabled by default in OSTree.  Unfortunately it uses thread-private
data and it breaks the Golang bindings.  Force the same thread for the
write operations to the OSTree repository.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
mrhyperbit23z0d added a commit to mrhyperbit23z0d/thomasdarimont that referenced this pull request Jun 6, 2022
Since ostreedev/ostree#1555, locking is
enabled by default in OSTree.  Unfortunately it uses thread-private
data and it breaks the Golang bindings.  Force the same thread for the
write operations to the OSTree repository.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
easyriderk0c9g added a commit to easyriderk0c9g/rnin9 that referenced this pull request Jun 6, 2022
Since ostreedev/ostree#1555, locking is
enabled by default in OSTree.  Unfortunately it uses thread-private
data and it breaks the Golang bindings.  Force the same thread for the
write operations to the OSTree repository.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
oguzturker8ijm8l added a commit to oguzturker8ijm8l/diwir that referenced this pull request Jun 6, 2022
Since ostreedev/ostree#1555, locking is
enabled by default in OSTree.  Unfortunately it uses thread-private
data and it breaks the Golang bindings.  Force the same thread for the
write operations to the OSTree repository.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
wesnowm added a commit to wesnowm/MatfOOP- that referenced this pull request Jun 6, 2022
Since ostreedev/ostree#1555, locking is
enabled by default in OSTree.  Unfortunately it uses thread-private
data and it breaks the Golang bindings.  Force the same thread for the
write operations to the OSTree repository.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
gaveen3 added a commit to gaveen3/KimJeongHoon3x that referenced this pull request Jun 6, 2022
Since ostreedev/ostree#1555, locking is
enabled by default in OSTree.  Unfortunately it uses thread-private
data and it breaks the Golang bindings.  Force the same thread for the
write operations to the OSTree repository.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
gaveen3 added a commit to gaveen3/KimJeongHoon3x that referenced this pull request Jun 6, 2022
Since ostreedev/ostree#1555, locking is
enabled by default in OSTree.  Unfortunately it uses thread-private
data and it breaks the Golang bindings.  Force the same thread for the
write operations to the OSTree repository.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Manuel-Suarez-Abascal80n9y added a commit to Manuel-Suarez-Abascal80n9y/knimeu that referenced this pull request Oct 7, 2022
Since ostreedev/ostree#1555, locking is
enabled by default in OSTree.  Unfortunately it uses thread-private
data and it breaks the Golang bindings.  Force the same thread for the
write operations to the OSTree repository.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
straiforos8bsh5n added a commit to straiforos8bsh5n/tokingsq that referenced this pull request Oct 7, 2022
Since ostreedev/ostree#1555, locking is
enabled by default in OSTree.  Unfortunately it uses thread-private
data and it breaks the Golang bindings.  Force the same thread for the
write operations to the OSTree repository.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants