Commit Graph

68 Commits

Author SHA1 Message Date
Brad Fitzpatrick d1fea28536 sorted/mysql: cap number of queries to 20 at a time
Arbitrary limit, but prevents things from exploding during request spikes.

Fixes camlistore/camlistore#683

Change-Id: I3699d25416fb6bbc1ea4f3b984b0ce05e6abf31b
2016-02-13 13:21:00 -08:00
Brad Fitzpatrick 8cf4f297eb pkg/sorted/sqlkv: don't release gate until iterator is closed
Change-Id: I4c3f5406b89294c09fb1d64aaeffc3c581664acd
2016-02-13 13:20:10 -08:00
Brad Fitzpatrick b3ba9aa7cd sorted/sqlkv, sorted/sqlite: replace Serial bool with a *syncutil.Gate
Change-Id: I820220d49b1d316d2be0ab7fe5bf302d204108b0
2016-02-13 13:01:46 -08:00
Mathieu Lonjaret d20ad1570e Merge "server/synchandler: add exported constructor and IdleWait method" 2016-01-28 00:57:56 +00:00
mpl 1773eb0859 server/synchandler: add exported constructor and IdleWait method
This change allows (for example) to hook a blobserver and an indexer
together in a way similar as they would be in a default Camlistore setup.
This is particularly useful to setup tests that require a realistic
indexer, without having to create a heavier test with e.g. test.World.

This actual goal of this change is described below. I kept these changes
together because the one described below illustrates the need for the
synchandler changes.

pkg/index/stress/: stress test the indexer with more data

The goal of these benchmkarks is to help us compare the various sorted
implementations, so we can pick the most efficient one as a default.

A second, harder, goal would be to add tests that help us estimate the
reliability of the various kv stores, again so we can rule out the buggy
ones, or help fix them.

Change-Id: I8a1fe50398a4ba09c03786502b68b6c2599e5984
2016-01-28 01:56:00 +01:00
mpl c88d81a2fd sorted/mysql: remove DB from pool when closing
Otherwise when openOrCachedDB is called for the second time,
it would return an actually closed DB.

Change-Id: I820834e508fed1a34ab7bd19a8a91e398badff9c
2016-01-06 20:42:52 +01:00
mpl 40be4d8da2 vendor: go4.org/jsonconfig (and errorutil)
Previously pkg/jsonconfig and pkg/errorutil

Copied from go4.org at rev d1b8a2fb2de6160036e4801aa5e4d855571078b8

Change-Id: I673ed55b0825baa2607289b6082f205100261d7a
2015-12-01 17:21:49 +01:00
Brad Fitzpatrick 6f58fc2426 Fix build, move more stuff from third_party to vendor. 2015-08-18 10:19:49 +02:00
Brad Fitzpatrick 06f7accf31 Require Go 1.5 (due out soon), start move from third_party to vendor.
See https://golang.org/s/go15vendor

This commit moves the google.golang.org/cloud/... packages. The rest
of third_party will move later.

This commit is a dependency for some cloud logging work which we'll
develop in Camlistore's tree.
2015-08-15 22:45:11 +02:00
mpl eec23f4a21 serverinit: use user-defined kv type everywhere, otherwise leveldb.
In a few places, cznic/kv use was hardcoded, instead of picking the user
set kv type, if any. This change makes sure we use the user-defined one,
if set, syndtr/leveldb otherwise.

Relatedly, the low-level config generated for diskpacked now uses that
same principle for its internal index. Also, if a diskpacked is
configured without an index, it now defaults to syndtr/leveldb.

Please note that this patch DOES NOT change the default kv type in the
automatically generated high-level config.

Related: #632

Change-Id: I55dbd385230878e92776e6b83d34c36fd1fa9382
2015-08-05 16:54:29 +02:00
Tamás Gulácsi 95703e8039 pkg/sorted/sqlkv: cache query after placeholder replacement
Store the strings, as the TODO said.
This memoization saves 9/10 of running time:

BenchmarkSql-4 (before)         300000     5429 ns/op
BenchmarkSql-4 (after)          3000000     430 ns/op

Change-Id: I4edabff96043620b5af3f5b507ddd75d65b22ff1
2015-07-01 21:31:13 +02:00
Tamás Gulácsi a9a7cd73fc Upgrade github.com/syndtr/goleveldb
Commit 4875955338b0a434238a31165cb87255ab6e9e4a

Because camlistored ate my CPU time (constant 170% from 2 cpu, GOMAXPROCS=1):

(pprof) top10
36 of 40 total (90.00%)
Showing top 10 nodes out of 75 (cum >= 3)
      flat  flat%   sum%        cum   cum%
         1  2.50%  2.50%         40   100%  runtime.goexit
        35 87.50% 90.00%         35 87.50%  runtime.gopark
         0     0% 90.00%         21 52.50%  runtime.selectgo
         0     0% 90.00%         21 52.50%  runtime.selectgoImpl
         0     0% 90.00%          9 22.50%  runtime.goparkunlock
         0     0% 90.00%          5 12.50%  runtime.chanrecv
         0     0% 90.00%          3  7.50%  camlistore.org/third_party/github.com/syndtr/goleveldb/leveldb.(*DB).compactionError
         0     0% 90.00%          3  7.50%  camlistore.org/third_party/github.com/syndtr/goleveldb/leveldb.(*DB).jWriter
         0     0% 90.00%          3  7.50%  camlistore.org/third_party/github.com/syndtr/goleveldb/leveldb.(*DB).mCompaction
         0     0% 90.00%          3  7.50%  camlistore.org/third_party/github.com/syndtr/goleveldb/leveldb.(*DB).mpoolDrain

Change-Id: I792840b32bcb04d304621e61fca87aeb30f21b91
2015-04-22 22:48:16 +02:00
Brad Fitzpatrick f3ae8c8c9a sorted: fix crash on double close of memory iterator
The sorted.KeyValue and Iterator interfaces both promise that it's okay
to Close twice.

Change-Id: I169f84d64c86da86e1be417b6be8551fd4d20ced
2015-04-13 20:38:42 +02:00
Brad Fitzpatrick af36d78bd7 env: add IsDev and use it everywhere
Change-Id: I5547ce989c05f1f48774f24abee41c489326baa0
2015-04-02 05:55:01 -07:00
Brad Fitzpatrick c9a0beae45 Add new 'env' package to detect the type of environment.
Also, delete my old gce package from third_party and only use the
google metadata package (which my gce package became, and which was
also already vendored into third_party)

Fixes #596

Change-Id: I64fd6f1e9dc6f433466f91f81efd2ecbf039334f
2015-04-01 08:45:36 -07:00
mpl f6bf779cd6 sorted/kvtest: close iterator ASAP to make sqlite happy
Change-Id: I7dcca4447bea262fedc6a5fbe572034bfd8cc61d
2015-03-12 16:15:56 +01:00
mpl 763a8a9e8e Merge "sorted/kv: typo in comment about max size" 2015-01-26 19:10:41 +00:00
mpl ae989d0d19 sorted/kv: typo in comment about max size
Change-Id: I8423e7ff798cc040d684f0182be17fafda1b0331
2015-01-26 20:10:02 +01:00
mpl 36dd866f36 Merge "pkg/sorted: define (larger) values for key and value sizes" 2015-01-26 19:05:22 +00:00
mpl ae38f657b8 pkg/sorted: define (larger) values for key and value sizes
Issue #429

Change-Id: Id8205ca1581c1f21b3983e13d8c3f61293868529
2015-01-26 19:39:41 +01:00
Brad Fitzpatrick aada432c52 third_party: add oauth2/google, google.golang.org/cloud, google.golang.org/api
oauth2 at 267028f9bc2a1177dc5769be38c68c1b4fbe91c4
google cloud at 2e43671e4ad874a7bca65746ff3edb38e6e93762
google api at fc402b0d6f2a46ba7dcf0a4606031f45fb82a728
  (partial commit only, since it's 16+ MB)

And update all callers from the old
code.google.com/p/google-api-go-client over to google.golang.org/api.

Change-Id: Ide190e04bb863928f98369a7c4d2b8c19fda1f66
2015-01-22 15:10:36 -08:00
Brad Fitzpatrick c4f0a62e84 sorted: add Foreach and ForeachInRange helpers
Change-Id: Ifeba7ed6719468f01585aa7f7f9a9006fdd661de
2014-10-28 05:07:55 -07:00
Tamás Gulácsi 550a8a51b3 Add sorted/leveldb.
Modify pkg/sorted/kvfile/kvfile.go to not have a named
return in Next - just as in pkg/sorted/leveldb/leveldb.go.

Change-Id: I0d46a86b33d2e1d2992d8a41f08979eb21aaddbb
2014-09-23 18:20:27 +02:00
mpl df7952b9ba mysql: create database now distinct from create tables
Because we do not want the database name to be optional with a
placeholder (/*DB*/) in the statement that creates the database, since
it is not actually optional there - as opposed to when creating tables.

Change-Id: I05351d76d95071492d763758a11454f219524510
2014-08-08 20:06:02 +02:00
Brad Fitzpatrick 031c6199da sorted/mysql: automatically find IPs of hosts named *.cloudsql.google.internal
Change-Id: Ib03add64c2c6b4de7fc6059f2a9c22065e2b2e7d
2014-08-06 17:28:55 -07:00
Brad Fitzpatrick 1e7d12f1df sqlkv: remove one of the sql expansion funcs. make batch use KeyValue's
Fixes bug with TablePrefix where batch mutations weren't getting the db prefix.

Change-Id: Ice599e607f070e374471e5ff22b426a6a5e05800
2014-08-06 17:23:43 -07:00
Brad Fitzpatrick ac5c2fd045 sorted/mysql: create the db too if it doesn't exist.
Change-Id: I566d49052057848e9d4af0f01243a89db367e20a
2014-08-06 17:21:42 -07:00
Brad Fitzpatrick 6513d525c6 sorted/mysql: don't put database name in the DSN, share connections
Change-Id: Ia4d399e72a1290f68dc2b0de71945176c6aac482
2014-08-06 16:15:08 -07:00
Brad Fitzpatrick d6a8ecce2d sorted/sqlkv: support for adding optional 'db.' prefix before table names
This is so configurations using the same database server for many
databases (multiple queues + the index) can all share the same
underlying *sql.DB

Change-Id: Iae7d4835fe9045008709c953e36b729729b1b6f4
2014-08-06 16:13:18 -07:00
Brad Fitzpatrick b65868d754 serverinit: allow specifying port numbers in user@server:port:pass
With heuristics and tests.

Change-Id: Ifacfc725db15100c447a3251c23267a5bfd313cf
2014-08-06 15:07:43 -07:00
Brad Fitzpatrick 511c3aad12 sqlite: skip test instead of failing when not compiled in
Change-Id: If7ef7308cdb7b6aec5490ec332d4dace7b7565a0
2014-08-02 10:45:49 -07:00
Andrew Gerrand c15b4c05a7 pkg/sorted/buffer: flesh out, add test
Change-Id: I18f57425ad2e9a4d692d4efe865fea81e8f143e3
2014-07-15 08:24:54 +10:00
Brad Fitzpatrick a352572e0a sorted/buffer: start of a sorted.KeyValue buffer for reindexing
Change-Id: I2617d98d6cb0b32548723ca45620b05eab91bca2
2014-06-27 12:02:16 -07:00
mpl 45ce6cfdd3 mysql: replace mymysql with go-sql-driver
from github.com/go-sql-driver/mysql at 9a7aa3606b82e2081a13a008ada88dfdb96c20fd

Context: http://camlistore.org/issue/428

Change-Id: Ia93ac35da02933bd03d2c6b7b8e5e549ba0472cb
2014-05-01 17:42:51 +02:00
mpl a9db189cd7 docker tests: remove container when done
http://camlistore.org/issue/421

Change-Id: Iefde3a8235db0103e8fcfac51f5dfcce5df73ef6
2014-04-09 23:26:14 +02:00
mpl 899acb8e72 pkg/sorted: remove API for each distinct implementation
Change-Id: I42446683189cdb00dcfbec1f221885092fdd83d6
2014-04-08 01:37:08 +02:00
Steven L. Speek 3e50f83b1c pkg/sorted/postgres: Renamed "postgresql" -> "postgres" in init()
Change-Id: I8f1ba7c970b57c62741e534c23958918714cee0b
Fixes: Issue 418
2014-04-06 21:47:53 +02:00
mpl b0c4f85ee0 sorted/postgres: test with docker
Also, NewKeyValue now automatically creates the required tables.

http://camlistore.org/issue/263

Change-Id: I02dd7660ee08c2eaeec17131622d6f581fdd6c55
2014-03-28 19:34:09 +01:00
mpl 08f9c821f5 sorted,dockertest: added MySQL (dockerified) test
Two important related changes:

1) sorted/mysql now takes into account the host given in the config
2) the required tables are now automatically created by NewKeyValue

http://camlistore.org/issue/263

Change-Id: I0043f36edb0630d6484148508d3a1e08c8e88a94
2014-03-26 00:39:38 +01:00
Govert Versluis 96637ffcd3 pkg/blobserver/mongo: Add support for blob storage in MongoDB
Related changes:
Split docker-related test-helper functions from pkg/sorted/mongo.
These helper functions are now also used in the pkg/blobserver/mongo
tests too.
Also fixed a typo in a comment in pkg/blob/fetcher.go and a missing variable in
debug output in pkg/blobserver/storagetest/storagetest.go

Addresses http://camlistore.org/issue/127

Change-Id: I8b6f57f9ced066d6f83788fdcc87be6619c65c3c

Conflicts:
	pkg/blob/fetcher.go
2014-03-22 12:36:59 -07:00
mpl 23ef1cf24b sorted/kvfile: added test
http://camlistore.org/issue/263

Change-Id: I4f6e8fe3cb26bedcff0a09278924364c249a3291
2014-03-20 23:57:05 +01:00
mpl 05058091e9 kvutil: add VerifyDb*, use kvutil in sorted
http://camlistore.org/issue/393

Change-Id: If9482aa05f2346644196e3218dcde571e4d1a1a1
2014-03-20 01:21:27 +01:00
mpl 4ac7601315 sorted/kv: enable VerifyDb* options with env var
http://camlistore.org/issue/393

Change-Id: I97bbe3d4ab6eb186c3960db0995cedeec3a34ddf
2014-03-20 00:04:18 +01:00
mpl 2dd3e17129 sorted/sqlite: initialize DB when needed, added test.
Change-Id: Ibd418e357e2bed6a5beed2dda2f947c7c999fe92
2014-03-19 18:16:05 +01:00
Brad Fitzpatrick 3c00ed347c mongo: test using Docker
Under a second to start and test against a real MongoDB instace in Docker:

$ go test -v camlistore.org/pkg/sorted/mongo
=== RUN TestMongoKV
--- PASS: TestMongoKV (0.79 seconds)
PASS
ok      camlistore.org/pkg/sorted/mongo 0.791s

Test is skipped in short mode, or if docker isn't available.

Change-Id: I6f3acc96357cf9c50054b3df6727661c9329e6bf
2014-02-09 20:02:56 -08:00
Bill Thiede fe25884b71 pkg/sorted/kvfile: faster wipe.
Delete the underlying DB file instead of iterating over the contents and
deleting item by item.

Change-Id: I1328c44b447ba9b1dc1cf81fdaf1f2437f80a071
2013-12-24 21:27:49 -08:00
Brad Fitzpatrick 289065c730 sorted/kvfile: make it actually compile
Change-Id: I0a3916c1c260dfac6b3444a18510a013d429ef33
2013-12-24 15:35:29 -08:00
Bill Thiede de3a5d1941 pkg/sorted/kvfile: add sorted.Wiper.
This allows people with kvIndexFile in their server-config.json to run:
camlistored -reindex

Change-Id: If1008297fa29ca514260529edb2125a1ea7d5246
2013-12-24 13:15:24 -08:00
Brad Fitzpatrick a11ff22b8e camlistored: add --reindex flag; make sqlkv a sorted.Wiper
Change-Id: I6b16c1c32187fb754d3acdbe852d02a506236078
2013-12-23 19:07:17 -08:00
mpl 8fec95752c pkg/index: move postgresql to sorted + some fixes
Change-Id: Ia6410256ffe8d4cbc2b9a5c056d075707105ab08
2013-12-24 00:37:14 +01:00