mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-29 08:23:36 -05:00
Merge pull request #135 from overleaf/spd-debugging
Add extra debug logging, and enable it
This commit is contained in:
commit
f27d167554
5 changed files with 27 additions and 4 deletions
|
@ -451,6 +451,7 @@ public class Bridge {
|
||||||
RawDirectory oldDirectoryContents,
|
RawDirectory oldDirectoryContents,
|
||||||
String hostname
|
String hostname
|
||||||
) throws SnapshotPostException, IOException, MissingRepositoryException, ForbiddenException, GitUserException {
|
) throws SnapshotPostException, IOException, MissingRepositoryException, ForbiddenException, GitUserException {
|
||||||
|
Log.debug("[{}] pushing to Overleaf", projectName);
|
||||||
try (LockGuard __ = lock.lockGuard(projectName)) {
|
try (LockGuard __ = lock.lockGuard(projectName)) {
|
||||||
pushCritical(
|
pushCritical(
|
||||||
oauth2,
|
oauth2,
|
||||||
|
@ -538,10 +539,11 @@ public class Bridge {
|
||||||
if (maxFileNum.isPresent()) {
|
if (maxFileNum.isPresent()) {
|
||||||
long maxFileNum_ = maxFileNum.get();
|
long maxFileNum_ = maxFileNum.get();
|
||||||
if (directoryContents.getFileTable().size() > maxFileNum_) {
|
if (directoryContents.getFileTable().size() > maxFileNum_) {
|
||||||
|
Log.debug("[{}] Too many files: {}/{}", projectName, directoryContents.getFileTable().size(), maxFileNum_);
|
||||||
throw new FileLimitExceededException(directoryContents.getFileTable().size(), maxFileNum_);
|
throw new FileLimitExceededException(directoryContents.getFileTable().size(), maxFileNum_);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Log.info("[{}] Pushing", projectName);
|
Log.info("[{}] Pushing files ({} new, {} old)", projectName, directoryContents.getFileTable().size(), oldDirectoryContents.getFileTable().size());
|
||||||
String postbackKey = postbackManager.makeKeyForProject(projectName);
|
String postbackKey = postbackManager.makeKeyForProject(projectName);
|
||||||
Log.info(
|
Log.info(
|
||||||
"[{}] Created postback key: {}",
|
"[{}] Created postback key: {}",
|
||||||
|
|
|
@ -7,6 +7,7 @@ import java.util.Map;
|
||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
|
import uk.ac.ic.wlgitbridge.util.Log;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Winston on 20/11/14.
|
* Created by Winston on 20/11/14.
|
||||||
|
@ -35,29 +36,40 @@ public class ProjectLockImpl implements ProjectLock {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void lockForProject(String projectName) {
|
public void lockForProject(String projectName) {
|
||||||
|
Log.debug("[{}] taking project lock", projectName);
|
||||||
getLockForProjectName(projectName).lock();
|
getLockForProjectName(projectName).lock();
|
||||||
|
Log.debug("[{}] taking reentrant lock", projectName);
|
||||||
rlock.lock();
|
rlock.lock();
|
||||||
|
Log.debug("[{}] taken locks", projectName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void unlockForProject(String projectName) {
|
public void unlockForProject(String projectName) {
|
||||||
|
Log.debug("[{}] releasing project lock", projectName);
|
||||||
getLockForProjectName(projectName).unlock();
|
getLockForProjectName(projectName).unlock();
|
||||||
|
Log.debug("[{}] releasing reentrant lock", projectName);
|
||||||
rlock.unlock();
|
rlock.unlock();
|
||||||
|
Log.debug("[{}] released locks", projectName);
|
||||||
if (waiting) {
|
if (waiting) {
|
||||||
|
Log.debug("[{}] waiting for remaining threads", projectName);
|
||||||
trySignal();
|
trySignal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void trySignal() {
|
private void trySignal() {
|
||||||
int threads = rwlock.getReadLockCount();
|
int threads = rwlock.getReadLockCount();
|
||||||
|
Log.debug("-> waiting for {} threads", threads);
|
||||||
if (waiter != null && threads > 0) {
|
if (waiter != null && threads > 0) {
|
||||||
waiter.threadsRemaining(threads);
|
waiter.threadsRemaining(threads);
|
||||||
}
|
}
|
||||||
|
Log.debug("-> finished waiting for threads");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void lockAll() {
|
public void lockAll() {
|
||||||
|
Log.debug("-> locking all threads");
|
||||||
waiting = true;
|
waiting = true;
|
||||||
trySignal();
|
trySignal();
|
||||||
|
Log.debug("-> locking reentrant write lock");
|
||||||
wlock.lock();
|
wlock.lock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,7 @@ public class WriteLatexPutHook implements PreReceiveHook {
|
||||||
ReceivePack receivePack,
|
ReceivePack receivePack,
|
||||||
Collection<ReceiveCommand> receiveCommands
|
Collection<ReceiveCommand> receiveCommands
|
||||||
) {
|
) {
|
||||||
|
Log.debug("-> Handling {} commands in {}", receiveCommands.size(), receivePack.getRepository().getDirectory().getAbsolutePath());
|
||||||
for (ReceiveCommand receiveCommand : receiveCommands) {
|
for (ReceiveCommand receiveCommand : receiveCommands) {
|
||||||
try {
|
try {
|
||||||
handleReceiveCommand(
|
handleReceiveCommand(
|
||||||
|
@ -73,17 +74,20 @@ public class WriteLatexPutHook implements PreReceiveHook {
|
||||||
receiveCommand
|
receiveCommand
|
||||||
);
|
);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
Log.debug("IOException on pre receive: {}", e.getMessage());
|
||||||
receivePack.sendError(e.getMessage());
|
receivePack.sendError(e.getMessage());
|
||||||
receiveCommand.setResult(
|
receiveCommand.setResult(
|
||||||
Result.REJECTED_OTHER_REASON,
|
Result.REJECTED_OTHER_REASON,
|
||||||
e.getMessage()
|
e.getMessage()
|
||||||
);
|
);
|
||||||
} catch (OutOfDateException e) {
|
} catch (OutOfDateException e) {
|
||||||
|
Log.debug("OutOfDateException on pre receive: {}", e.getMessage());
|
||||||
receiveCommand.setResult(Result.REJECTED_NONFASTFORWARD);
|
receiveCommand.setResult(Result.REJECTED_NONFASTFORWARD);
|
||||||
} catch (GitUserException e) {
|
} catch (GitUserException e) {
|
||||||
|
Log.debug("GitUserException on pre receive: {}", e.getMessage());
|
||||||
handleSnapshotPostException(receivePack, receiveCommand, e);
|
handleSnapshotPostException(receivePack, receiveCommand, e);
|
||||||
} catch (Throwable t) {
|
} catch (Throwable t) {
|
||||||
Log.warn("Throwable on pre receive: ", t);
|
Log.warn("Throwable on pre receive: {}", t.getMessage());
|
||||||
handleSnapshotPostException(
|
handleSnapshotPostException(
|
||||||
receivePack,
|
receivePack,
|
||||||
receiveCommand,
|
receiveCommand,
|
||||||
|
@ -91,6 +95,7 @@ public class WriteLatexPutHook implements PreReceiveHook {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Log.debug("-> Handled {} commands in {}", receiveCommands.size(), receivePack.getRepository().getDirectory().getAbsolutePath());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleSnapshotPostException(
|
private void handleSnapshotPostException(
|
||||||
|
|
|
@ -27,6 +27,10 @@ public class Log {
|
||||||
logger.debug(msg, t);
|
logger.debug(msg, t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void debug(String format, Object... args) {
|
||||||
|
logger.info(format, args);
|
||||||
|
}
|
||||||
|
|
||||||
public static void info(String msg) {
|
public static void info(String msg) {
|
||||||
logger.info(msg);
|
logger.info(msg);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,10 +22,10 @@
|
||||||
</appender>
|
</appender>
|
||||||
|
|
||||||
<!-- Set log levels for the application (or parts of the application). -->
|
<!-- Set log levels for the application (or parts of the application). -->
|
||||||
<logger name="uk.ac.ic.wlgitbridge" level="INFO" />
|
<logger name="uk.ac.ic.wlgitbridge" level="DEBUG" />
|
||||||
|
|
||||||
<!-- The root log level determines how much our dependencies put in the logs. -->
|
<!-- The root log level determines how much our dependencies put in the logs. -->
|
||||||
<root level="WARN">
|
<root level="INFO">
|
||||||
<appender-ref ref="stdout" />
|
<appender-ref ref="stdout" />
|
||||||
<appender-ref ref="stderr" />
|
<appender-ref ref="stderr" />
|
||||||
</root>
|
</root>
|
||||||
|
|
Loading…
Reference in a new issue