Skip to content

Conversation

robbavey
Copy link
Contributor

@robbavey robbavey commented Jun 1, 2021

This is a workaround for jruby/jruby#6693 - stat
is currently reporting incorrect values of uid and gid on aarch64 linux
nodes, and appears to be setting uid and gid to 0, ie root

This workaround will only attempt to call chown if the unlikely event that the
permissions have changed. This will also "fallback" to a non-atomic write in the event
that an atomic write fails.

@serializer.serialize(@sincedb, io, time.to_f)
end
rescue => e
logger.warn("sincedb_write: unable to write atomically, falling back to non-atomic write: #{path} error:", :exception => e.class, :message => e.message)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you foresee atomic write potentially recovering, later?
if not maybe we would want the switch permanently to non-atomic ... (on the caller end).
guess this is rare, still seems like we would produce a lot of the same warn-ings (which might be fine 🤔).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good question. I think it might make sense to make the change 'sticky' in the event of permission errors, which are probably unlikely to recover later, and leave as is in the event of other errors.

Copy link
Contributor

@kares kares left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, intermittent 🔴 CI taken care of on master

robbavey added 4 commits June 9, 2021 11:20
This is a workaround for jruby/jruby#6693 - stat
is currently reporting incorrect values of `uid` and `gid` on aarch64 linux
nodes, and appears to be setting `uid` and `gid` to 0, ie `root`

It is highly unlikely that `chown` needs to be called on the file - and even more unlikely
that `chown` would succeed anyway - `chmod` typically requires superuser privileges, unless
the change of ownerhip is a change of group to another group the user is already a member of.

This workaround updates the code to only attempt to call `chown` in the unlikely event that file ownership
of the temp file is different from the original file, which should avoid the scenario that is currently
occurring due to the above jruby bug. This commit also falls back to a non-atomic write in the event
of a failure to write the file atomically.
…errors

if `atomic_write` fails due to permission errors, update the write method to
be `:non_atomic_write` to avoid unnecessary warn logs every time this occurs.

This commit also adds trace logging to the `atomic_write` and `non_atomic_write`.
@robbavey robbavey merged commit 55aac0a into logstash-plugins:master Jun 9, 2021
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.

3 participants