# How to parse the commitlog?

**URL:** <https://forum.scylladb.com/t/how-to-parse-the-commitlog/1354>\
**Category:** ScyllaDB\
**Tags:** open-source\
**Created:** [March 5, 2024, 7:02am UTC](https://forum.scylladb.com/t/how-to-parse-the-commitlog/1354 "2024-03-05T07:02:26Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![bo\_li](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/bo_li/32/438_2.png) [@bo\_li](https://forum.scylladb.com/u/bo_li)\
**Post date:** [March 5, 2024, 7:02am UTC](https://forum.scylladb.com/t/how-to-parse-the-commitlog/1354/1 "2024-03-05T07:02:26Z")

</div>

Directly view the file `CommitLog-2-8901636397.log` as garbled code. How to make the file readable by humans? Is there any parsing tool available? Thanks!

---

<div class="post-metadata">

**Author:** ![Botond\_Denes](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/botond_denes/32/163_2.png) [@Botond\_Denes](https://forum.scylladb.com/u/Botond_Denes)\
**Post date:** [March 5, 2024, 9:16am UTC](https://forum.scylladb.com/t/how-to-parse-the-commitlog/1354/2 "2024-03-05T09:16:14Z")

</div>

Currently there are no end-user tools to parse commit logs. I do plan to add such a tool in the near future, so stay tuned.

Out of curiosity, why would you like to dump the content of this commit-log file?

---

<div class="post-metadata">

**Author:** ![Botond\_Denes](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/botond_denes/32/163_2.png) [@Botond\_Denes](https://forum.scylladb.com/u/Botond_Denes)\
**Post date:** [March 5, 2024, 9:19am UTC](https://forum.scylladb.com/t/how-to-parse-the-commitlog/1354/3 "2024-03-05T09:19:58Z")

</div>

There is an indirect way to dump the commit-log:

1. Start up a single scylla instance, wait until it finishes booting then stop it. Make sure to start this instance, such that it doesn’t join any existing cluster!!!
2. Copy over the contents of `/var/lib/data/system\_schema/\* to the new Scylla instance, overwriting everything that is already there.
3. Copy over the commitlog file to `/var/lib/commitlog`.
4. Start the node. It will replay the commit log. As soon as it finishes starting-up, stop it.
5. The data will be in sstables, you can use `scylla-sstable` to examine it.

Note that this method will make the data go through insertion to memtable, then flush. Some (or even all) of the data might be compacted away in the process.

---

<div class="post-metadata">

**Author:** ![bo\_li](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/bo_li/32/438_2.png) [@bo\_li](https://forum.scylladb.com/u/bo_li)\
**Post date:** [March 6, 2024, 6:19am UTC](https://forum.scylladb.com/t/how-to-parse-the-commitlog/1354/4 "2024-03-06T06:19:33Z")

</div>

Thank you, I look forward to it.  
In order to facilitate the statistics of certain data, I would like to migrate the data to other databases through commitlog. Just an idea.

---

<div class="post-metadata">

**Author:** ![tzach](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/tzach/32/172_2.png) [@tzach](https://forum.scylladb.com/u/tzach)\
**Post date:** [March 6, 2024, 7:34am UTC](https://forum.scylladb.com/t/how-to-parse-the-commitlog/1354/5 "2024-03-06T07:34:49Z")

</div>

This sounds like a risky reimplementation of [CDC](https://opensource.docs.scylladb.com/stable/using-scylla/cdc/cdc-intro.html).

You will need to deduplicate updates from each replica and lose the pre and post-images CDC provides.

---

<div class="post-metadata">

**Author:** ![bo\_li](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/bo_li/32/438_2.png) [@bo\_li](https://forum.scylladb.com/u/bo_li)\
**Post date:** [April 8, 2024, 7:48am UTC](https://forum.scylladb.com/t/how-to-parse-the-commitlog/1354/6 "2024-04-08T07:48:07Z")

</div>

> [@Botond\_Denes](#):
>
> I do plan to add such a tool in the near future, so stay tuned.

Hi, I use the `pretty_printer` function of `frozen_mutation` to print the  
content of commitlog, making it easy for humans to read.

In order to be able to call it offline, I added a [parsing tool](https://github.com/scylladb/scylladb/pull/18208/files). Now I have a question: how to initialize [db and sys\_ks](https://github.com/scylladb/scylladb/pull/18208/files#diff-d2cd36e35417c06514c684aef94344d4dc76f5ad72ffb2f2dc99ad8140dac167R47)? May I ask if you have any suggestions? Thank you.

---

<div class="post-metadata">

**Author:** ![Botond\_Denes](https://sea2.discourse-cdn.com/flex016/user_avatar/forum.scylladb.com/botond_denes/32/163_2.png) [@Botond\_Denes](https://forum.scylladb.com/u/Botond_Denes)\
**Post date:** [April 11, 2024, 6:00am UTC](https://forum.scylladb.com/t/how-to-parse-the-commitlog/1354/7 "2024-04-11T06:00:19Z")

</div>

Starting those two services is quite risky in the sense that they might try to create files. Worse still, if you run this tool on a live ScyllaDB node, they might access and mutate the files of the ScyllaDB node.  
So I think the way to go forward is to cut the dependency between the commitlog replayer and these services, by creating an interface and two implementations. The interface would have all the methods that the commitlog replayer requires from these services, e.g. `find_column_family()`, `extensions()`, etc. One implementation would use the `db` and `sys_ks` to implement these methods, just like the current code. Another implementation would be in the tools, which would try to do just the minimum amount of implementation possible, to allow the commitlog replayer to replay the commitlog. This might need some experimenting to get it working.
