Commit graph

1612 commits

Author SHA1 Message Date
martinsumner
938cc0fc16 Re-add tests
Oops - committed with tests commented out
2016-10-12 17:35:32 +01:00
martinsumner
0a08867280 Iterator support
Add iterator support, used initially only for retrieving bucket
statistics.

The iterator is supported by exporting a function, and when the function
is claled it will take a snapshot of the ledger, run the iterator and
hten close the snapshot.

This required a numbe rof underlying changes, in particular to get key
comparison to work as "expected".  The code had previously misunderstood
how comparison worked between Erlang terms, and in particular did not
account for tuple length being compared first by size of the tuple (and
not just by each element in order).
2016-10-12 17:12:49 +01:00
martinsumner
d2cc07a9eb Doc update and clerk<->penciller changes
Reviewing code to update comments revealed a weakness in the sequence of
events between penciller and clerk committing a manifest change wherby
an ill-timed crash could lead to files being deleted without the
manifest changing.

A different, and safer pattern now used between theses two actors.
2016-10-09 22:33:45 +01:00
martinsumner
4a8a2c1555 Code reduction refactor
An attempt to refactor out more complex code.

The Penciller clerk and Penciller have been re-shaped so that there
relationship is much simpler, and also to make sure that they shut down
much more neatly when the clerk is busy to avoid crashdumps in ct tests.

The CDB now has a binary_mode - so that we don't do binary_to_term twice
... although this may have made things slower ??!!?  Perhaps the
is_binary check now required on read is an overhead.  Perhaps it is some
other mystery.

There is now a more effiicient fetching of the size on pcl_load now as
well.
2016-10-08 22:15:48 +01:00
martinsumner
8dfeb520ef Inker Refactor
Inker refactored to block on manifest write.  If this is inefficient the
manifets write can be converted ot an append only operation.

Waiting on the manifest write makes the logic at startup much easier to
manage.
2016-10-07 18:07:03 +01:00
martinsumner
2055f8ed3f Add more complex snapshot test
This exposed another off-by-one error on startup.

This commit also includes an unsafe change to reply early from a rolling
CDB file (with lots of objects writing the hash table can take too
long).  This is bad, but will be resolved through a refactor of the
manifest writing:  essentially we deferred writing of the manifest
update which was an unnecessary performance optimisation.  If instead we
wait on this, the process is made substantially simpler, and it is safer
to perform the roll of the complete CDB journal asynchronously.  If the
manifest update takes too long, an append-only log may be used instead.
2016-10-07 10:04:48 +01:00
martinsumner
f58f4d0ea5 Mini Refactor
Thought about the mess, thought about swithcing to a FSM, throught about
just sorting a bit of the mess instead.
2016-10-06 13:23:20 +01:00
martinsumner
ad5aebe93e Further work on system tests
Another issue exposed with laziness in the using an incomplete ledger
when checking for presence during compaction.
2016-10-05 18:28:31 +01:00
martinsumner
d903f184fd Add initial end-to-end common tests
These tests highlighted some logical issues when scanning over databases
on startup, so fixes are wrapped in here.
2016-10-05 09:54:53 +01:00
martinsumner
507428bd0b Add initial system test
Add some initial system tests.  This highlighted issues:
- That files deleted by compaction would be left orphaned and not close,
and would not in fact delete (now deleted by closure only)
- There was an issue on stratup that the first few keys in each journal
would not be re-loaded into the ledger
2016-10-03 23:34:28 +01:00
martinsumner
15f57a0b4a Further Journal compaction tests
Improved unit testing
2016-09-28 18:26:52 +01:00
martinsumner
50b50ba486 Inker Clerk - Further Testing
Expanded the unit tetsing of the Inker Clerk actor.  Still WIP
2016-09-28 11:41:56 +01:00
martinsumner
d24b100aa6 Initial work on Journal Compaction
Largely untested work at this stage to allow for the Inker to request
the Inker's clerk to perform a single round of compact based on the best
run of files it can find.
2016-09-27 14:58:26 +01:00
martinsumner
e2bb09b873 Snapshot testing
Work to test the checking of sequence numbers in snapshots as required
by the inkers clerk to calculate the percentage of a file which is
compactable
2016-09-26 10:55:08 +01:00
martinsumner
c64d67d9fb Snapshot Work - Interim Commit
Some initial work to get snapshots going.

Changes required, as need to snapshot through the Bookie to ensure that
there is no race between extracting the Bookie's in-memory view and the
Penciller's view if a push_to_mem has occurred inbetween.

A lot still outstanding, especially around Inker snapshots, and handling
timeouts
2016-09-23 18:50:29 +01:00
martinsumner
d3e985ed80 Refactor Penciller Push
Two aspects of pushing to the penciller have been refactored:
1 - Allow the penciller to respond before the ETS table has been updated
to unlock the Bookie sooner.
2 - Change the way the copy of the memtable is stored to work more
effectively with snapshots wihtout locking the Penciller any further on
a snapshot or push request
2016-09-21 18:31:42 +01:00
martinsumner
66d6db4e11 Support for random sampling
Makes the ability to get positions and the fetch directly by position
more generic - supporting the fetch of different flavours of
combinations, and requesting a sample of positions not just all
2016-09-20 18:24:05 +01:00
martinsumner
aa7d235c4d Rename clerk and CDB Speed-Up
CDB did many "bitty" reads/writes when scanning or writing hash tables -
change these to bult reads and writes to speed up.

CDB also added capabilities to fetch positions and get keys by position
to help with iclerk role.
2016-09-20 16:13:36 +01:00
martinsumner
c10eaa75cb Dialyzer changes
Some chnages to improve dialyzer pass rate
2016-09-20 10:17:24 +01:00
martinsumner
4e28e4173c Rebar and eunit changes
Initial rebar compile - which exposed eunit tets failures associated
with changes to file structures and filename references
2016-09-19 18:50:11 +01:00
martinsumner
a1c970a66a Manifest ordering
Be more explicit about manifest ordering to stop keys being laoded in
incorrect order
2016-09-19 15:56:35 +01:00
martinsumner
7c28ffbd96 Further bookie test - CDB optimisation and Inker manifest correction
Additional bookie test revealed that the persisting/reading of inker
manifests was inconsistent and buggy.

Also, the CDB files were inffeciently writing the top index table -
needed to be improved as this is blokicng on a roll
2016-09-19 15:31:26 +01:00
martinsumner
b452fbe27c End-to-end test
Changes to ensure working of first end-to-end test (with a single Key
and Value)
2016-09-15 18:38:23 +01:00
martinsumner
5127119669 First draft of bookie
Now with the most simple of tests
2016-09-15 15:14:49 +01:00
martinsumner
e73a5bbf31 WIP - First draft of Bookie code
First draft of untested bookie code
2016-09-15 10:53:24 +01:00
martinsumner
86666b1cb6 Scan over CDB file
Make scanning over a CDB file generic rather than specific to read-in of
active nursery log - open to be called as an external function to
support other scanning behaviour.
2016-09-09 15:58:19 +01:00
martinsumner
edfe9e3bed Improved testing
Improve testing of Penciller to show startup and shutdown with push,
merging and fetch
2016-09-08 14:21:30 +01:00
martinsumner
0d905639be Testing of Inker rolling Journal
Add test to show inker rolling journal.  to achieve needs to make CDB
size an option, and also alter the manifest sorting so that
find_in_manifest actually works!
2016-09-07 17:58:12 +01:00
martinsumner
f0e1c1d7ea Basic GET/PUT and rolling in Inker
Add support to roll file on PUT in the inker
2016-09-06 17:17:31 +01:00
martinsumner
f3a40e106d Inker improvements
Resolve issue in CDB file when we have cached the index.  Allow for
Inker to find keys in the active journal
2016-09-05 20:22:16 +01:00
martinsumner
2a76eb364e Inker - Initial Code
An attempt to get a first inker that can build a ledger from a manifest
as well as support simple get and put operations.  Basic tests surround
the building of manifests only at this stage - more work required for
get and put.
2016-09-05 15:01:23 +01:00
martinsumner
ce0c55a2ec Resolve issue of Remainders
Two issues looked at
- There shouldn't be a remainder after writing the L0 file, as this
could have overlapping sequence numbers which will be missed on restart
- There should be a safety-check to stop the Clerk from doing a fake
push too soon after a background L0 file ahs been written (as the fake
push would lock the ledger waiting for the L0 file write to finish)
2016-08-16 12:45:48 +01:00
martinsumner
4586e2340a Startup and Shutdown Support
Added support for startup and shutdown of a Ledger.  As aprt of this
will now start tracking the highest sequence number.  This also adds a
safety check on pcl_pushmem to make sure that only keys with a higher
sequenc enumber are being pushed in - and hence we can happily insert
into the in-memory view without checking the sequence number.
2016-08-15 16:43:39 +01:00
martinsumner
6e56b569b8 Auto-merge
Allow for the clerk to merge continuously is no activity for the
penciller to prompt.

The penciller now must also correctly lock the manifest - to stop races
between the creation of ne wL0 files and the completion of work by the
clerk
2016-08-12 01:05:59 +01:00
martinsumner
c269eb3c52 Initial level merging
Some basic merging in the lsm tree.
2016-08-10 13:02:08 +01:00
martinsumner
718425633a Penciller accepting push
Standardise on record definitions between modules to make easier - then
add functionality to pushing to penciller as bookie would do.  Some
initial manual testing of this seems OK.
2016-08-09 16:09:29 +01:00
martinsumner
75996b90ca Remove file
Not needed yet
2016-08-02 17:54:13 +01:00
martinsumner
33f1efd576 Work on descriptions
Add further descriptions of roles following name changes.  Attempt to
simplify manifest management in the Penciller by assuming there is only
one Penciller's Clerk active - and so only one piece of work can be
ongoing
2016-08-02 17:51:43 +01:00
martinsumner
2bdb5fba6c Re-naming
Naming things is hard.  This change renames things based on the
Bookie/Inker/Penciller terminology
2016-08-02 13:44:48 +01:00
martinsumner
04da891272 Tidy up removing old files 2016-07-29 17:52:44 +01:00
martinsumner
b5db1b4e14 CDB to gen_server
First draft to make CDB a gen_Server
2016-07-29 17:48:11 +01:00
martinsumner
28f612426a Reformat of CDB
CDB was failing tests (was it always this way?).  There has been a
little bit of a patch-up of the test, but there are still some
potentially outstanding issues with scanning over a file when attempting
to read beyond the end of the file.

Tabbing reformatting and general tidy.

Concierge documentation development ongoing.
2016-07-29 17:19:30 +01:00
martinsumner
c1f6a042d9 Renaming
Delete some old working files and adopt a new naming convention.  The
keymanager actor has now been replaced by a concierge, to reflect that
this management role is performed at the front of house
2016-07-28 17:22:50 +01:00
martinsumner
a2d873a06d Add first draft of manager
Start to build up functions for the keymanager
2016-07-27 18:03:44 +01:00
martinsumner
a07ea27dd8 Add merging of files
Add first function of worker - the ability to merge multiple files
together from different levels
2016-07-22 16:57:28 +01:00
martinsumner
d96ac87fb5 Add gitignore
Ignore beam files
2016-07-12 19:45:22 +01:00
martinsumner
392830c839 Improve test clean-up
Remove file created in a test
2016-07-12 19:44:16 +01:00
martinsumner
45c10613e7 Iterator support added
Initial support for iterators
2016-07-12 19:42:50 +01:00
martinsumner
9dae893958 Read-only opening
Completing the file also closes it and leads to a read-only opening of
the file.
2016-07-07 11:43:26 +01:00
martinsumner
3b954aea43 Some refinements
Minor amendments to formatting and outputs
2016-07-06 18:09:40 +01:00