Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Session Recording #4892

Merged
merged 200 commits into from
Jun 7, 2023
Merged

Session Recording #4892

merged 200 commits into from
Jun 7, 2023

Conversation

atmaxinger
Copy link
Contributor

@atmaxinger atmaxinger commented Mar 28, 2023

Basics

  • Short descriptions of your changes are in the release notes
    (added as entry in doc/news/_preparation_next_release.md which contains _(my name)_)
    Please always add them to the release notes.
  • Details of what you changed are in commit messages
    (first line should have module: short statement syntax)
  • References to issues, e.g. close #X, are in the commit messages.
  • The buildservers are happy. If not, fix in this order:
    • add a line in doc/news/_preparation_next_release.md
    • reformat the code with scripts/dev/reformat-all
    • make all unit tests pass
    • fix all memleaks
    • fix the CI itself (or rebase if already fixed)
  • The PR is rebased with current master.

Checklist

  • I added unit tests for my code
  • I fully described what my PR does in the documentation
    (not in the PR description)
  • I fixed all affected documentation (see Documentation Guidelines)
  • I fixed all affected decisions (see Decision Process)
  • I added code comments, logging, and assertions as appropriate (see Coding Guidelines)
  • I updated all meta data (e.g. README.md of plugins and METADATA.ini)
  • I mentioned every code not directly written by me in reuse syntax

Review

Labels

  • Add the "work in progress" label if you do not want the PR to be reviewed yet.
  • Add the "ready to merge" label if everything is done and no further pushes are planned by you.

src/libs/record/record.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@flo91 flo91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again an impressive amount of work and progress! 😲
The code is well structured and not too hard to get into.
Good documentation and lots of tests are present.

Keep up that great work! 👍

My findings are available in the comments below.
I'll make a 2nd review when this PR is ready to merge.

doc/contrib/recording.md Outdated Show resolved Hide resolved
doc/help/kdb-record.md Outdated Show resolved Hide resolved
src/libs/elektra/contracts.c Outdated Show resolved Hide resolved
src/libs/elektra/contracts.c Outdated Show resolved Hide resolved
src/libs/elektra/diff.c Show resolved Hide resolved
src/libs/elektra/kdb.c Outdated Show resolved Hide resolved
src/libs/record/record.c Outdated Show resolved Hide resolved
src/plugins/recorder/recorder.c Outdated Show resolved Hide resolved
src/tools/kdb/recordundo.cpp Outdated Show resolved Hide resolved
tests/cframework/tests.h Outdated Show resolved Hide resolved
@atmaxinger
Copy link
Contributor Author

Does anyone have an idea how to debug the test issues on Cirrus CI?

There are a ton of shell tests that fail with the following error:

198/286 Test #198: testscr_check_kdb_internal_suite ..............***Failed    0.01 sec
ELEKTRA KDB INTERNAL TEST SUITE
Check if script tests the correct version
fatal (no cleanup necessary): Script was not compiled (0.9.14) with this Elektra version (): KDB_VERSION mismatch for kdb-tool (kdb), use CHECK_VERSION=NO to disable

It looks fishy that the second parenthesis is empty. The elektra version number should be present there. It is read from system:/elektra/version/constants/KDB_VERSION. Kind of seems like it can't find the kdb executable there.

@atmaxinger
Copy link
Contributor Author

jenkins build libelektra please

@atmaxinger
Copy link
Contributor Author

Ah okay, for future reference: The install script didn't complete because it couldn't find the man page for elektra-record.

@atmaxinger atmaxinger force-pushed the recording branch 3 times, most recently from 98cdae1 to ad68ed9 Compare April 11, 2023 22:21
@atmaxinger
Copy link
Contributor Author

jenkins build libelektra please

8 similar comments
@atmaxinger
Copy link
Contributor Author

jenkins build libelektra please

@atmaxinger
Copy link
Contributor Author

jenkins build libelektra please

@atmaxinger
Copy link
Contributor Author

jenkins build libelektra please

@atmaxinger
Copy link
Contributor Author

jenkins build libelektra please

@atmaxinger
Copy link
Contributor Author

jenkins build libelektra please

@atmaxinger
Copy link
Contributor Author

jenkins build libelektra please

@atmaxinger
Copy link
Contributor Author

jenkins build libelektra please

@atmaxinger
Copy link
Contributor Author

jenkins build libelektra please

@atmaxinger
Copy link
Contributor Author

@flo91 @markus2330
I think I'm at a bit of a loss here.

The test program test_record segfaults in Jenkins on Fedora 37, and only in Jenkins. No other CI builds fail, and I can't reproduce it even with the same Docker images locally on multiple computers. Even all the ASAN builds are successful, and locally valgrind did not find any erroneous reads or writes.

What's even weirder is I've enabled --verbose for ctest to see the output. All other tests output something, but the test_record doesn't. It seems to crash before main.

See for example the output for test_sha-256:

test 273
        Start 273: test_sha-256

273: Test command: /home/jenkins/workspace/libelektra_PR-4892/build\ directory/bin/test_sha-256 "/home/jenkins/workspace/libelektra_PR-4892/build directory/tests/ctest"
273: Working Directory: /home/jenkins/workspace/libelektra_PR-4892/build directory/tests/ctest
273: Environment variables: 
273:  LD_LIBRARY_PATH=/home/jenkins/workspace/libelektra_PR-4892/build directory/lib
273: Test timeout computed to be: 1500
273: SHA-256    TESTS
273: ==================
273: 
273: 
273: test_sha-256 RESULTS: 13 test(s) done. 0 error(s).
165/170 Test #273: test_sha-256 .......................   Passed    0.00 sec

And now the output of test_record:

test 272
        Start 272: test_record

272: Test command: /home/jenkins/workspace/libelektra_PR-4892/build\ directory/bin/test_record "/home/jenkins/workspace/libelektra_PR-4892/build directory/tests/ctest"
272: Working Directory: /home/jenkins/workspace/libelektra_PR-4892/build directory/tests/ctest
272: Environment variables: 
272:  LD_LIBRARY_PATH=/home/jenkins/workspace/libelektra_PR-4892/build directory/lib
272: Test timeout computed to be: 1500
164/170 Test #272: test_record ........................***Exception: SegFault  0.00 sec

@atmaxinger atmaxinger force-pushed the recording branch 3 times, most recently from 0d50bb2 to 91f27e1 Compare April 13, 2023 17:00
@atmaxinger
Copy link
Contributor Author

Oh wow, that was a truly multi-level bug cascade. But everything seems to work now 😁.

@atmaxinger
Copy link
Contributor Author

jenkins build libelektra please

1 similar comment
@atmaxinger
Copy link
Contributor Author

jenkins build libelektra please

@atmaxinger
Copy link
Contributor Author

jenkins build libelektra please

@atmaxinger
Copy link
Contributor Author

jenkins build libelektra please

Copy link
Member

@kodebach kodebach left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, just a few suggestions for the docs

doc/help/elektra-glossary.md Outdated Show resolved Hide resolved

Note: when you activate session recording, concurrency of Elektra will be somewhat limited.
As long as it is active, a global lock will be created to ensure no two processes will write data simultaneously.
This behavior is similar as to when multiple processes will write to the same configuration file.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This behavior is similar as to when multiple processes will write to the same configuration file.
The errors reports to applications in such cases are similar to when multiple processes write to the same configuration file.

doc/help/kdb-record-start.md Show resolved Hide resolved
doc/help/kdb-record-state.md Show resolved Hide resolved
src/libs/ease/array.c Outdated Show resolved Hide resolved
src/plugins/ansible/README.md Show resolved Hide resolved
src/libs/elektra/errors.c Fixed Show resolved Hide resolved
@kodebach
Copy link
Member

kodebach commented May 31, 2023

One more thing, you should add meta:/elektra/deleted to doc/METADATA.ini (and probably meta:/elektra/* as reserved).

@markus2330 markus2330 merged commit de26195 into ElektraInitiative:master Jun 7, 2023
Copy link
Collaborator

@flo91 flo91 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Outstanding and comprehensive work done here! 🎉
The contribution is well structured, well documented and includes lots of test cases. 👍🏻

I've just found a few small mistakes and have a few questions.
This PR got already merged during my review, but it shouldn't be a problem to create a follow-up PR where you incorporate these changes to improve the already high quality of your contribution even a bit more.

Additionally, it would be great if you find time to also review my PR for the ODBC backend: #4915

Thank you!

Comment on lines +20 to +21
this key denotes the parent key of the session. Only changes same of
below this key will be recorded.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this key denotes the parent key of the session. Only changes same of
below this key will be recorded.
this key denotes the parent key of the session.
Only changes of this key and below this key will be recorded.

A recording session is a period of time during which changes to the Key Database (KDB) are tracked and accumulated.
It begins when recording starts and ends when recording stops.
Throughout the recording session, all changes made to the KDB are recorded, including additions, modifications, and deletions of keys and their associated values.
The recording session provides a complete audit trail of all changes made to the KDB during the specified period of time.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The recording session provides a complete audit trail of all changes made to the KDB during the specified period of time.

The same sentence that you already removed from doc/help/elektra-glossary.md after the review from @kodebach.

Used for the session recording plugin.
Hard coded to search for a plugin named `recorder`.

The following function must be exported:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
The following function must be exported:
The following functions must be exported:

- Signature: `int (Plugin * handle, Key * parentKey)`
- Called in `kdbSet` before the storage phase.
- The `parentKey` must not be modified, except for adding errors and warnings.
- Must ensure that this is only process that can record changes until `unlock` is called.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Must ensure that this is only process that can record changes until `unlock` is called.
- Must ensure that this is the only process that can record changes until `unlock` is called.

- **recording session**:
A recording session is a period of time during which changes to the Key Database (KDB) are tracked and accumulated.
It begins when recording starts and ends when recording stops.
Throughout the recording session, all changes made to the KDB are recorded, including additions, modifications, and deletions of keys and their associated values.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Throughout the recording session, all changes made to the KDB are recorded, including additions, modifications, and deletions of keys and their associated values.
Throughout the recording session, all changes made to the KDB are recorded, including additions, modifications, and deletions of keys and their associated values and metadata.

Comment on lines +204 to +205
EXPECT_EQ (diffWithDifferences.isEmpty (), false);
EXPECT_EQ (diffWithoutDifferences.isEmpty (), true);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be replaced with EXPECT_FALSE resp. EXPECT_TRUE.

ksDel (ksCut (toRecord, ksAtCursor (blacklistedKeys, it)));
}

if (ksGetSize (toRecord) == 0 && ksGetSize (newKeys) != 0)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the 2nd condition (ksGetSize (newKeys) != 0) really necessary here?
Maybe you could also add the check for an empty KeySet newKeys at the beginning of this function (after the NULL-pointer checks).

return successful;
}

bool elektraRecordGetDiff (KDB * handle, ElektraDiff ** diff, Key * errorKey)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation is missing for this function.

return ks;
}

bool elektraRecordExportSession (KDB * handle, Plugin * plugin, Key * parentKey, Key * errorKey)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Documentation is also missing for this function.

// We need to duplicate the ks, as `getDiffFromSessionStorage` will remove it from sessionStorage
sessionStorageBackup = ksDup (ksBelow (sessionStorage, sessionKey));

// Remove all keys from session storage that are not initiall under parent key
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"initiall" -> "initially"

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

Successfully merging this pull request may close these issues.

5 participants