Projects tigase _server server-core Issues #565
user cache bug: cache not remove the user info when i remove the user info from db ? (#565)
Closed
peirong jiang opened 9 years ago
Due Date
2015-12-30

today I send a delete user request by rest api to tigase server some times(>3).

the first time return "the user have deleted successfully".but the other times also return the same message.

so I check the JDBCRepository.java and know have a user cache to manage users.

I traced the codes find the first time request return "deleted successfully" but the user cache not remove the user immediately.

pls verify this problem.

the tigase version: 7.0.2 release

peirong jiang commented 9 years ago

peirong jiang wrote:

today I send a delete user request by rest api to tigase server some times(>3).

the first time return "the user have deleted successfully".but the other times also return the same message.

so I check the JDBCRepository.java and know have a user cache to manage users.

I traced the codes find the first time request return "deleted successfully" but the user cache not remove the user immediately.

pls verify this problem.

the tigase version: 7.0.2 release

I have found this problem's reason.

JDBCRepository.java

	
	public long getUserUID(BareJID user_id) throws TigaseDBException {
		Long cache_res = (Long) cache.get(user_id.toString());

		if (cache_res != null) {
			return cache_res.longValue();
		}    // end of if (result != null)

		long result = -1;

		try {
			result = getUserUID(null, user_id);
		} catch (SQLException e) {
			throw new TigaseDBException("Error retrieving user UID from repository: ", e);
		}
		+// if result<1 , don't put it into cache
		if(result>0) {
			cache.put(user_id.toString(), Long.valueOf(result));
		}+

		return result;
	}

also this class: TigaseCustomAuth.java need to optimize it.

public void removeUser(BareJID user) throws UserNotFoundException, TigaseDBException {
		if (deluser_query == null) {
			return;
		}

		try {
			PreparedStatement remove_user = data_repo.getPreparedStatement(user, deluser_query);

			synchronized (remove_user) {
				remove_user.setString(1, user.toString());
				remove_user.execute();
			}
		} catch (SQLException e) {
			throw new TigaseDBException("Problem accessing repository.", e);
		}
//need the finaaly? remove  deleted-user from cache.
	}
peirong jiang commented 9 years ago

peirong jiang wrote:

today I send a delete user request by rest api to tigase server some times(>3).

the first time return "the user have deleted successfully".but the other times also return the same message.

so I check the JDBCRepository.java and know have a user cache to manage users.

I traced the codes find the first time request return "deleted successfully" but the user cache not remove the user immediately.

pls verify this problem.

the tigase version: 7.0.2 release

romove user

service.getUserRepository().removeUser(jid) ->this code will remove the cache user info

service.getAuthRepository().removeUser(jid) ->this code will not remove the cache user info,it will be delay

Artur Hefczyc commented 9 years ago

Yes, I think you are correct, there might be this kind of a problem. However, I would consider it a low impact issue for a few reasons:

  1. Cache is disabled in a cluster mode, so the problem will not happen

  2. On a typical single-mode installation, with a few thousands users online, it is likely that a user's JID is not in cache when you attempt to remove the user

Andrzej Wójcik (Tigase) commented 9 years ago

In version 7.0.2 we had old script resposible for handling REST API to manage users. For admin user It was already updated to use adhoc command which fixes this issue.

I found similar issue in user management script for REST API for user to manage his own account and fixed issue.

All fixes were done in version 7.1.0-SNAPSHOT.

issue 1 of 1
Type
Bug
Priority
Minor
Assignee
RedmineID
3491
Version
tigase-server-8.0.0
Spent time
6h
Issue Votes (0)
Watchers (0)
Reference
tigase/_server/server-core#565
Please wait...
Page is in error, reload to recover