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

distsql: add NewFinalIterator to the rowIterator interface #26441

Merged
merged 1 commit into from
Jun 6, 2018
Merged

distsql: add NewFinalIterator to the rowIterator interface #26441

merged 1 commit into from
Jun 6, 2018

Conversation

asubiotto
Copy link
Contributor

Some implementations of the rowIterator interface would destroy rows as
they were iterated over to free memory eagerly. NewFinalIterator is
introduced in this change to provide non-reusable behavior and
NewIterator is explicitly described as reusable.

A reusable iterator has been added to the memRowContainer to satisfy
these new interface semantics.

Release note: None

@asubiotto asubiotto requested review from jordanlewis and a team June 5, 2018 20:25
@cockroach-teamcity
Copy link
Member

This change is Reviewable

@rjnn
Copy link
Contributor

rjnn commented Jun 5, 2018

:lgtm_strong: Good interface design!

Might be worth adding a boolean to the implementors that track whether a final iterator was created, which errors out on any further iteration creations, just to eagerly ensure callers of final iterator are not messing up. this proactive checking would avoid a problem where we actually make destructive final iterator implementations in the future, and only then discover the bugs lurking underneath.


Review status: all files reviewed at latest revision, all discussions resolved, some commit checks pending.


Comments from Reviewable

@asubiotto
Copy link
Contributor Author

@arjunravinarayan I'm not sure whether we should do that because it is technically valid to call NewFinalIterator a second time, you just won't read any rows unless you added to the rowContainer. I think it won't be that likely to run into any surprise issues because NewIterator would probably be the default that most people use (just like {Unsafe}Key in RocksDB).

bors r+

@jordanlewis
Copy link
Member

Review status: all files reviewed at latest revision, all discussions resolved, some commit checks pending.


pkg/sql/distsqlrun/row_container.go, line 38 at r1 (raw file):

	// NewFinalIterator returns a rowIterator that can be used to iterate over the
	// rows. The use of this method indicates to the implementer that the row will
	// never be read again. Consult implementations for exact behavior.

I find this phrasing a little confusing - I would probably say something like "NewFinalIterator returns a rowIterator that can be used to iterate over the rows, possibly freeing resources along the way. Once you call NewFinalIterator, subsequent calls to NewIterator or NewFinalIterator are not guaranteed to return any rows."


Comments from Reviewable

@jordanlewis
Copy link
Member

:lgtm:


Review status: all files reviewed at latest revision, 1 unresolved discussion, some commit checks pending.


Comments from Reviewable

@asubiotto
Copy link
Contributor Author

bors r-

@craig
Copy link
Contributor

craig bot commented Jun 6, 2018

Canceled

Some implementations of the rowIterator interface would destroy rows as
they were iterated over to free memory eagerly. NewFinalIterator is
introduced in this change to provide non-reusable behavior and
NewIterator is explicitly described as reusable.

A reusable iterator has been added to the memRowContainer to satisfy
these new interface semantics.

Release note: None
@asubiotto
Copy link
Contributor Author

Review status: all files reviewed at latest revision, 1 unresolved discussion, some commit checks failed.


pkg/sql/distsqlrun/row_container.go, line 38 at r1 (raw file):

Previously, jordanlewis (Jordan Lewis) wrote…

I find this phrasing a little confusing - I would probably say something like "NewFinalIterator returns a rowIterator that can be used to iterate over the rows, possibly freeing resources along the way. Once you call NewFinalIterator, subsequent calls to NewIterator or NewFinalIterator are not guaranteed to return any rows."

Done.


Comments from Reviewable

@asubiotto
Copy link
Contributor Author

bors r+

craig bot pushed a commit that referenced this pull request Jun 6, 2018
26441: distsql: add NewFinalIterator to the rowIterator interface r=asubiotto a=asubiotto

Some implementations of the rowIterator interface would destroy rows as
they were iterated over to free memory eagerly. NewFinalIterator is
introduced in this change to provide non-reusable behavior and
NewIterator is explicitly described as reusable.

A reusable iterator has been added to the memRowContainer to satisfy
these new interface semantics.

Release note: None

26463: storage: Disable campaign-on-wake when receiving raft messages r=bdarnell a=bdarnell

When the incoming message is a MsgVote (which is likely the case for
the first message received by a quiesced follower), immediate
campaigning will cause the election to fail.

This is similar to reverting commit 44e3977, but only disables
campaigning in one location.

Fixes #26391

Release note: None

26469: lint: Fix a file descriptor leak r=bdarnell a=bdarnell

This leak is enough to cause `make lintshort` fail when run under the
default file descriptor limit on macos (256).

Release note: None

26470: build: Pin go.uuid to the version currently in use r=bdarnell a=bdarnell

Updates #26332

Release note: None

Co-authored-by: Alfonso Subiotto Marqués <[email protected]>
Co-authored-by: Ben Darnell <[email protected]>
@craig
Copy link
Contributor

craig bot commented Jun 6, 2018

Build succeeded

@craig craig bot merged commit b0ab0d6 into cockroachdb:master Jun 6, 2018
@asubiotto asubiotto deleted the dest-iter branch June 11, 2018 16:22
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.

4 participants