Commit Graph

28 Commits

Author SHA1 Message Date
Katie Mancini
b3441294e0 fix copy paste error in logs
Summary: I had copy pasted these error messages from rocks db code. lets make them say sqlite instead

Reviewed By: xavierd

Differential Revision: D40803445

fbshipit-source-id: 7c2060dc8b611a7d28c3dbb4163955458ce218b9
2022-10-28 10:45:49 -07:00
Katie Mancini
0c6d420baf allow delayed opening of sqlite db
Summary:
opening the localstore can delay starting up the EdenFS server. I don't think
we use the Sqlite LocalStore any where (though we use RockDB for the overlay).
But I am going to allow the RockDbLocalStore to use a delayed open pattern, so
might as well teach sqlite to work this way to.

Reviewed By: mshroyer, xavierd

Differential Revision: D38839387

fbshipit-source-id: 1496d421fe210cd8d409c6fcc4303ad79dab066a
2022-08-19 10:45:59 -07:00
Zeyi (Rice) Fan
b617e1c1b5 sqlite: add tests for sqlite
Summary:
We didn't have unit tests for `SqliteStatement`, `SqliteDatabase` nor `PersistentSqliteStatement`.

This diff adds some tests to cover it.

Reviewed By: genevievehelsel

Differential Revision: D36297019

fbshipit-source-id: e622b95b1426c9ade9cc884b65f4dc84bfb96f93
2022-05-11 19:12:10 -07:00
Zeyi (Rice) Fan
d5dd991979 Redo "[edenfs] treeoverlay: set upper limit for journal size""
Summary:
Original commit changeset: 9f97d166f621

Original Phabricator Diff: D35624964 (ed17b57094)

This is the exact backout of the backout diff, but depends on D36264955 which fixes the underlying issue that was causing the crash.

Reviewed By: chadaustin

Differential Revision: D36254037

fbshipit-source-id: a5c62ed3d41a6da467ff76abd8239912dcc2c1d0
2022-05-11 19:12:10 -07:00
Zeyi (Rice) Fan
52fadad515 Fix a crash in SqliteStatement
Summary:
We were seeing a crash on Windows and this diff fixes that.

`sqlite3_reset` will return the same error code as it did in `sqlite3_step` if there is any error happened during that statement execution.

This was fine previously because the exception was handled when we call `sqlite3_step`. However after my previous diff, we are calling `sqlite3_reset` in the newly introduced scope guard.

This means we will be rethrowing the same exception in the destructor, causing EdenFS to crash.

Reviewed By: xavierd

Differential Revision: D36264955

fbshipit-source-id: 26322307b366ba637431144ee132ca82f894f21f
2022-05-11 19:12:10 -07:00
Zeyi (Rice) Fan
2152b8ec6e Back out "treeoverlay: set upper limit for journal size"
Summary:
Original commit changeset: ac900be288d0

Original Phabricator Diff: D35321408 (36b3b05242)

Original commit changeset: 9f97d166f621

Original Phabricator Diff: D35624964 (ed17b57094)

We are seeing some crashes in overlay and it should be these two diffs. Backing them out for now.

Reviewed By: kmancini

Differential Revision: D36254038

fbshipit-source-id: 19cf91e425f3caa20853077cfe18ca8e34a0da9a
2022-05-09 16:58:57 -07:00
Zeyi (Rice) Fan
36b3b05242 treeoverlay: set upper limit for journal size
Summary:
We often get reports complaining `treeoverlay.db-WAL` is too big on user's machine.

The issue here is that, we never get a chance to let SQLite run wal checkpoint because we never close the connection to SQLite database.

In which case, we can run the maintenance job ourselves to keep the journal file small. This diff adds a periodical task in EdenServer to give tree overlay a chance to run `wal_checkpoint`.

Reviewed By: xavierd

Differential Revision: D35321408

fbshipit-source-id: ac900be288d0919785876b93a9bde2166871c56a
2022-05-03 14:31:45 -07:00
Zeyi (Rice) Fan
ed17b57094 sqlite: add a SqliteStatement::Guard to reset cached statement correctly
Summary:
In my next diff, I am adding a maintenance task for SQLite to run wal checkpoints periodically. However, prepared select statements will prevent wal checkpoint from succeeding if they are not reset.

This diff introduces a `SqliteStatement::Guard` to reset the prepared statement correctly, and this has proven to unblock wal checkpoint for overlays.

Reviewed By: xavierd

Differential Revision: D35624964

fbshipit-source-id: 9f97d166f62131ae5cff7e29afe9e49d6398e7ef
2022-05-03 14:31:45 -07:00
Xavier Deguillard
a29d465ee8 fs: fix license header
Summary:
With Facebook having been renamed Meta Platforms, we need to change the license
headers.

Reviewed By: fanzeyi

Differential Revision: D33407812

fbshipit-source-id: b11bfbbf13a48873f0cea75f212cc7b07a68fb2e
2022-01-04 15:00:07 -08:00
Zeyi (Rice) Fan
af1f5d62ee overlay: use PersistentSqliteStatement in TreeOverlayStore
Summary: This diff replaces `SqliteStatement` in `TreeOverlayStore` with the new `PersistendSqliteStatement`.

Reviewed By: chadaustin

Differential Revision: D26656314

fbshipit-source-id: dbbfeddd52d3be2a1b5d3b6121d3694c41841fd5
2021-03-15 12:01:48 -07:00
Zeyi (Rice) Fan
89b98ecba6 sqlite: persist statements used in SqliteDatabase
Summary: This diff introduce `StatementCache` for `SqliteDatabase` for caching transaction related SQLite statements.

Reviewed By: chadaustin

Differential Revision: D26656312

fbshipit-source-id: db8b061baa187c9540d1a1a5fcf2f95c3b8a40d0
2021-03-15 12:01:48 -07:00
Zeyi (Rice) Fan
6bba048ea7 sqlite: make SqliteStatement persistent
Summary:
This diff makes `SqliteStatement` to construct persistent statement by default.

This change should be harmless if the caching assumption is not true. If the statement is not cached by the caller, it's probably on a non-critical path.

Reviewed By: chadaustin

Differential Revision: D26639365

fbshipit-source-id: 26af6ccdba036dc0fccf774e9ffb6bb2a014c5ff
2021-03-15 12:01:48 -07:00
Zeyi (Rice) Fan
6162023789 sqlite: split Sqlite.h
Summary: This diff splits Sqlite.h into smaller files so it's easier to change.

Reviewed By: xavierd

Differential Revision: D26656315

fbshipit-source-id: 8156b1d8feef47e5bad4ab66ad5f5f96cf32547e
2021-03-15 12:01:47 -07:00
Zeyi (Rice) Fan
47d68e2769 overlay: add TreeOverlayStore
Summary:
This diff adds `TreeOverlayStore` that is used in following diffs to store tree
data in SQLite database. This class encapsulates the SQL statments needed for
storing trees.

Reviewed By: chadaustin

Differential Revision: D24083787

fbshipit-source-id: 61c08617fe50e7eac94c614948f5ba5355dba71a
2021-03-02 09:58:18 -08:00
Zeyi (Rice) Fan
0327b74975 sqlite: add more logging
Summary:
This diff adds more logging to SQLite so we can see what statements are being
executed in logs. Setting `eden.fs.sqlite=DBG9` will show every SQL statement
being executed and bound values.

Reviewed By: chadaustin

Differential Revision: D25223472

fbshipit-source-id: ed089b7ec112c75d9f7bc63d9fe53f0ec2bd6420
2021-03-02 09:58:17 -08:00
Zeyi (Rice) Fan
ea5a69b81f sqlite: add transaction to SqliteDatabase
Summary:
This diff introduces `transaction()` to `SqliteDatabase` to make managing SQLite transaction easier.

Usage:

```
db->transaction([](auto& txn) {
  SqliteStatement(txn, "SELECT ...");
  SqliteStatement(txn, "INSERT ...");
});
```

It will automatically roll back when exception happens, and commit when the closure finishes.

Reviewed By: chadaustin

Differential Revision: D25102179

fbshipit-source-id: 5a4ced8c6eb8016e15b8132be2b5abcc9760e2f9
2021-03-02 09:58:17 -08:00
Zeyi (Rice) Fan
7b7bfe2cc9 sqlite: alias LockedPtr to Connection
Summary: This diff adds an alias `SqliteDatabase::Connection` to make it less mouthful when we want to reference the type of the SQLite connection we created

Reviewed By: xavierd

Differential Revision: D25386777

fbshipit-source-id: a6a58d522200fe0bf35ac52f6dad16063c0389d0
2021-03-02 09:58:17 -08:00
Xavier Deguillard
34598d4337 remove dependency on glog
Summary:
The EdenFS codebase uses folly/logging/xlog to log, but we were still relying
on glog for the various CHECK macros. Since xlog also contains equivalent CHECK
macros, let's just rely on them instead.

This is mostly codemodded + arc lint + various fixes to get it compile.

Reviewed By: chadaustin

Differential Revision: D24871174

fbshipit-source-id: 4d2a691df235d6dbd0fbd8f7c19d5a956e86b31c
2020-11-10 16:31:15 -08:00
Zeyi (Rice) Fan
d2158d07df sqlite: allow to create in-memory sqlite database for testing
Summary:
This diff adds a new constructor to `SqliteDatabase` to allow creation of
in-memory SQLite database. This can come in handy in testing.

Reviewed By: xavierd

Differential Revision: D24083579

fbshipit-source-id: ad6dd8b1c20392a882c1f164ef1f8af2f0ba11f8
2020-10-05 15:51:18 -07:00
Xavier Deguillard
b251082355 silence some msvc warnings from sqlite.{h,cpp}
Summary:
We have a lot of warnings on Windows, which in case of a build failure makes
it hard to find the actual cause, let's start by silencing the Sqlite ones.

Reviewed By: wez

Differential Revision: D21238029

fbshipit-source-id: 95763dcd06af77d45b7a769a93e0bbd6cabfa9c3
2020-04-26 21:14:24 -07:00
Puneet Kaushik
38299c2d3a Sqlite Overlay for Inode support on Windows
Summary:
This diff introduces a sqlite based overlay, which stores the directory inode and its entries in the sqlite database. This is similar to FsOverlay but doesn't support all the functionality. Sqlite overlay in this diff is only designed to handles the requirement for Eden on Windows.

We did not build sqlite overlay as a virtual class because as of this diff the interface and functionality of this is different from fsOverlay.

Reviewed By: simpkins

Differential Revision: D20480870

fbshipit-source-id: c87cb2ffd11c6c0c7a10bc8dfaf6164e0e442b2b
2020-04-23 12:41:47 -07:00
Adam Simpkins
2f075880c8 fix a missing dependency in a CMakeLists.txt file
Summary:
The `eden/fs/sqlite` code uses `eden/fs/utils/PathFuncs.h`, so add a proper
dependency on the `eden_utils` library.

Reviewed By: pkaush

Differential Revision: D18652105

fbshipit-source-id: b8dffd93971ab5efb71d7bc3c2dcb62249b3915b
2019-11-21 21:43:54 -08:00
Andres Suarez
fbdb46f5cb Tidy up license headers
Reviewed By: chadaustin

Differential Revision: D17872966

fbshipit-source-id: cd60a364a2146f0dadbeca693b1d4a5d7c97ff63
2019-10-11 05:28:23 -07:00
Adam Simpkins
4bc8682391 update license headers in CMake files
Summary:
Update the copyright & license headers in CMake files to reflect the
relicensing to GPLv2

Reviewed By: wez

Differential Revision: D15487079

fbshipit-source-id: 715e559464c19a0070d6e55a095b3fc7d61ad2f8
2019-06-19 17:02:46 -07:00
Adam Simpkins
aa5e6c7295 update license headers in C++ files
Summary:
Update the copyright & license headers in C++ files to reflect the
relicensing to GPLv2

Reviewed By: wez

Differential Revision: D15487078

fbshipit-source-id: 19f24c933a64ecad0d3a692d0f8d2a38b4194b1d
2019-06-19 17:02:45 -07:00
Adam Simpkins
904812bc0d avoid leaking the sqlite3 db if we fail to open it
Summary:
We need to call sqlite3_close() if sqlite3_open() fails to avoid leaking the
DB object that was allocated.

Reviewed By: chadaustin, strager

Differential Revision: D8529745

fbshipit-source-id: 1087dac8343b8b3120c89bd3c9a250970e69df8e
2018-06-20 16:36:22 -07:00
Adam Simpkins
dea514bbef add CMake build files
Summary: Add CMakeFiles to build Eden.

Reviewed By: wez

Differential Revision: D7479587

fbshipit-source-id: 7e0b4a756005dadc3af5c13c36ce22d1dcc15071
2018-04-30 14:37:46 -07:00
Wez Furlong
eaeaf8f23c add SqliteLocalStore
Summary:
Adds a SQLite storage implementation and makes it the
default engine for integration tests; this requires fewer resources
to run and the integration tests thus run faster and more reliably.

In the future we may add a configuration option to remember the
storage engine that was used as it is currently not "safe" to switch
from one to the other because the hgproxyhash data cannot be
recreated without re-importing a revision.

Reviewed By: simpkins

Differential Revision: D6919456

fbshipit-source-id: 3afbfafb190cca0e3c797cd9b7cd051768575a8c
2018-02-08 20:06:55 -08:00