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

index in meta increased for twice #16326

Open
rickif opened this issue Dec 24, 2019 · 5 comments
Open

index in meta increased for twice #16326

rickif opened this issue Dec 24, 2019 · 5 comments
Assignees
Labels

Comments

@rickif
Copy link
Contributor

rickif commented Dec 24, 2019

Steps to reproduce:

influxdb 1.8, 1.7 or some other earlier versions

https://github.com/influxdata/influxdb/blob/f1d26652e91e94e050c4904818d023fe5d6701c3/services/meta/client.go

// SetData overwrites the underlying data in the meta store.
func (c *Client) SetData(data *Data) error {
	c.mu.Lock()

	// reset the index so the commit will fire a change event
	c.cacheData.Index = 0

	// increment the index to force the changed channel to fire
	d := data.Clone()
	d.Index++

	if err := c.commit(d); err != nil {
		return err
	}

	c.mu.Unlock()

	return nil
}

When func (c *Client) SetData(data *Data) error is called, the index of the data increase twice,

one for here:

another:

data.Index++

is that by design?

Expected behavior:

Actual behavior:

Environment info:

Config:

Logs:

Performance:

@russorat russorat added the 1.x label Dec 30, 2019
@russorat
Copy link
Contributor

@rickif thanks for opening this. Is this causing an actual issue for you or are you just curious?

@rickif
Copy link
Contributor Author

rickif commented Jan 1, 2020

thanks for reply.
I'm just curious about this when I study the source code of influxdb 1.8.
I wonder whether it is by design and the purpose of the twice index increment.

@sebito91
Copy link
Contributor

sebito91 commented Jan 2, 2020

I think you might have come across a small bug @rickif! Thanks a lot for reporting this. I'm digging into the code to see exactly what impact removing the data.Index++ inside of SetData will have (as each subsequent call to commit includes an increment).

Will get back to you shortly on this.

@rickif
Copy link
Contributor Author

rickif commented Jan 6, 2020

maybe just removing the line below will work, since the (c *Client) commit(data *Data) error is called everytime the data changed

@rickif
Copy link
Contributor Author

rickif commented Jan 14, 2020

@sebito91 I've submmitied a pull request to fix this issue.
Since it's my first pr, it would be my pleasure if u could take a look
#16525

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants