Moodle

deleting an mnet peer tries to delete from mnet_rpc2host, which doesn't exist

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 2.0
  • Fix Version/s: 2.0
  • Component/s: MNet
  • Labels:
    None
  • Affected Branches:
    MOODLE_20_STABLE
  • Fixed Branches:
    MOODLE_20_STABLE

Description

Not sure if this table used to exist or this has always happened.

Issue Links

Activity

Hide
Peter Bulmer added a comment -

There isn't an rpc2host table in 1.9

Is the same code present in 1.9, 1.8?

Do you have a reference to specific code location where the problem is centered?

Show
Peter Bulmer added a comment - There isn't an rpc2host table in 1.9 Is the same code present in 1.9, 1.8? Do you have a reference to specific code location where the problem is centered?
Hide
Penny Leach added a comment -

1. yes, i know, which is why i reported the bug
2. didn't have time to check. i reported the bug so i would remember to fix it later
3. see 2.

Show
Penny Leach added a comment - 1. yes, i know, which is why i reported the bug 2. didn't have time to check. i reported the bug so i would remember to fix it later 3. see 2.
Hide
Penny Leach added a comment -

Pete, to clarify - as I've been going through and doing the mahara portfolio plugin I've found lots of bugs that need fixing in mnet... I don't want to context switch and start working on mnet in the middle of portfolio stuff so I'm just reporting them as I find them so that I remember later.

I don't expect someone else to try and interpret my superfast bug reports and fix them. Once I have more time I'll go through and fix the ones I can fix easily and triage the rest.

Show
Penny Leach added a comment - Pete, to clarify - as I've been going through and doing the mahara portfolio plugin I've found lots of bugs that need fixing in mnet... I don't want to context switch and start working on mnet in the middle of portfolio stuff so I'm just reporting them as I find them so that I remember later. I don't expect someone else to try and interpret my superfast bug reports and fix them. Once I have more time I'll go through and fix the ones I can fix easily and triage the rest.
Hide
Penny Leach added a comment -

It's at least in 1.9 and 1.8

You added the following comment which is in HEAD but not previously:

1.16 (peterbul 01-Sep-08): * This includes deleting current sessions, and rpc2host records.

I cannot find it in 1.7 or before.

1.1 (martinla 04-Jan-07): $obj = delete_records('mnet_rpc2host', 'host_id', $this->id);

But it's the only reference I can ever find to rpc2host - deleting records. I'm not sure if it a typo and should be deleting from another table, which is why i haven't simply deleted it.

Show
Penny Leach added a comment - It's at least in 1.9 and 1.8 You added the following comment which is in HEAD but not previously: 1.16 (peterbul 01-Sep-08): * This includes deleting current sessions, and rpc2host records. I cannot find it in 1.7 or before. 1.1 (martinla 04-Jan-07): $obj = delete_records('mnet_rpc2host', 'host_id', $this->id); But it's the only reference I can ever find to rpc2host - deleting records. I'm not sure if it a typo and should be deleting from another table, which is why i haven't simply deleted it.
Hide
Peter Bulmer added a comment -

As much as possible I've been avoiding making changes to code, but rather making it readable to find bugs like this, and documenting what it seems to be trying to do.

There are a couple of exceptions of course, and If you could tell me what file you're looking at or the relevant commit in git, then I could probabally be of more assistance.

My above comment about "There isn't an rpc2host table in 1.9" was because you seemed to have filed the but only about moodle 2.0, and I was advising that it was at least present in 1.9 as well. I will now invert my question, and ask if the same code exists in head?

Cheers,
Pete.

Show
Peter Bulmer added a comment - As much as possible I've been avoiding making changes to code, but rather making it readable to find bugs like this, and documenting what it seems to be trying to do. There are a couple of exceptions of course, and If you could tell me what file you're looking at or the relevant commit in git, then I could probabally be of more assistance. My above comment about "There isn't an rpc2host table in 1.9" was because you seemed to have filed the but only about moodle 2.0, and I was advising that it was at least present in 1.9 as well. I will now invert my question, and ask if the same code exists in head? Cheers, Pete.
Hide
Penny Leach added a comment -

it is in head, hence the original bug report against 2.0, where I was working.

it is in 1.9
it is in 1.8

as I didn't have time to check when I reported the bug (see my previous comment), but have now confirmed.

if you grepped for rpc2host you would find exactly one result, in admin/peers.php.

Show
Penny Leach added a comment - it is in head, hence the original bug report against 2.0, where I was working. it is in 1.9 it is in 1.8 as I didn't have time to check when I reported the bug (see my previous comment), but have now confirmed. if you grepped for rpc2host you would find exactly one result, in admin/peers.php.
Hide
Penny Leach added a comment -

mnet/peers.php rather.

Show
Penny Leach added a comment - mnet/peers.php rather.
Hide
Penny Leach added a comment -

grrrr, peer, even.

Show
Penny Leach added a comment - grrrr, peer, even.
Hide
Peter Bulmer added a comment -

I imagine this was intended to delete records from host2service table.
Perhaps part of the bugfix would be to run an upgrade which deletes host2service records which have
a) no associated entry in mnet_host
b) associated entry in mnet_host which is marked as deleted.

Show
Peter Bulmer added a comment - I imagine this was intended to delete records from host2service table. Perhaps part of the bugfix would be to run an upgrade which deletes host2service records which have a) no associated entry in mnet_host b) associated entry in mnet_host which is marked as deleted.
Hide
Penny Leach added a comment -

Seems reasonable. Yay for referential integrity!

Show
Penny Leach added a comment - Seems reasonable. Yay for referential integrity!
Hide
Eloy Lafuente (stronk7) added a comment -

And, just for the record... what happens with records in other tables (mnet_enrol_assignments, mnet_enrol_course, mnet_log, mnet_session, mnet_sso_access_control) apart from mnet_host2service ?

All them will continue storing "orphan" records? Or aren't really orphan because delete in mnet is just "mark as deleted" if possible. The delete code only seems to look in mnet_log to decide if the host is deleted or marked as deleted. Perhaps other tables should be checked too.

Ciao

Show
Eloy Lafuente (stronk7) added a comment - And, just for the record... what happens with records in other tables (mnet_enrol_assignments, mnet_enrol_course, mnet_log, mnet_session, mnet_sso_access_control) apart from mnet_host2service ? All them will continue storing "orphan" records? Or aren't really orphan because delete in mnet is just "mark as deleted" if possible. The delete code only seems to look in mnet_log to decide if the host is deleted or marked as deleted. Perhaps other tables should be checked too. Ciao
Hide
Peter Bulmer added a comment -

Can I suggest that we don't bother with all the checking, and err on the side of mark-as-deleted.

Until we are able to actually-delete any chosen host record, why bother actually-deleting any of them?

The 'undelete' process is a little bumpy, but (IMO) that's a better area to work on than making sure that the 1% of mnet hosts that are about to be actually-deleted really are a good case for actual-deletion.

Show
Peter Bulmer added a comment - Can I suggest that we don't bother with all the checking, and err on the side of mark-as-deleted. Until we are able to actually-delete any chosen host record, why bother actually-deleting any of them? The 'undelete' process is a little bumpy, but (IMO) that's a better area to work on than making sure that the 1% of mnet hosts that are about to be actually-deleted really are a good case for actual-deletion.
Hide
Jerome Mouneyrac added a comment -

I'm writing a Mahara repository plugin and I'd like to delete some old ones but we still can't for the same reason than before:

Error writing to database

More information about this error
Table 'moodle_HEAD.mdl_mnet_rpc2host' doesn't exist

DELETE FROM mdl_mnet_rpc2host WHERE host_id = ?
[array ( 0 => 3, )]

Peter, I don't get why you say we should not bother about it? The peer delete button doesn't work.
Note: I linked two duplicate issues.

Show
Jerome Mouneyrac added a comment - I'm writing a Mahara repository plugin and I'd like to delete some old ones but we still can't for the same reason than before: Error writing to database More information about this error Table 'moodle_HEAD.mdl_mnet_rpc2host' doesn't exist DELETE FROM mdl_mnet_rpc2host WHERE host_id = ? [array ( 0 => 3, )] Peter, I don't get why you say we should not bother about it? The peer delete button doesn't work. Note: I linked two duplicate issues.
Hide
Peter Bulmer added a comment -

sure,
the error with it trying to delete rpc2host needs to be fixed. The "delete mnet host" button needs to work. No argument there.

IIRC what I found in the code was a complex operation to determine if the mnet peer you've asked to delete has been used. If the host has been used, the peer is marked as deleted. In the case where it has not been used it is actually deleted. What I was saying, was that we shouldn't be bothering with the complex investigation, since most mnet hosts that we want to delete will have been used in some way. We might as well shortcut the process, and whereever we want to delete a host, go straight to marking it as deleted, no investigation.

When we do mark hosts as deleted, we should IMO actually delete host2service records related to the 'deleted' host. (This is probably what the author was thinking of when the `delete rpc2host` code was written)

Show
Peter Bulmer added a comment - sure, the error with it trying to delete rpc2host needs to be fixed. The "delete mnet host" button needs to work. No argument there. IIRC what I found in the code was a complex operation to determine if the mnet peer you've asked to delete has been used. If the host has been used, the peer is marked as deleted. In the case where it has not been used it is actually deleted. What I was saying, was that we shouldn't be bothering with the complex investigation, since most mnet hosts that we want to delete will have been used in some way. We might as well shortcut the process, and whereever we want to delete a host, go straight to marking it as deleted, no investigation. When we do mark hosts as deleted, we should IMO actually delete host2service records related to the 'deleted' host. (This is probably what the author was thinking of when the `delete rpc2host` code was written)
Hide
Jerome Mouneyrac added a comment -

Hi Peter,
I'm back using Mnet in order to fix the remote repository plugin. And this issue came back to me hehe
I agree with your last comment mark them all as deleted and also delete host2service references. I think we should fix it in 2.0 at this moment. Are you still working on Mnet?

Show
Jerome Mouneyrac added a comment - Hi Peter, I'm back using Mnet in order to fix the remote repository plugin. And this issue came back to me hehe I agree with your last comment mark them all as deleted and also delete host2service references. I think we should fix it in 2.0 at this moment. Are you still working on Mnet?
Hide
Jerome Mouneyrac added a comment -

I attached a patch that:

  • always set the host as deleted (we always keep the entry into the database)
  • keep old settings (we don't delete the service references)
Show
Jerome Mouneyrac added a comment - I attached a patch that:
  • always set the host as deleted (we always keep the entry into the database)
  • keep old settings (we don't delete the service references)
Hide
Jerome Mouneyrac added a comment -

I edited the function phpdoc into the patch to match the patch behavior
I'll probably commit the patch soon if nobody is opposed too.

Show
Jerome Mouneyrac added a comment - I edited the function phpdoc into the patch to match the patch behavior I'll probably commit the patch soon if nobody is opposed too.
Hide
Peter Bulmer added a comment -

Hey Jerome,

I'm not actively working on anything mnet right now. I've got some fairly major improvements that I want to land, but they're waiting for the role assignments rework.

Due to db layer improvements, mnet enrolments are very broken on postgres in moodle 2.0, so for me even if your patch breaks mnet in m2.0 a little, it'll be hard to tell ^^
^^ Postgres is (rightly) throwing it's hands up at some of the stuff that's going on.

Glad to see you're having a look at it.
Pete.

Show
Peter Bulmer added a comment - Hey Jerome, I'm not actively working on anything mnet right now. I've got some fairly major improvements that I want to land, but they're waiting for the role assignments rework. Due to db layer improvements, mnet enrolments are very broken on postgres in moodle 2.0, so for me even if your patch breaks mnet in m2.0 a little, it'll be hard to tell ^^ ^^ Postgres is (rightly) throwing it's hands up at some of the stuff that's going on. Glad to see you're having a look at it. Pete.
Hide
Jerome Mouneyrac added a comment -

I was trying to make the remote repository plugin working but I spent all my time on mnet (just half a day not that much). For example at the beginning, the peer key is never recognized, I always have to copy it manually. As it was working in 2.0 some months ago, it started to be a bit suspicious.
At this moment one of the peer just has a blank services page and the other site has a working services page... that's quite weird and it is a blocker bug for me, I have to find out why.
If you tell me that Mnet is broken with postgres, it probably is on other DB I guess.
Happy if I can give a bit of help into the Mnet jungle
I'll let you know when I know more about the mnet situation

Show
Jerome Mouneyrac added a comment - I was trying to make the remote repository plugin working but I spent all my time on mnet (just half a day not that much). For example at the beginning, the peer key is never recognized, I always have to copy it manually. As it was working in 2.0 some months ago, it started to be a bit suspicious. At this moment one of the peer just has a blank services page and the other site has a working services page... that's quite weird and it is a blocker bug for me, I have to find out why. If you tell me that Mnet is broken with postgres, it probably is on other DB I guess. Happy if I can give a bit of help into the Mnet jungle I'll let you know when I know more about the mnet situation
Hide
Nigel McNie added a comment -

For the record: I just tried on the cvshead version of Moodle as of today, the problem is still there, and Jerome's patch still fixes it.

We all know MNET is busted and needs a champion, but I humbly submit that this is a problem for another day. Maybe this patch could be applied for now, given that?

Show
Nigel McNie added a comment - For the record: I just tried on the cvshead version of Moodle as of today, the problem is still there, and Jerome's patch still fixes it. We all know MNET is busted and needs a champion, but I humbly submit that this is a problem for another day. Maybe this patch could be applied for now, given that?
Hide
Jerome Mouneyrac added a comment -

I think it's reasonable too till we design the mnet champion. I committed the patch.
Thanks all.

PS: at Moodle HQ we talked about a "port" of mnet as a web service protocol, but it's still in an early stage of discussion.

Show
Jerome Mouneyrac added a comment - I think it's reasonable too till we design the mnet champion. I committed the patch. Thanks all. PS: at Moodle HQ we talked about a "port" of mnet as a web service protocol, but it's still in an early stage of discussion.

People

Dates

  • Created:
    Updated:
    Resolved: