diff mbox series

[ovs-dev] ovsdb-cs: fix 'cs_db' lock flag not updated error.

Message ID 20230407065904.865968-1-wanghanlin@corp.netease.com
State Rejected
Headers show
Series [ovs-dev] ovsdb-cs: fix 'cs_db' lock flag not updated error. | 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

汪翰林 April 7, 2023, 6:59 a.m. UTC
When 'cs' is not connected to a server, then
ovsdb_cs_db_compose_lock_request__ will update
'cs_db' lock flag, but the lock flag will not
be updated next.

Signed-off-by: wanghanlin <wanghanlin@corp.netease.com>
---
 lib/ovsdb-cs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Horman April 7, 2023, 1:20 p.m. UTC | #1
On Fri, Apr 07, 2023 at 02:59:04PM +0800, wanghanlin wrote:
> When 'cs' is not connected to a server, then
> ovsdb_cs_db_compose_lock_request__ will update
> 'cs_db' lock flag, but the lock flag will not
> be updated next.
> 
> Signed-off-by: wanghanlin <wanghanlin@corp.netease.com>

Hi,

Are there also error conditions where this situation can arise?
汪翰林 April 11, 2023, 9:07 a.m. UTC | #2
在 2023/4/7 21:20, Simon Horman 写道:
> On Fri, Apr 07, 2023 at 02:59:04PM +0800, wanghanlin wrote:
>> When 'cs' is not connected to a server, then
>> ovsdb_cs_db_compose_lock_request__ will update
>> 'cs_db' lock flag, but the lock flag will not
>> be updated next.
>>
>> Signed-off-by: wanghanlin <wanghanlin@corp.netease.com>
> Hi,
>
> Are there also error conditions where this situation can arise?
This happens when reconnect_disable is called.
Ilya Maximets May 4, 2023, 10:12 a.m. UTC | #3
On 4/11/23 11:07, 汪翰林 wrote:
> 
> 在 2023/4/7 21:20, Simon Horman 写道:
>> On Fri, Apr 07, 2023 at 02:59:04PM +0800, wanghanlin wrote:
>>> When 'cs' is not connected to a server, then
>>> ovsdb_cs_db_compose_lock_request__ will update
>>> 'cs_db' lock flag, but the lock flag will not
>>> be updated next.
>>>
>>> Signed-off-by: wanghanlin <wanghanlin@corp.netease.com>
>> Hi,
>>
>> Are there also error conditions where this situation can arise?
> This happens when reconnect_disable is called.

Hi.  Why exactly this condition is bad?  While composing the
lock request the 'has_lock' flag will be dropped to 'false'.
The lock request will be created, but the send will fail, since
there is no connection.  However, this shouldn't have any
consequences, because we do not claim to have a lock.  Once we
re-connect a new request should be formed and sent out.  Or am
I missing something?

Best regards, Ilya Maximets.
Ilya Maximets May 4, 2023, 10:14 a.m. UTC | #4
On 5/4/23 12:12, Ilya Maximets wrote:
> On 4/11/23 11:07, 汪翰林 wrote:
>>
>> 在 2023/4/7 21:20, Simon Horman 写道:
>>> On Fri, Apr 07, 2023 at 02:59:04PM +0800, wanghanlin wrote:
>>>> When 'cs' is not connected to a server, then
>>>> ovsdb_cs_db_compose_lock_request__ will update
>>>> 'cs_db' lock flag, but the lock flag will not
>>>> be updated next.
>>>>
>>>> Signed-off-by: wanghanlin <wanghanlin@corp.netease.com>
>>> Hi,
>>>
>>> Are there also error conditions where this situation can arise?
>> This happens when reconnect_disable is called.
> 
> Hi.  Why exactly this condition is bad?  While composing the
> lock request the 'has_lock' flag will be dropped to 'false'.
> The lock request will be created, but the send will fail, since
> there is no connection.  However, this shouldn't have any
> consequences, because we do not claim to have a lock.  Once we
> re-connect a new request should be formed and sent out.  Or am
> I missing something?

Even worse, if we do not drop the flag, the application will still
think that it has the lock, while it doesn't.

> 
> Best regards, Ilya Maximets.
汪翰林 May 5, 2023, 2:55 a.m. UTC | #5
在 2023/5/4 18:14, Ilya Maximets 写道:
> On 5/4/23 12:12, Ilya Maximets wrote:
>> On 4/11/23 11:07, 汪翰林 wrote:
>>> 在 2023/4/7 21:20, Simon Horman 写道:
>>>> On Fri, Apr 07, 2023 at 02:59:04PM +0800, wanghanlin wrote:
>>>>> When 'cs' is not connected to a server, then
>>>>> ovsdb_cs_db_compose_lock_request__ will update
>>>>> 'cs_db' lock flag, but the lock flag will not
>>>>> be updated next.
>>>>>
>>>>> Signed-off-by: wanghanlin <wanghanlin@corp.netease.com>
>>>> Hi,
>>>>
>>>> Are there also error conditions where this situation can arise?
>>> This happens when reconnect_disable is called.
>> Hi.  Why exactly this condition is bad?  While composing the
>> lock request the 'has_lock' flag will be dropped to 'false'.
>> The lock request will be created, but the send will fail, since
>> there is no connection.  However, this shouldn't have any
>> consequences, because we do not claim to have a lock.  Once we
>> re-connect a new request should be formed and sent out.  Or am
>> I missing something?
> Even worse, if we do not drop the flag, the application will still
> think that it has the lock, while it doesn't.
>
>> Best regards, Ilya Maximets.


In bridge_run,  ovsdb_idl_has_lock will check the 'has_lock' flag and 
return immediately when 'has_lock' is false.
汪翰林 May 5, 2023, 3:15 a.m. UTC | #6
在 2023/5/5 10:55, 汪翰林 写道:
>
> 在 2023/5/4 18:14, Ilya Maximets 写道:
>> On 5/4/23 12:12, Ilya Maximets wrote:
>>> On 4/11/23 11:07, 汪翰林 wrote:
>>>> 在 2023/4/7 21:20, Simon Horman 写道:
>>>>> On Fri, Apr 07, 2023 at 02:59:04PM +0800, wanghanlin wrote:
>>>>>> When 'cs' is not connected to a server, then
>>>>>> ovsdb_cs_db_compose_lock_request__ will update
>>>>>> 'cs_db' lock flag, but the lock flag will not
>>>>>> be updated next.
>>>>>>
>>>>>> Signed-off-by: wanghanlin <wanghanlin@corp.netease.com>
>>>>> Hi,
>>>>>
>>>>> Are there also error conditions where this situation can arise?
>>>> This happens when reconnect_disable is called.
>>> Hi.  Why exactly this condition is bad?  While composing the
>>> lock request the 'has_lock' flag will be dropped to 'false'.
>>> The lock request will be created, but the send will fail, since
>>> there is no connection.  However, this shouldn't have any
>>> consequences, because we do not claim to have a lock.  Once we
>>> re-connect a new request should be formed and sent out.  Or am
>>> I missing something?
>> Even worse, if we do not drop the flag, the application will still
>> think that it has the lock, while it doesn't.
>>
>>> Best regards, Ilya Maximets.
>
>
> In bridge_run,  ovsdb_idl_has_lock will check the 'has_lock' flag and 
> return immediately when 'has_lock' is false.
>

Because ovs process flow configuration in connmgr_run called by 
bridge_run__, then flow configure will not work now.
Ilya Maximets May 5, 2023, 4:09 p.m. UTC | #7
On 5/5/23 05:15, 汪翰林 wrote:
> 
> 在 2023/5/5 10:55, 汪翰林 写道:
>>
>> 在 2023/5/4 18:14, Ilya Maximets 写道:
>>> On 5/4/23 12:12, Ilya Maximets wrote:
>>>> On 4/11/23 11:07, 汪翰林 wrote:
>>>>> 在 2023/4/7 21:20, Simon Horman 写道:
>>>>>> On Fri, Apr 07, 2023 at 02:59:04PM +0800, wanghanlin wrote:
>>>>>>> When 'cs' is not connected to a server, then
>>>>>>> ovsdb_cs_db_compose_lock_request__ will update
>>>>>>> 'cs_db' lock flag, but the lock flag will not
>>>>>>> be updated next.
>>>>>>>
>>>>>>> Signed-off-by: wanghanlin <wanghanlin@corp.netease.com>
>>>>>> Hi,
>>>>>>
>>>>>> Are there also error conditions where this situation can arise?
>>>>> This happens when reconnect_disable is called.
>>>> Hi.  Why exactly this condition is bad?  While composing the
>>>> lock request the 'has_lock' flag will be dropped to 'false'.
>>>> The lock request will be created, but the send will fail, since
>>>> there is no connection.  However, this shouldn't have any
>>>> consequences, because we do not claim to have a lock.  Once we
>>>> re-connect a new request should be formed and sent out.  Or am
>>>> I missing something?
>>> Even worse, if we do not drop the flag, the application will still
>>> think that it has the lock, while it doesn't.
>>>
>>>> Best regards, Ilya Maximets.
>>
>>
>> In bridge_run,  ovsdb_idl_has_lock will check the 'has_lock' flag and return immediately when 'has_lock' is false.

That is intended behavior.  If we don't have database connection
we should not apply any changes.

> Because ovs process flow configuration in connmgr_run called by bridge_run__, then flow configure will not work now.

We can't validate port numbers if we don't have connection to the
database.  For example, if the second ovs-vswitchd process is
started on the system for some reason, it should not apply any
configuration changes to the datapath.  This is ensured by the
database lock.

Best regards, Ilya Maximets.
diff mbox series

Patch

diff --git a/lib/ovsdb-cs.c b/lib/ovsdb-cs.c
index c7c147cc0..f909a66f9 100644
--- a/lib/ovsdb-cs.c
+++ b/lib/ovsdb-cs.c
@@ -632,7 +632,7 @@  ovsdb_cs_run(struct ovsdb_cs *cs, struct ovs_list *events)
 
         ovsdb_cs_db_add_event(&cs->data, OVSDB_CS_EVENT_TYPE_RECONNECT);
 
-        if (cs->data.lock_name) {
+        if (cs->data.lock_name && ovsdb_cs_is_connected(cs)) {
             jsonrpc_session_send(
                 cs->session,
                 ovsdb_cs_db_compose_lock_request(&cs->data));