Skip to content

kvserver: sync cluster version setting to store#55240

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
tbg:sync-cluster-vers
Oct 8, 2020
Merged

kvserver: sync cluster version setting to store#55240
craig[bot] merged 1 commit intocockroachdb:masterfrom
tbg:sync-cluster-vers

Conversation

@tbg
Copy link
Copy Markdown
Member

@tbg tbg commented Oct 6, 2020

Writes to a storage.Engine are not sync'ed by default, meaning that
they can get lost due to an ill-timed crash.

Fixes #54906.

(The backport will take care of #54908).

Release note (bug fix): a rare scenario in which a node would refuse
to start after updating the binary was fixed. The log message would
indicate: "store [...], last used with cockroach version [...], is too
old for running version [...] (which requires data from [...] or
later)".

@tbg tbg requested a review from irfansharif October 6, 2020 10:13
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Collaborator

@petermattis petermattis left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @irfansharif and @tbg)


pkg/kv/kvserver/store.go, line 2784 at r1 (raw file):

		return err
	}
	return eng.Flush() // make it durable

This is a big hammer as it causes the memtable to be flushed. I think it is better to change c-deps/libroach/engine.cc:DBImpl::{Put,Merge,Delete,SingleDelete,DeleteRange} to specify options.sync = true.

Or create a batch here and commit it with Commit(true). But my preference is doing the fix in libroach.

I'm separately trying to determine how many places we're using a raw DB for writes.

@tbg tbg force-pushed the sync-cluster-vers branch from 2e8814c to 7295103 Compare October 6, 2020 12:45
@tbg tbg requested a review from petermattis October 6, 2020 12:48
Copy link
Copy Markdown
Member Author

@tbg tbg left a comment

Choose a reason for hiding this comment

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

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @irfansharif and @petermattis)


pkg/kv/kvserver/store.go, line 2784 at r1 (raw file):

Previously, petermattis (Peter Mattis) wrote…

This is a big hammer as it causes the memtable to be flushed. I think it is better to change c-deps/libroach/engine.cc:DBImpl::{Put,Merge,Delete,SingleDelete,DeleteRange} to specify options.sync = true.

Or create a batch here and commit it with Commit(true). But my preference is doing the fix in libroach.

I'm separately trying to determine how many places we're using a raw DB for writes.

That seems like a bigger semantic change, one which I in principle support, but do we want that to be the thing we backport to all branches? I would rather go with the minimal PR here (i.e. NewBatch) and flip the default separately.

Copy link
Copy Markdown
Collaborator

@petermattis petermattis left a comment

Choose a reason for hiding this comment

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

:lgtm:

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @irfansharif, @petermattis, and @tbg)


pkg/kv/kvserver/store.go, line 2784 at r1 (raw file):

Previously, tbg (Tobias Grieger) wrote…

That seems like a bigger semantic change, one which I in principle support, but do we want that to be the thing we backport to all branches? I would rather go with the minimal PR here (i.e. NewBatch) and flip the default separately.

It is a bigger change, though note that storage.Pebble is doing sync mutations for these operations. So the semantic change has already been made for 20.2 (and 20.1 clusters running Pebble). I'm good with this change, just want to gently push you to make the more central fix.

@tbg
Copy link
Copy Markdown
Member Author

tbg commented Oct 6, 2020

I just saw the result of your investigation on slack, so SGTM about the central fix. Will ping when updated.

@tbg tbg force-pushed the sync-cluster-vers branch from 7295103 to 58850f8 Compare October 6, 2020 12:56
Copy link
Copy Markdown
Member Author

@tbg tbg left a comment

Choose a reason for hiding this comment

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

Updated.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (and 1 stale) (waiting on @irfansharif and @tbg)

Copy link
Copy Markdown
Collaborator

@petermattis petermattis left a comment

Choose a reason for hiding this comment

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

:lgtm_strong:

I hope my confidence here doesn't come back to bite me.

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @irfansharif and @tbg)

Writes to a RocksDB `storage.Engine` were not sync'ed by default,
meaning that they can get lost due to an ill-timed crash. They are now,
matching pebble's behavior. This affects only WriteClusterVersion,
updateBootstrapInfoLocked, WriteLastUpTimestamp, and Compactor.Suggest,
nonw of which are performance sensitive.

Fixes cockroachdb#54906.

(The backport will take care of cockroachdb#54908).

Release note (bug fix): a rare scenario in which a node would refuse
to start after updating the binary was fixed. The log message would
indicate: "store [...], last used with cockroach version [...], is too
old for running version [...] (which requires data from [...] or
later)".
@tbg tbg force-pushed the sync-cluster-vers branch from 58850f8 to ccd12ed Compare October 8, 2020 11:42
@tbg
Copy link
Copy Markdown
Member Author

tbg commented Oct 8, 2020

bors r=petermattis

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Oct 8, 2020

Build succeeded:

@craig craig bot merged commit 91afced into cockroachdb:master Oct 8, 2020
itsbilal added a commit to itsbilal/cockroach that referenced this pull request Oct 19, 2020
Currently, doing direct mutations on a RocksDB instance bypasses
custom batching / syncing logic that we've built on top of it.
This, or something internal to RocksDB, started leading to some bugs
when all direct mutations started passing in WriteOptions.sync = true
(see cockroachdb#55240 for when this change went in).

In this change, direct mutations still commit the batch with sync=true
to guarantee WAL syncing, but they go through the batch commit pipeline
too, just like the vast majority of operations already do.

Fixes cockroachdb#55362.

Release note: None.
itsbilal added a commit to itsbilal/cockroach that referenced this pull request Oct 19, 2020
Currently, doing direct mutations on a RocksDB instance bypasses
custom batching / syncing logic that we've built on top of it.
This, or something internal to RocksDB, started leading to some bugs
when all direct mutations started passing in WriteOptions.sync = true
(see cockroachdb#55240 for when this change went in).

In this change, direct mutations still commit the batch with sync=true
to guarantee WAL syncing, but they go through the batch commit pipeline
too, just like the vast majority of operations already do.

Fixes cockroachdb#55362.

Release note: None.
itsbilal added a commit to itsbilal/cockroach that referenced this pull request Oct 20, 2020
Currently, doing direct mutations on a RocksDB instance bypasses
custom batching / syncing logic that we've built on top of it.
This, or something internal to RocksDB, started leading to some bugs
when all direct mutations started passing in WriteOptions.sync = true
(see cockroachdb#55240 for when this change went in).

In this change, direct mutations still commit the batch with sync=true
to guarantee WAL syncing, but they go through the batch commit pipeline
too, just like the vast majority of operations already do.

Fixes cockroachdb#55362.

Release note: None.
itsbilal added a commit to itsbilal/cockroach that referenced this pull request Oct 20, 2020
Currently, doing direct mutations on a RocksDB instance bypasses
custom batching / syncing logic that we've built on top of it.
This, or something internal to RocksDB, started leading to some bugs
when all direct mutations started passing in WriteOptions.sync = true
(see cockroachdb#55240 for when this change went in).

In this change, direct mutations still commit the batch with sync=true
to guarantee WAL syncing, but they go through the batch commit pipeline
too, just like the vast majority of operations already do.

Fixes cockroachdb#55362.

Release note: None.
craig bot pushed a commit that referenced this pull request Oct 20, 2020
55708: storage: Use batches for direct RocksDB mutations r=itsbilal a=itsbilal

Currently, doing direct mutations on a RocksDB instance bypasses
custom batching / syncing logic that we've built on top of it.
This, or something internal to RocksDB, started leading to some bugs
when all direct mutations started passing in WriteOptions.sync = true
(see #55240 for when this change went in).

In this change, direct mutations still commit the batch with sync=true
to guarantee WAL syncing, but they go through the batch commit pipeline
too, just like the vast majority of operations already do.

Fixes #55362.

Release note: None.

55734: server: skip unit'ed engines in tombstone storage r=irfansharif a=tbg

Empty (i.e. uninitialized engines) could receive tombstones before
being initialized. Initialization checks that the engine is empty
(save for the cluster version) and thus failed. Simply don't write
tombstones to uninitialized engines, which is fine since by the
time the callbacks fire, at least one is initialized anyway, and
besides, this mechanism is best effort.

The alternatives would have been to either allow tombstones to
be present on an engine that is being bootstrapped, or to give
the storage the option to defer writing to the engine once it's
bootstrapped. Neither seemed worth the extra work.

Fixes #55576.

Release note: None


55739: opt: fix normalization of st_distance when use_spheroid parameter used r=rytaft a=rytaft

This commit fixes the normalization rule that converts `st_distance` to
`st_dwithin` or `st_dwithinexclusive`, which was broken in the case when
the `use_spheroid` parameter was used. Prior to this commit, the rule was
assigning the `use_spheroid` parameter as the 3rd parameter to `st_dwithin`
or `st_dwithinexclusive` and the `distance` parameter as the 4th, but that
order does not match the function signatures. This commit fixes the issue
by assigning `distance` as the 3rd parameter and `use_spheroid` as the 4th
if it exists.

Fixes #55675

Release note (bug fix): Fixed an internal error that could occur during
query planning when the use_spheroid parameter was used in the ST_Distance
function as part of a filter predicate. For example, `SELECT ... WHERE
ST_Distance(geog1, geog2, false) < 10` previously caused an error. This
has now been fixed.

Co-authored-by: Bilal Akhtar <bilal@cockroachlabs.com>
Co-authored-by: Tobias Grieger <tobias.b.grieger@gmail.com>
Co-authored-by: Rebecca Taft <becca@cockroachlabs.com>
itsbilal added a commit to itsbilal/cockroach that referenced this pull request Nov 11, 2020
Currently, doing direct mutations on a RocksDB instance bypasses
custom batching / syncing logic that we've built on top of it.
This, or something internal to RocksDB, started leading to some bugs
when all direct mutations started passing in WriteOptions.sync = true
(see cockroachdb#55240 for when this change went in).

In this change, direct mutations still commit the batch with sync=true
to guarantee WAL syncing, but they go through the batch commit pipeline
too, just like the vast majority of operations already do.

Fixes cockroachdb#55362.

Release note: None.
itsbilal added a commit to itsbilal/cockroach that referenced this pull request Nov 11, 2020
Currently, doing direct mutations on a RocksDB instance bypasses
custom batching / syncing logic that we've built on top of it.
This, or something internal to RocksDB, started leading to some bugs
when all direct mutations started passing in WriteOptions.sync = true
(see cockroachdb#55240 for when this change went in).

In this change, direct mutations still commit the batch with sync=true
to guarantee WAL syncing, but they go through the batch commit pipeline
too, just like the vast majority of operations already do.

Fixes cockroachdb#55362.

Release note: None.
@rafiss rafiss added this to the 20.2 milestone Apr 22, 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.

roachtest: decommission/mixed-versions failed

4 participants