Commit graph

48 commits

Author SHA1 Message Date
CLoZengineer
f9ddb5d5c1
fix: updating code to meet linting requirements (#2171)
* removes unused filesize function

* removes ioutil usage

* updates ioutil.ReadAll to io.ReadAll

* updates ioutil.TempFile to os.CreateTemp

* updates ioutil.TempDir to os.MkdirTemp

* updates ioutil.ReadAll to os.ReadAll

* update ioutil.WriteFile to os.WriteFile

* updates ioutil.Discard to io.Discard

* updates ioutil.ReadDir to os.ReadDir where applicable

* removes unused code in idk

* creates type to use for context value keys

* replaces assert.Nil with assert.NoError for error checks
2022-09-29 12:34:29 -04:00
Fletcher Haynes
da9b57bd45 Updated dependency paths to reflect new repo location 2022-09-06 09:39:22 -07:00
Fletcher Haynes
eb06bb50ae Updated code to latest version for open-sourcing. 2022-09-02 13:23:39 -07:00
Seebs
e5ffed35a4 use labeled targets for break statements
break in a select in a for terminates the current case of the
select, but does not terminate the for loop. The worker queue
implementations for opening indexes/fields/views all suffered
from the same issue here.

Also fix a `<= 0` on a uint value.

All hail staticcheck.
2019-10-11 14:44:25 -05:00
Ben Johnson
e844e1ad75
Translation store refactor 2019-10-09 08:59:41 -06:00
Ben Johnson
c7c9c1e1d7
v2.0.0
Co-authored-by: Cody Soyland <codysoyland@gmail.com>
2019-10-08 14:56:17 -06:00
Ben Johnson
7ff684c193
Allow partial translate file reads.
This commit fixes an issue where translation `LogEntry` must be
read in its entirety, however, large entries can exceed the buffer
size. This has been changed so that partial entries reads are allowed.

The `LogEntry.ReadFrom()` may still generate large byte slices
during reads of large individual fields or keys.
2019-06-04 10:08:52 -06:00
kuba--
51ac675e82
TranslateFile - reopen the same instance
Signed-off-by: kuba-- <kuba@sourced.tech>
2019-05-02 14:05:40 +02:00
Travis Turner
b46ff7b990
fix some lint warnings raised in VS-Code 2019-04-17 18:10:05 -05:00
Cody Soyland
fdbfc68f7c Add license headers to files missing them and CI check to verify they are present. Fixes #1633 2019-04-12 11:30:41 -05:00
Seebs
cd534af430 prevent deadlock in replication logic on reopening a store
Depending on where in the replicate() loop you are when a
store is closed or reassigned, it's possible for it to deadlock.
The deadlock would be that replicate has just successfully read an
entry from your PrimaryTranslateStore.Reader, when a new
PrimaryTranslateStore event happens. Then handlePrimaryTranslateStore
grabs the mutex, signals that the replication handler should
close, and waits for the replication handler to close. Meanwhile,
the replicate() loop tries to grab the mutex... and deadlocks.

Solution: Make the replicate() loop part that needs the mutex
a goroutine that signals on a channel, so we can put it in a select
along with checking for the replicationClosing signal (or the
context terminating). If one of those happens, replicate()
terminates, allowing monitorReplication() to return, which
causes the anonymous function which called it to call
repWG.Done(), allowing handlePrimaryTranslateStore to continue
and eventually release the mutex. At some later point, appendEntry
succeeds or fails, dumps its result status in a buffered
channel, and exits, and the buffered channel is garbage collected.

This is way simpler than it sounds, but it took me a while
to figure out how simple it was.
2019-01-18 13:24:24 -06:00
Travis Turner
95f05ca4d0
WIP: allow translate log entry buffer to grow
In the case where a translate log entry contained
many key/id pairs, it was possible for the read
buffer (which was allocated at 65536 bytes) to
fail to handle it. This happened when the serialized
LogEntry was larger than 65536 bytes.

This PR adds logic which returns a custom error called
ErrTranslateReadTargetUndersized notifying the reader
to reallocate a larger read buffer and try the read
again.

TODO:
- [ ] Add a max buffer size check to prevent this from doubling the
buffer size with no limit.
- [ ] Add tests.
2018-12-18 09:26:26 -06:00
Matt Jaffee
65f478470f
logging cleanup - start with lowercase unless reporting error or warning 2018-11-20 14:08:06 -06:00
Seebs
a203313143 move Logger and Stats to their own packages
I'd like to add stat tracking to Roaring, which means it
has to be able to import the stats package, which means
stats has to be a package rather than part of the pilosa
package. If stats stops being in pilosa, it still needs
a way to import logger, so logger also has to leave the
pilosa package. Then everything using them needs to import
them and use package selectors on their names.

This doesn't actually add the stats support to roaring,
it just makes it so there's a way to import the stats
code from something in the roaring package.
2018-11-15 15:10:44 -06:00
Todd Gruben
0df193cf98 revert to existing api with panic per jaffee 2018-10-17 10:29:58 -05:00
Todd Gruben
85ebaf298d removed logging from translate store replaced with error 2018-10-01 11:04:47 -05:00
Todd Gruben
a0dda250a5 converted to pilosa.logger 2018-10-01 10:11:10 -05:00
Cody Soyland
81dbe38081 Change wording for consistency 2018-09-25 11:59:52 -05:00
Cody Soyland
2521922d7b Properly wrap translation store errors, decrease test map size to prevent failure on 32-bit 2018-09-25 11:35:58 -05:00
Cody Soyland
52ba336461 Address code review feedback 2018-09-20 16:05:28 -05:00
Cody Soyland
2394d36108 Adjust tests, fix 32-bit config 2018-09-19 13:30:22 -05:00
Cody Soyland
7a32745b28 Make translate map size configurable. 2018-09-19 12:35:00 -05:00
Matt Jaffee
847132d02a
fix race on replicationClosing channel
monitorReplication is now not allowed to return until the goroutine it starts
cancels the context. Previously, it could return just before the context was
canceled which caused a race between its internal goroutine and
handlePrimaryStoreEvent which recreates a channel which that internal goroutine
was listening on.

handlePrimaryStoreEvent already correctly made sure that monitorReplication had
returned before recreating the channel, so proper handling of the sub-goroutine
of monitorReplication was all that was needed to avoid this race.
2018-08-20 11:11:19 -05:00
Travis Turner
d50a0e853c
change NewTranslateStore() to take an interface for backward compatibility 2018-08-13 12:04:22 -05:00
Travis Turner
b304de6536
Treat coordinator as primary translate store.
Daisy-chain other nodes based on their position in the cluster.
Deprecate the `primary-url` configuration option.
2018-08-13 11:06:16 -05:00
Cody Soyland
e76c523135
Merge branch 'master' into 1517-metalinter-unconvert 2018-08-02 11:45:24 -05:00
Cody Soyland
dd7b5f517b
Merge branch 'master' into 1513-metalinter-megacheck 2018-08-02 10:29:47 -05:00
Cody Soyland
be60a91a58 Clarify error string for cases when reading from non-primary translate store when given non-existent key 2018-07-31 12:19:09 -05:00
Travis Turner
3ffafaca4a
ignore remote translation 2018-07-30 11:45:34 -05:00
Cody Soyland
dc50204846 Fix linter issues: unconvert 2018-07-20 11:51:55 -05:00
Cody Soyland
e9523063b5 Fix linter issues: unused 2018-07-20 10:33:29 -05:00
Cody Soyland
f01d850b17 Fix linter issues: gosimple 2018-07-20 09:06:43 -05:00
Cody Soyland
f9625ef4fa Fix linter issues: unparam 2018-07-17 12:05:07 -05:00
Cody Soyland
a7c1795cf7 Unexport TranslateFileReader 2018-07-05 23:11:56 -05:00
Cody Soyland
e4847c498a Unexport TranslateFile.ReplicationRetryInterval 2018-07-05 23:11:56 -05:00
Cody Soyland
7a1d2c6980 Unexport TranslateFile.MapSize 2018-07-05 23:11:56 -05:00
Cody Soyland
4c2ba7b7d3 Unexport TranslateFile.Size 2018-07-05 23:11:56 -05:00
Cody Soyland
ed0372b1d0 Unexport TranslateFile.IsReadOnly 2018-07-05 23:11:56 -05:00
Cody Soyland
9d882469da Unexport NewTranslateFileReader 2018-07-05 23:11:56 -05:00
Cody Soyland
b4b0fd2e64 Unexport LogEntry.HeaderSize 2018-07-05 23:11:56 -05:00
Cody Soyland
9fd8cdb007 Unexport DefaultMapSize 2018-07-05 23:11:56 -05:00
Matt Jaffee
3be609ed10
unexport newCluster and some other stuff 2018-07-02 09:10:09 -05:00
Matt Jaffee
2210480198
unexport some translation related consts, remove an unused one 2018-07-02 08:20:53 -05:00
Matt Jaffee
6bb5bf2602
Merge branch 'develop' into deadcode 2018-06-29 10:11:56 -05:00
Matt Jaffee
6ff792c164
remove dead code (deadcode) 2018-06-29 08:12:04 -05:00
Matt Jaffee
4124bc76a3
define map size separately for 32 and 64 bit systems 2018-06-29 07:18:26 -05:00
Cody Soyland
5d43d414f7 Fix a few data races 2018-06-27 17:00:17 -05:00
Ben Johnson
060254e0d6
Key-to-ID Translation
This commit adds id-to-key translation to make it easier for users
to provide non-integer identifiers for rows & columns.
2018-06-15 16:45:05 -06:00