diff mbox series

[ovs-dev] raft: Fix unnecessary periodic compactions.

Message ID 20220819230810.2626573-1-i.maximets@ovn.org
State Accepted
Commit a32a4e1fa2d3fad284834d4b7bccc2e71d33f9da
Headers show
Series [ovs-dev] raft: Fix unnecessary periodic compactions. | expand

Checks

Context Check Description
ovsrobot/apply-robot success apply and check: success
ovsrobot/github-robot-_Build_and_Test success github build: passed
ovsrobot/intel-ovs-compilation success test: success

Commit Message

Ilya Maximets Aug. 19, 2022, 11:08 p.m. UTC
While creating a new database file and storing a new snapshot
into it, raft module by mistake updates the base offset for the
old file.  So, the base offset of a new file remains zero.  Then
the old file is getting replaced with the new one, copying new
offsets as well.  In the end, after a full compaction, base offset
is always zero.  And any offset is twice as large as zero.  That
triggers a new compaction again at the earliest scheduled time.
In practice this issue triggers compaction every 10-20 minutes
regardless of the database load, after the first one is triggered
by the actual file growth or by the 24h maximum limit.

Fixes: 1b1d2e6daa56 ("ovsdb: Introduce experimental support for clustered databases.")
Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2022-August/051977.html
Reported-by: Oleksandr Mykhalskyi <oleksandr.mykhalskyi@netcracker.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
---
 ovsdb/raft.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Dumitru Ceara Aug. 26, 2022, 2:08 p.m. UTC | #1
On 8/20/22 01:08, Ilya Maximets wrote:
> While creating a new database file and storing a new snapshot
> into it, raft module by mistake updates the base offset for the
> old file.  So, the base offset of a new file remains zero.  Then
> the old file is getting replaced with the new one, copying new
> offsets as well.  In the end, after a full compaction, base offset
> is always zero.  And any offset is twice as large as zero.  That
> triggers a new compaction again at the earliest scheduled time.
> In practice this issue triggers compaction every 10-20 minutes
> regardless of the database load, after the first one is triggered
> by the actual file growth or by the 24h maximum limit.
> 
> Fixes: 1b1d2e6daa56 ("ovsdb: Introduce experimental support for clustered databases.")
> Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2022-August/051977.html
> Reported-by: Oleksandr Mykhalskyi <oleksandr.mykhalskyi@netcracker.com>
> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
> ---
>  ovsdb/raft.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/ovsdb/raft.c b/ovsdb/raft.c
> index b2c21e70f..b2361b173 100644
> --- a/ovsdb/raft.c
> +++ b/ovsdb/raft.c
> @@ -4039,7 +4039,7 @@ raft_write_snapshot(struct raft *raft, struct ovsdb_log *log,
>      if (error) {
>          return error;
>      }
> -    ovsdb_log_mark_base(raft->log);
> +    ovsdb_log_mark_base(log);
>  
>      /* Write log records. */
>      for (uint64_t index = new_log_start; index < raft->log_end; index++) {

Nice!

Acked-by: Dumitru Ceara <dceara@redhat.com>
Ilya Maximets Aug. 31, 2022, 9:57 a.m. UTC | #2
On 8/26/22 16:08, Dumitru Ceara wrote:
> On 8/20/22 01:08, Ilya Maximets wrote:
>> While creating a new database file and storing a new snapshot
>> into it, raft module by mistake updates the base offset for the
>> old file.  So, the base offset of a new file remains zero.  Then
>> the old file is getting replaced with the new one, copying new
>> offsets as well.  In the end, after a full compaction, base offset
>> is always zero.  And any offset is twice as large as zero.  That
>> triggers a new compaction again at the earliest scheduled time.
>> In practice this issue triggers compaction every 10-20 minutes
>> regardless of the database load, after the first one is triggered
>> by the actual file growth or by the 24h maximum limit.
>>
>> Fixes: 1b1d2e6daa56 ("ovsdb: Introduce experimental support for clustered databases.")
>> Reported-at: https://mail.openvswitch.org/pipermail/ovs-discuss/2022-August/051977.html
>> Reported-by: Oleksandr Mykhalskyi <oleksandr.mykhalskyi@netcracker.com>
>> Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
>> ---
>>  ovsdb/raft.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/ovsdb/raft.c b/ovsdb/raft.c
>> index b2c21e70f..b2361b173 100644
>> --- a/ovsdb/raft.c
>> +++ b/ovsdb/raft.c
>> @@ -4039,7 +4039,7 @@ raft_write_snapshot(struct raft *raft, struct ovsdb_log *log,
>>      if (error) {
>>          return error;
>>      }
>> -    ovsdb_log_mark_base(raft->log);
>> +    ovsdb_log_mark_base(log);
>>  
>>      /* Write log records. */
>>      for (uint64_t index = new_log_start; index < raft->log_end; index++) {
> 
> Nice!
> 
> Acked-by: Dumitru Ceara <dceara@redhat.com>
> 

Thanks!  Applied and backported down to 2.13.

Best regards, Ilya Maximets.
diff mbox series

Patch

diff --git a/ovsdb/raft.c b/ovsdb/raft.c
index b2c21e70f..b2361b173 100644
--- a/ovsdb/raft.c
+++ b/ovsdb/raft.c
@@ -4039,7 +4039,7 @@  raft_write_snapshot(struct raft *raft, struct ovsdb_log *log,
     if (error) {
         return error;
     }
-    ovsdb_log_mark_base(raft->log);
+    ovsdb_log_mark_base(log);
 
     /* Write log records. */
     for (uint64_t index = new_log_start; index < raft->log_end; index++) {